gecko Posted February 1, 2009 Share Posted February 1, 2009 Hi, Im having problems querying a database that is running on an older version of mySQL: version 4.1.22 Whenever I run an insert query from a PHP file, I get the following error message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use I know the SQL query executes fine on a newer version of mySQL, but upgrading the version through my web host isn't an option. I've had a brief look in the documentation for any particular differences in how to write the query for version 4.1.22, but I can't see any differences! I am currently using the following query to insert a record, which returns the error shown above. $query = "INSERT INTO tblguestbook (id, from, email, comment) VALUES (NULL, `$from`, `$email`, `$comment`)"; $insertresults = @mysql_query($query)or die(mysql_error()); Any ideas on how to solve this problem would be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/ Share on other sites More sharing options...
printf Posted February 1, 2009 Share Posted February 1, 2009 Are those single quotes surrounding your values or back-tics? $query = "INSERT INTO tblguestbook (id, from, email, comment) VALUES ( '', '" . mysql_real_escape_string ( $from ) . "', '" . mysql_real_escape_string ( $email ) . "', '" . mysql_real_escape_string ( $comment ) . "' );"; Quote Link to comment https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/#findComment-751906 Share on other sites More sharing options...
gecko Posted February 1, 2009 Author Share Posted February 1, 2009 Hi, I've tried both back ticks and single quotes, but using either of those returns the same error message It still returns the syntax error unfortunately Quote Link to comment https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/#findComment-751913 Share on other sites More sharing options...
printf Posted February 1, 2009 Share Posted February 1, 2009 can you show me the what the table looks like... example of what I want to see.. CREATE TABLE `bbs_spell` ( `sid` int(10) unsigned NOT NULL DEFAULT '0', `opt` text NOT NULL, PRIMARY KEY (`sid`), KEY `sid` (`sid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Quote Link to comment https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/#findComment-751932 Share on other sites More sharing options...
fenway Posted February 3, 2009 Share Posted February 3, 2009 Please echo the actual query. Quote Link to comment https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/#findComment-753346 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.