Query was empty PHP error

拈花ヽ惹草 提交于 2019-12-02 02:47:37

What do you try to achieve with this line?

$result = mysql_query($query);

Just delete it and change the line above to

$result = mysql_query('insert into cart values('.$user.','.$itemNum.','.$name.', '.$image.','.$quantity.', '.$price.')'); 

[Edit]

Btw. you are forgetting the " (quotes) inside the query which causes an sql error to occur, leading to $query = false (see manual). $query (false) then gets converted to string, resulting in '' (an empty string) which you pass to mysql_query and that generates an "Query was empty"-Message, as it should because you tried to send an empty query.

It can also mean the table which is in consideration is empty.This condition arises when the "DELETE FROM table_name where ;" is used. Here if the table "table_name" has no data, it cannot delete anything and hence it shows an error stating that the query is empty.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!