php – T_CONSTANT_ENCAPSED_STRING blocking ip – Education Career Blog

Here is line 37;

$write = mysql_query("INSERT INTO `trial' VALUES (" '', '".$ip."', '1' ") or die(mysql_error());

The error may be coming from further up.. But I’m not quite sure :S

I am trying to block the ip of a

,

There are both PHP and SQL syntax errors in the same line of code.

You incorrectly quoted your table name, have misplaced double quotes in your VALUES expression and have misplaced parentheses in your or die statement. Here’s the fixed statement:

$write = mysql_query("INSERT INTO `trial` VALUES ( '', '".mysql_real_escape_string($ip)."', '1' )") or die(mysql_error());

(Additionally, yes, I did throw in that mysql_real_escape_string() in case you didn’t escape your query variables.)

,

You have a wrong quote here:

`trial'
      ^

,

You have some ” inside the VALUES() that are not escaped. And trial is quoted wrong. (as codaddict mentioned)

$write = mysql_query("INSERT INTO `trial` VALUES ('', '".$ip."', '1') or die(mysql_error());

Leave a Comment