I am trying to remove data from the database, but in the end here is the error:

Warning: mysql_fetch_array () expects parameter 1 to be resource, given in J: \ home \ localhost \ www \ admin \ section \ page.php on line 5

Php code:

include "/../setting_sql.php"; $d_table=mysql_query("SELECT * FROM 'order'"); while($stroka=mysql_fetch_array($d_table)) { echo $stroka["id"]; echo " <br>"; } 

Reported as a duplicate by participants PashaPash , Visman , Vladimir Glinskikh , BOPOH , Saidolim 10 Oct '15 at 14:01 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • The mysql_ functions are deprecated in php . Do not use them! - Visman
  • And replace the single quotes around the table name with apostrophes. - Visman

2 answers 2

Try running this code and see what error it produces.

 include "/../setting_sql.php"; $d_table=mysql_query("SELECT * FROM 'order'"); if($d_table) { while($stroka=mysql_fetch_array($d_table)) { echo $stroka["id"]; echo " <br>"; } } else { print mysql_error(); } 

PS Yes, and 'order' is better to replace the order

  • one
    order is a keyword, so without escaping from such a table, sampling will not work - etki

replace 'order' with `order` , check if the connection to the database, as you wrote above, is established, where is the problem in one of these options

  • You shouldn't have written like that. Parser gobbled up your whole thought: D - Visman
  • do not use single quotes, but those that are on the tilde ~ - Dmitry Tkhorzhevsky
  • They are called apostrophes . - Visman