Jump to content

[SOLVED] MySQL Problem


xshanelarsonx

Recommended Posts

I keep getting this error using this code.

 

-String

$Reason = "You don't live in B-Town";

 

-Function

function autoban($date, $reason, $ip){
    $autoban="INSERT into bans(ip,date,comment,active) VALUES('$ip','$date','$reason','1')";
        mysql_query($autoban) or die(mysql_error());
    echo ("<center><h1><font color='White'>You have been banned on the $date</font></h1></center>");
    echo ("<center><font color='red'>Reason:</font> <font color='White'>$reason</font></center>");
    exit();
}

 

-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 't live in B-Town','1')' at line 1

Link to comment
https://forums.phpfreaks.com/topic/39975-solved-mysql-problem/
Share on other sites

This don't work. What I'm trying to do is make it here my code will not give a error when reason has a ' in it.

 

$autoban="INSERT into bans(ip,date,comment,active) VALUES('$ip','$date','$reason','1')";
        mysql_query($autoban) or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/39975-solved-mysql-problem/#findComment-193311
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.