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()); Link to comment https://forums.phpfreaks.com/topic/226182-mysql-error/ 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 Link to comment https://forums.phpfreaks.com/topic/226182-mysql-error/#findComment-1167622 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()) Link to comment https://forums.phpfreaks.com/topic/226182-mysql-error/#findComment-1167623 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? Link to comment https://forums.phpfreaks.com/topic/226182-mysql-error/#findComment-1167629 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>' ); Link to comment https://forums.phpfreaks.com/topic/226182-mysql-error/#findComment-1167656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.