警告:mysql_query()期望参数1是字符串,对象在.....中给出(需要param ???)

时间:2014-06-06 02:42:23

标签: php

我收到了这条消息

Warning: mysql_query() expects parameter 1 to be string, object given in

关于这一行:

$QSelPro = mysql_query($con,"SELECT * FROM products");

这有什么问题????

1 个答案:

答案 0 :(得分:2)

来自mysql_query()的PHP手册:

mixed mysql_query ( string $query [, resource $link_identifier = NULL ] )

因此,改为

$QSelPro = mysql_query("SELECT * FROM products", $con);

同样来自同一页:

Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the future...

换句话说,请考虑不使用mysql_*。它已被弃用。而是使用mysqli_*pdo