Jump to content

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 = 'ywwedez@dedw.com', 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.