Jump to content

MySQL version causing query problems


gecko

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/143362-mysql-version-causing-query-problems/
Share on other sites

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 ) . "' );";

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;

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.