Jump to content

quick question


paulman888888

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/111158-quick-question/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/111158-quick-question/#findComment-570515
Share on other sites

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']'")

Link to comment
https://forums.phpfreaks.com/topic/111158-quick-question/#findComment-570520
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.