Mod-Jay Posted January 31, 2011 Share Posted January 31, 2011 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()); Quote Link to comment Share on other sites More sharing options...
JD* Posted January 31, 2011 Share Posted January 31, 2011 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 Quote Link to comment Share on other sites More sharing options...
Mod-Jay Posted January 31, 2011 Author Share Posted January 31, 2011 INSERT INTO `noxipcom_toplist`.`votes` (`ip`, `serverId`, `ownerId`, `date`) VALUES (::1, 3, , now()) Quote Link to comment Share on other sites More sharing options...
JD* Posted January 31, 2011 Share Posted January 31, 2011 Ok, so it looks like your variables are empty. Can you post the rest of your code? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 31, 2011 Share Posted January 31, 2011 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>' ); Quote Link to comment 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.