Jump to content

MySQL Error


Mod-Jay

Recommended Posts

I dont know whats wrong

 

Error:

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 '::1, 3, , now())' at line 1

 

Error Line:

                mysql_query('INSERT INTO `'. $db .'`.`votes` (`ip`, `serverId`, `ownerId`, `date`) VALUES ('. $ip .', '. $serverId .', '. $ownerId .', now())') or die(mysql_error());

Link to comment
Share on other sites

Put this on the line above your mysql query:

 

die('INSERT INTO `'. $db .'`.`votes` (`ip`, `serverId`, `ownerId`, `date`) VALUES ('. $ip .', '. $serverId .', '. $ownerId .', now())');

 

And then reload the page. It should print out your query with the variables replaced with their values and you can see what looks incorrect, or post the results here and we'll take a look

Link to comment
Share on other sites

No, actually what the problem looks like is the values aren't quoted in the query string. The IP address looks hosed, but if it were quoted, it would at least insert. $ownerId may be empty. If you form your query string in a variable, without all the unnecessary string concatenation, it makes these errors much easier to spot, and allows you to echo the entire query string when there's an error.

 

$query = "INSERT INTO `$db`.`votes` ( `ip`, `serverId`, `ownerId`, `date` ) VALUES ( '$ip', '$serverId', '$ownerId', now() )";
$result = mysql_query( $query ) or die( "<br>Query string: $query<br>Produced error: " . mysql_error() . '<br>' );

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.