gpt4 book ai didi

php - mysql_query() 需要参数

转载 作者:行者123 更新时间:2023-11-29 14:47:02 25 4
gpt4 key购买 nike

需要有关此错误的帮助。看不出有什么问题。

错误:

Warning: mysql_query() expects parameter 1 to be string, resource given in C:\wamp\www\pm website\php\bulletin_board\bulletin_board.php on line 48

代码:

<?php
$con = mysql_connect("localhost","root",""); //Databse connection
if(!$con)
{
die ('Could not connect to DB' . mysql_error()); //Error promt
}
mysql_select_db("profound_master", $con); //Selecting the DB
$view = mysql_query("SELECT * FROM bulletin ORDER BY pro_no DESC"); //Selecting the table from the DB

if (!mysql_query ($view, $con))
{
die ('Error Sir' . mysql_error()); //Error promt
}
while ($row = mysql_fetch_array($view))

echo "<table width=\"1000\">";
echo "<tr id=\"boardLetter\">";
echo "<th width=\"46\">".$row['pro_no']."</th>";
echo "<th width=\"56\">".$row['date']."</th>";
echo "<th width=\"138\">".$row['project']."</th>";
echo "<th width=\"138\">".$row['task']."</th>";
echo "<th>".$row['originated']."</th>";
echo "<th>".$row['incharge']."</th>";
echo "<th>".$row['deadline']."</th>";
echo "<th width=\"139\">".$row['status']."</th>";
echo "<th width=\"151\">".$row['comment']."</th>";
echo "<th>".$row['din']."</th>";
echo "</tr>";
echo "</table>";
?>

最佳答案

你写的是:

$view = mysql_query("SELECT * FROM bulletin ORDER BY pro_no DESC"); //Selecting the table from the DB
if (!mysql_query ($view, $con))

请注意如何执行查询,将其结果资源分配给 $view,然后尝试使用 $view 作为 SQL 运行另一个查询?但 $view 不是 SQL,它是结果资源,因此会出现错误。

只需这样写:

$view = mysql_query("SELECT * FROM bulletin ORDER BY pro_no DESC");
if (!$view)

关于php - mysql_query() 需要参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6741269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com