views:

25

answers:

3

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

A: 

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());
madsleejensen
A: 

You have a wrong quote here:

`trial'
      ^
codaddict
+3  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.)

BoltClock
+1, for the complete answer, addressing all his bugs.
codaddict
@codaddict: It took me longer than the 5-minute edit window to get them all in though :/
BoltClock