Jump to content

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.

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.