paulman888888 Posted June 20, 2008 Share Posted June 20, 2008 I get 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 '.175.53, 06.20.08)' at line 2 and this is my code <?php include("connect.php"); ?> <?php $ipaddress =$_SERVER['REMOTE_ADDR']; $thedate = date("m.d.y"); mysql_query("INSERT INTO intowar1 (ipaddress, thedate) VALUES($ipaddress, $thedate)") or die(mysql_error()); ?> Please can you tell me what i have done wrong? Thankyou paul Quote Link to comment Share on other sites More sharing options...
peranha Posted June 20, 2008 Share Posted June 20, 2008 mysql_query("INSERT INTO intowar1 (ipaddress, thedate) VALUES('{$ipaddress}', '{$thedate}')") Try that i added '{ }' to the values. That is what I use. Quote Link to comment Share on other sites More sharing options...
Jabop Posted June 20, 2008 Share Posted June 20, 2008 http://www.phpfreaks.com/forums/index.php/board,3.0.html MySQL help forums Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted June 20, 2008 Author Share Posted June 20, 2008 have i got to do the same with this one as well? <?php include("connect.php"); ?> <?php $query = "SELECT * FROM intowar1"; $result = mysql_query($query) or die("ERROR LEVEL 3"); $row = mysql_fetch_array($result) or die("ERROR LEVEL 4"); echo $row['ipaddress']; mysql_query("DELETE FROM example WHERE ipaddress=$row['ipaddress']") or die("ERROR LEVEL 5"); ?> and the error code Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/something.com/something.php on line 11 Quote Link to comment Share on other sites More sharing options...
andrewgarn Posted June 20, 2008 Share Posted June 20, 2008 I get 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 '.175.53, 06.20.08)' at line 2 and this is my code <?php include("connect.php"); ?> <?php $ipaddress =$_SERVER['REMOTE_ADDR']; $thedate = date("m.d.y"); mysql_query("INSERT INTO intowar1 (ipaddress, thedate) VALUES($ipaddress, $thedate)") or die(mysql_error()); ?> Please can you tell me what i have done wrong? Thankyou paul you just need '' around the variables in the value section dont you? mysql_query("INSERT INTO intowar1 (ipaddress, thedate) VALUES('$ipaddress', '$thedate')") or die(mysql_error()); and for your second example: <?php mysql_query("DELETE FROM example WHERE ipaddress='$row['ipaddress']'") 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.