Jump to content

php/sql


Praetorian

Recommended Posts

I cannot for the life of me figure out why this isn't working. I'm trying to editing several columns at once using variables, and it keeps giving me a syntax error.

$query = mysql_query("UPDATE dictionary SET 			word='".mysql_real_escape_string($the_word)."',	origin='".mysql_real_escape_string($the_origin)."',	pronounce='".mysql_real_escape_string($pronunciation)."',	definition='".mysql_real_escape_string($the_definition)."',	definitiontwo='".mysql_real_escape_string($the_definitiontwo)."',	fulltext='".mysql_real_escape_string($the_fulltext)."'	WHERE word='$word_word'") or die (mysql_error());

Here's the error it keeps producing.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext='' WHERE word='Absolute Quilting'' at line 6

Is my nesting of quotes wrong? It's driving me insane. Help would be greatly appreciated.

Link to comment
Share on other sites

$query = mysql_query("UPDATE dictionary SET			word='".mysql_real_escape_string($the_word)."',	origin='".mysql_real_escape_string($the_origin)."',	pronounce='".mysql_real_escape_string($pronunciation)."',	definition='".mysql_real_escape_string($the_definition)."',	definitiontwo='".mysql_real_escape_string($the_definitiontwo)."',	`fulltext`='".mysql_real_escape_string($the_fulltext)."'	WHERE word='$word_word'") or die (mysql_error());

Fulltext is a reserved word therefore you must put backticks `` around it. `fulltext`

Link to comment
Share on other sites

Okay, ran into another problem. This query isn't working either. It's not giving me an error, and the header() function passes fine, but it doesn't delete the entry. Where'd I go wrong?

$query_delete = mysql_query("DELETE FROM dictionary WHERE word='$entry'") or die (mysql_error());

Link to comment
Share on other sites

Don't put inverted commas around the table name. If you are worried that a country name may be a reserved keyword then you can use backquotes

$result = mysql_query ("SELECT * FROM `$country` WHERE header = '$edit'") or die(mysql_error());

Link to comment
Share on other sites

Okay removing the quotes fixed that, but yet again I have that syntax error on a different query. And it's not the content of the variables. I've tried with just text and it still produces the syntax error.

mysql_query("UPDATE $country SET quote='$edit_quote' WHERE header='$header_location'") or die (mysql_error());

Link to comment
Share on other sites

Are you sure $country is set? Try printing the querystring.By the way, with MySQL errors, look at the point just before the returned string and that will usually be where the error is.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...