Jump to content

Mysql Error


Twist3d

Recommended Posts

Hell again.

Well what im trying to do as usual as build this Toplist.

What this code is supposed to do, Is Log the IP address in a Field in a Mysql Database.

Then Updates votes the the ID = the ID from the GET thing on the previous page.

 

But it gives me this 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 ''23' at line 1

 

Here is my code:

 

<?php
$dbhost = "mysql"; //Database Host 
$dbuser = "16584_toplist"; //Database User 
$dbpass = "PASSWORD"; //Database Password 
$dbname = "16584_toplist"; //Database Name 

//connect 
$db = mysql_pconnect($dbhost,$dbuser,$dbpass); 
mysql_select_db("$dbname",$db);

$id = $_GET['id'];
$name = $_GET['name'];
$ip=$_SERVER['REMOTE_ADDR'];

mysql_query("INSERT INTO iplog (IP) VALUES
('$ip')") 
or die(mysql_error());

mysql_query("UPDATE data SET votes=+1 WHERE id='$id")
or die(mysql_error());

echo "<center>You have just voted for $name</center>";
echo "<center>Click <a href=viewtoplist.php>To view the toplist</center>";

?>

 

I have left the connection to the mysql up, because Line 1 is that, but i have used this exact code on ALL of my other files that need connecting to the Mysql database, and it works fine.

Any help?

 

 

-----------------

 

P.S

I just found out that this code actually Logs the IP address, but it doesn't set the votes to +1.

If thats the problem, i need help on that.

Link to comment
https://forums.phpfreaks.com/topic/186016-mysql-error/
Share on other sites

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.