Mysql error can you help with this question

Avatar
  • Answered
my mysql query is not accepting single quotes please can anybody help on how i can solve that it brings the following reply below

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 'You have an error in your SQL syntax; check the manual that corresponds to your ' at line 1

$sql="SELECT * FROM work WHERE firstname='$_POST[textfield]'";
$result=mysql_query($sql) or die(mysql_error());
$num=mysql_num_rows($result);


if ($num >0){

header('location:events_admin.php?msg=record already exists');

exit();
}else{

include("uppix.php");
$date=date(" j F Y, \a\\t g:i a", time());
$event_content=nl2br($_POST['textfield']);
$event_content2=mysql_escape_string($event_content);
Avatar
anonymous
Hello,

I would suggest putting $_POST[textfield] into a variable then calling that variable in the SQL statement instead of your above example.

Best Regards,
TJ Edens