This is driving me nuts, I can't believe how difficult it is to do this.
I had a previous problem whefre I could not get a $variable to be recognised in a MySQL SELECT. WIth some help from here I got that solved by using concatenation to build the select as follows:
$query = 'SELECT * FROM employees WHERE first="' .$resp. '"';
Now I am on the part of the program that takes inout from the user and INSERTs it into the database. The variables have been set by <input> statements and I have even output a couple of those variables to the screen to make sure they are valid and have values. But I can't get those variables into the query, after it executes the database itself either has nothing in it (as I assume the SQL has failed) or has the actual variable names itself.
This is what SHOULD work according to the documentation I have read:
$sql= "INSERT INTO employees (id, first, last, phone) VALUES (NULL, '$first', '$last', '$phone')";
but that just inserts a record with blank values except for the autoincremented id field.
I have tried changing to $(first), ${first}, ${${first}} and other permutations to no avail.
Anyone have an answer?
Stuart
I had a previous problem whefre I could not get a $variable to be recognised in a MySQL SELECT. WIth some help from here I got that solved by using concatenation to build the select as follows:
$query = 'SELECT * FROM employees WHERE first="' .$resp. '"';
Now I am on the part of the program that takes inout from the user and INSERTs it into the database. The variables have been set by <input> statements and I have even output a couple of those variables to the screen to make sure they are valid and have values. But I can't get those variables into the query, after it executes the database itself either has nothing in it (as I assume the SQL has failed) or has the actual variable names itself.
This is what SHOULD work according to the documentation I have read:
$sql= "INSERT INTO employees (id, first, last, phone) VALUES (NULL, '$first', '$last', '$phone')";
but that just inserts a record with blank values except for the autoincremented id field.
I have tried changing to $(first), ${first}, ${${first}} and other permutations to no avail.
Anyone have an answer?
Stuart