Jump to content

[SOLVED] PHP / MySQL syntax error


9three

Recommended Posts

Hey,

 

I'm pretty sure that my syntax for MySQL is correct, so it could be my PHP syntax that is off.

 

All I'm doing is checking to see if the record of a person already exist. I'm checking by name, email, date, ip, and user agent.

 

    $input = "SELECT
              Name, Email, Date, IP, Agent
              FROM user_input
              WHERE
              Name = '$name', Email = '$email', Date = '$date', IP = '$ip', Agent = '$agent'";
    $check = $connection->query($input);
    if (mysql_num_rows($check) > 1)
      echo 'I\'m sorry you can only post once.';
   else
     //Run code

 

The exception is here:

 

exception 'Exception' with message '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 ' Email = '[email protected]', Date = 'February 15, 2009', IP = '127.0.0.1', A' at line 5' in C:\Users\9three\Desktop\Server\htdocs\gb\library\mysql.class.php:38 Stack trace: #0 C:\Users\9three\Desktop\Server\htdocs\gb\index.php(67): mysql->query('SELECT?? ...') #1 {main} 

Link to comment
https://forums.phpfreaks.com/topic/145367-solved-php-mysql-syntax-error/
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.