9three Posted February 16, 2009 Share Posted February 16, 2009 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} Quote Link to comment https://forums.phpfreaks.com/topic/145367-solved-php-mysql-syntax-error/ Share on other sites More sharing options...
sKunKbad Posted February 16, 2009 Share Posted February 16, 2009 Use AND instead of commas in your query (the error is showing you where to start). Quote Link to comment https://forums.phpfreaks.com/topic/145367-solved-php-mysql-syntax-error/#findComment-763145 Share on other sites More sharing options...
9three Posted February 16, 2009 Author Share Posted February 16, 2009 nvm seems to be working. Looks like I didn't reload the page. Quote Link to comment https://forums.phpfreaks.com/topic/145367-solved-php-mysql-syntax-error/#findComment-763175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.