Question:
Hi, i am trying to build a web site with a database but keep getting this error when i try to use php with sql?
anonymous
2009-12-16 13:27:33 UTC
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 'query' at line 1.

Ok now at line 1 is this , i can not see where the problem is but any help on this issue would be just amazing thank you ever so much.
Five answers:
JA12
2009-12-17 04:39:18 UTC
Your best bet with PHP and MySQL is to use the inbuilt functions.



Personally I mostly use these:



mysql_connect

mysql_select_db

mysql_fetch_assoc

mysql_close



Remember never to add a semi-colon on the end of the query, this is the usual problem people bump into.



To test the true error, enter the SQL query into your



phpMyAdmin



installation.
Ken B
2009-12-16 14:12:52 UTC
You need to look at line 1 of the query you have submitted, not line 1 of your PHP/HTML file.



Somewhere in your PHP script, you have a line which probably includes a call to "mysql_query". You need to find out what is the exact query you are passing, and then go from there.



- kb -
Sontu C
2009-12-16 13:55:45 UTC
Seems like you are looking in the wrong file. Sql syntaxes happpen in sql scripts or stored procedures.

Something on that page runs some sql code against your mysql database, or calls a stored procedure on it. You should look in the code / .php file i guess and see where you can find the sql code (inline sql query, stored procedure, etc, and you will find what you are looking for.
RedBishop
2009-12-16 14:17:17 UTC
Print the query, I mean:



$query= "Select * from customer where ID = '32'"

print($query)



doing this, you will see what you are sending to MySQL Engine, or if you are an advanced user you can use an Alert in JavaScript
anonymous
2016-05-26 03:13:50 UTC
A password may be required to access the website


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...