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

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.