php查询数据库,该如何处理

WBOY
Release: 2016-06-13 10:18:11
Original
860 people have browsed it

php查询数据库
session_start();
include("../../control/config.php");
$id=$_SESSION['user'];
$p_id=$_GET['id'];//试卷ID
$time=$_GET['t_time'];
$result=mysql_query("select * from PAPERS where P_ID='$p_id'");
$rows=mysql_fetch_assoc($result);
preg_match_all('/(\d{2}|\d{1}|\d{3}?)/',$rows['P_QUES'], $timu);//获取题目数组
for ($i=0;$i {
$question=$timu[0][i];
$result1=mysql_query("select * from QUESTION where Q_ID='$question'")
while($rows1=mysql_fetch_array($reslut1))
  {
echo "题目:".$rows1['Q_TEXT'];
echo "选项A:".$rows1['Q_A'];
echo "选项B:".$rows1['Q_B'];
echo "选项C:".$rows1['Q_C'];
echo "选项D:".$rows1['Q_D'];
echo "
";
}
}
mysql_close($db);
?>
提示红色返回不是有效结果集··错在哪?

------解决方案--------------------
$result1=mysql_query("select * from QUESTION where Q_ID='$question'") 单引号去掉,加了单引号不会被解析。
------解决方案--------------------
$reslut1查询出来的可能是空值,没有记录。你把sql在mysql中调试一下,看看有没有结果。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template