php调用存储过程后出错Commands out of sync; you can't run this command now 如果是 mysqli 或 pdo 可以读空结果集但你是 mysql 所以只能重新连接数据库 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 error_reporting(0); require_once("db.php");//此文件位于下面 //显示表二计算结果 $query="call score2('PartTwo".$_REQUEST[num]."',@A,@B,@c,@D,@E,@F,@G,@score);"; $result=executeQuery($query); if(!$result) die(mysql_error()); while($r=mysql_fetch_row($result)){ echo '<font style="color:#0000FF">睡眠质量(A):</font>'.$r[0].'     <font style="color:#0000FF">入睡时间(B):</font>'.$r[1].'     <font style="color:#0000FF">睡眠时间(C):</font>'.$r[2].'     <font style="color:#0000FF">睡眠效率(D):</font>'.$r[3].'     <font style="color:#0000FF">睡眠障碍(E):</font>'.$r[4].'     <font style="color:#0000FF">催眠药物(F):</font>'.$r[5].'     <font style="color:#0000FF">日间功能障碍(G):</font>'.$r[6].'     <font style="color:#0000FF">PSQI总分:</font>'.$r[7].'<br/><br/>'; } mysql_free_result($result); //显示表三计算结果 $query="call score('PartTwo".$_REQUEST[num]."',3,@score);"; $result=executeQuery($query); if(!$result) die(mysql_error()); while($r=mysql_fetch_row($result)){ echo '<font style="color:#0000FF">SCORE:</font>'.$r[0].'   '; if(($r[0]>6)&&($r[0]<12)) { echo '瞌睡'; }elseif(($r[0]>11)&&($r[0]<17)){ echo '过度瞌睡'; }elseif($r[0]>16){ echo '有危险性的瞌睡'; } } mysql_free_result($result); //以下为db.php $dbserver="localhost"; $dbusername="question"; $dbpassword="questionadmin"; $dbname="questionnaire"; $conn=false; function executeQuery($query) { global $conn,$dbserver,$dbname,$dbpassword,$dbusername; global $message; if (!($conn = @mysql_connect ($dbserver,$dbusername,$dbpassword))) $message="Cannot connect to server"; if (!@mysql_select_db ($dbname, $conn)) $message="Cannot select database"; $result=mysql_query($query,$conn); if(!$result) $message="Error while executing query.<br/>Mysql Error: ".mysql_error(); else return $result; } function closedb() { global $conn; if(!$conn) mysql_close($conn); } 你只定义了 closedb 函数,并没执行 我试过执行closedb(),还是会报错 怎么匹配 中纯中文,不匹配中文标点。 基础题,通过递归正则匹配数字元素 推荐几本php的好书吗入门进阶都可 关于sscanf函数的用法 查找HTML中类似" <!-- -->内容 <!--End of Insertion -->" 请教php为什么捕获不到mysql的异常? 成都公司聘请专职php程序员 有没有谁开发过将自己的网站或系统和现在主流的一些论坛的用户整合起来的?即网站用户和论坛用户统一管理。 提供免费ftp,供大家交流 PHP做网站 怎么用php读取ppt文档的内容,并且在浏览器中显示出来??? PHP处理音频文件
require_once("db.php");//此文件位于下面
//显示表二计算结果
$query="call score2('PartTwo".$_REQUEST[num]."',@A,@B,@c,@D,@E,@F,@G,@score);";
$result=executeQuery($query);
if(!$result) die(mysql_error());
while($r=mysql_fetch_row($result)){
echo '<font style="color:#0000FF">睡眠质量(A):</font>'.$r[0].'     <font style="color:#0000FF">入睡时间(B):</font>'.$r[1].'     <font style="color:#0000FF">睡眠时间(C):</font>'.$r[2].'     <font style="color:#0000FF">睡眠效率(D):</font>'.$r[3].'     <font style="color:#0000FF">睡眠障碍(E):</font>'.$r[4].'     <font style="color:#0000FF">催眠药物(F):</font>'.$r[5].'     <font style="color:#0000FF">日间功能障碍(G):</font>'.$r[6].'     <font style="color:#0000FF">PSQI总分:</font>'.$r[7].'<br/><br/>';
}
mysql_free_result($result);
//显示表三计算结果
$query="call score('PartTwo".$_REQUEST[num]."',3,@score);";
$result=executeQuery($query);
if(!$result) die(mysql_error());
while($r=mysql_fetch_row($result)){
echo '<font style="color:#0000FF">SCORE:</font>'.$r[0].'   ';
if(($r[0]>6)&&($r[0]<12))
{
echo '瞌睡';
}elseif(($r[0]>11)&&($r[0]<17)){
echo '过度瞌睡';
}elseif($r[0]>16){
echo '有危险性的瞌睡';
}
}
mysql_free_result($result);
//以下为db.php
$dbserver="localhost";
$dbusername="question";
$dbpassword="questionadmin";
$dbname="questionnaire";
$conn=false;
function executeQuery($query)
{
global $conn,$dbserver,$dbname,$dbpassword,$dbusername;
global $message;
if (!($conn = @mysql_connect ($dbserver,$dbusername,$dbpassword)))
$message="Cannot connect to server";
if (!@mysql_select_db ($dbname, $conn))
$message="Cannot select database";
$result=mysql_query($query,$conn);
if(!$result)
$message="Error while executing query.<br/>Mysql Error: ".mysql_error();
else
return $result;
}
function closedb()
{
global $conn;
if(!$conn)
mysql_close($conn);
}