mysql_fetch_array(): supplied argument is not a valid MySQL result resource....
程序员文章站
2022-05-22 12:26:25
...
还是结合代码说明一下:
呵呵,每天积累一点东西。
<?php $username = $_POST['username']; $name = $_POST['name']; $pwd = $_POST['pwd']; $email = $_POST['email']; if(!empty($username)) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con);//连接一个名字叫test的数据库 $sql = "select * from t_user"; if(!$con) { die("Error:".mysql_error()); } $result = mysql_query($sql); echo "<table border ='1' bgcolor = 'lightblue'>"; echo "<tr><th>用户名</th><th>姓名</th><th>密码</th><th>邮箱</th></tr>"; while($row = mysql_fetch_array($result))//记得这里是把$result放入 mysql_fetch_array中,我一开始吧$sql放进去也报的是上面这种错 { echo "<tr><td>{$row['f_username']}</td>";//这里字段名写错就可能导致出现上面的错误 echo "<td>{$row['f_name']}</td>"; echo "<td>{$row['f_password']}</td>"; echo "<td>{$row['f_email']}</td></tr>\n"; } echo "</table>"; mysql_close($con);//关闭连接 } ?>
呵呵,每天积累一点东西。
上一篇: 如何处理PDF乱码的问题!
推荐阅读
-
php错误提示: mysql_fetch_row(): supplied argument is not a valid MySQL
-
mysql_fetch_row(): supplied argument is not a valid MySQL result resource,何人能解?该如何解决
-
为何总是Warning: mysql_fetch_object(): supplied argument is not a valid MySQL resul
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该如何处理
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource....
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource....
-
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result res,该怎么解决
-
php出现Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result解决办法
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource,该怎么解决
-
mysql_fetch_array(): supplied argument is not a valid MySQL result resource