PHP MySQL fails whenever WHERE statement is present -


I am trying to do a simple query in a small SECL table, but when I insert the clause I suddenly added an invalid query error (a while (mysql_fetch_array) {} without work). The MYSQL console returns a 1064 (syntax) error, however, I checked the MySQL documentation and I'm using the appropriate syntax as much as possible.

  & lt ;? Php $ ind = rand (1,3); $ Bid = null; $ = Null sign; $ Afil = Null; $ Con = mysql_connect (localhost, root, ********); // Database mysql_select_db ("phone_site", $ con); // Select the table $ query = "SELECT * FROM quotes WHERE index = $ IND"; // Get a line for that index $ data = mysql_query ($ query); // Print Out Print ("& lt; p id = \" quote \ "& gt;". $ Data ['quote']. "& Lt; / p & gt;"); Print ("& lt; p id = \" ename \ "& gt;" $ data ['sign']. "& Lt; / p & gt;"); Print ("& lt; p id = \" afill \ "& gt; -". $ Data ['afil']. "& Lt; / p & gt;"); Mysql_close ($ con); // Close connection? & Gt;  

Does anyone know what the problem is? Is there something wrong in my mysql I am using XAMPP?

index is of a MySQL:

< P> Some words such as SELECT, DELETE, or BIGINT have been reserved and require special treatment for use, such as table and column name, which may also be true for the names of the underlying work is.

If you quote as stated in

, then the protected word is allowed as an identifier, with that type of name, you have to quote the column name Will be - see:

Identifier quote character is Bachetic ("`)

Which means that your query should look like this:


After watching, to complete my answer Who has Said:

I am surprised that when the table was created.

I think the table was created with some tools such as phpMyAdmin or MySQL Workbench ;


Edit after comment: I edit after that comment


is not visible, but you are using this type of code:

  $ data = mysql_query ($ query); print ("& lt; p id = \" Quotation \ "& gt;" $ data ['citation']. "& Lt; / P & gt; ");  

The function does not return data directly: it only gives a" resorts " (quote from a manual page) :

Returns the result to use the returned data, and other tasks must be passed to deal with the result tables.

Fixed Not that it will solve all your problems (


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -