Forum Moderators: coopster
Here's the query code:
$query = "INSERT INTO " . $table . " (" . $field_names . ") VALUES(" . $field_values . ")";
$result = mysql_query($query);
print(mysql_affected_rows());
The query string is constructed from strings stored in the mentioned variable, and it was the details of those strings I thought might be to blame for the problem, but if I use print($query);, this is the output I get:
INSERT INTO book_review ('meta_keywords', 'meta_description', 'title', 'author', 'illustrator', 'publisher', 'synopsis', 'review', 'questions', 'writing', 'phonemic', 'phonics', 'fun') VALUES('$meta_keywords', '$meta_description', '$title', '$author', '$illustrator', '$publisher', '$synopsis', '$review', '$questions', '$writing', '$phonemic', '$phonics', '$fun')
Which looks FINE to me (long, but fine). But then maybe I'm so close to it right now that I'm overlooking the obvious. Anyone see anything wrong with this query? If not, can you think of potential causes for this problem?
Thanks in advance for any input.
cEM
In your INSERT query, you have the table names in between apostrophes:
For example:
INSERT INTO book_review ('meta_keywords', 'meta_description' etc etc
Only the values should be between apostrophes, NOT the table names.
INSERT INTO book_review (meta_keywords, meta_description, etc etc
Hope that helps.
:)
In the MySQL GRANT and REVOKE Syntax [dev.mysql.com] pages we find this...
When specifying quoted values, (you should) quote database, table, or column names as identifiers, using backticks (``'). Quote hostnames, usernames, or passwords as strings, using apostrophes (`'').
Basically, if a database, table, or column name as identifier, is not legal as an unquoted identifier, refer to it as a quoted identifier using backticks. But, as I said before, in order that you won't have to worry about it, don't create these values as anything otherwise ;)
Resource:
[dev.mysql.com...]