Jump to content

[SOLVED] Mysql php error help?


plznty

Recommended Posts

<?php
$RSN = $_GET["n"];
$IP = $_SERVER['REMOTE_ADDR'];
$TOPIC = $_GET["thread"];
echo "<title>FailScape Community // $TOPIC</title>";

// MySQL Connection
mysql_connect("localhost", "webhostg_master", "pass") or die(mysql_error());
mysql_select_db("webhostg_IPtracker") or die(mysql_error());

mysql_query("INSERT INTO database 
(rsn, ip) VALUES('$RSN', '$IP' ) ") 
or die(mysql_error());  

echo "$RSN - $TOPIC was not found on Failscape servers. Please type a correct URL.";
?>

 

I get the 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 'database (rsn, ip) VALUES('ryan', '11.11.148.85' )' at line 1

Link to comment
https://forums.phpfreaks.com/topic/175633-solved-mysql-php-error-help/
Share on other sites

As you can probably imagine the word database (the start of the part of the query that was printed in the error message) probably has special meaning to a database query language.

 

Ref: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

 

You either need to use a different name for your table or you need to enclose database in back-ticks ` everywhere it gets used in a  query.

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.