Praetorian Posted June 6, 2008 Share Posted June 6, 2008 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 More sharing options...
king Posted June 6, 2008 Share Posted June 6, 2008 $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 More sharing options...
Praetorian Posted June 6, 2008 Author Share Posted June 6, 2008 Ah. Thank you! That fixed it. And I feel better knowing that's something I would never have thought of. heh. Link to comment Share on other sites More sharing options...
Praetorian Posted June 7, 2008 Author Share Posted June 7, 2008 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 More sharing options...
Praetorian Posted June 7, 2008 Author Share Posted June 7, 2008 Nevermind. I missed some quotes. Link to comment Share on other sites More sharing options...
Praetorian Posted June 7, 2008 Author Share Posted June 7, 2008 Okay, same error I had before about syntax. Different query though. $result = mysql_query ("SELECT * FROM '$country' WHERE header = '$edit'") or die(mysql_error()); Link to comment Share on other sites More sharing options...
Synook Posted June 8, 2008 Share Posted June 8, 2008 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 More sharing options...
Praetorian Posted June 8, 2008 Author Share Posted June 8, 2008 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 More sharing options...
Synook Posted June 8, 2008 Share Posted June 8, 2008 What is the error? Link to comment Share on other sites More sharing options...
Praetorian Posted June 8, 2008 Author Share Posted June 8, 2008 It's the same error. It just says "check your manual", syntax error blah blah. It points to this block though. 'SET quote='test' WHERE header='Summary'' so I figure it's either something wrong with the SET or the WHERE.... Link to comment Share on other sites More sharing options...
Synook Posted June 8, 2008 Share Posted June 8, 2008 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 More sharing options...
Praetorian Posted June 8, 2008 Author Share Posted June 8, 2008 Sometimes I think I'm really retarded.Yes, the problem was that $country wasn't set. Oy. Thanks for the help Synook. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.