警告:mysql_fetch_array()期望参数1是资源,php中给出的字符串

时间:2014-07-15 12:30:50

标签: php mysql

这是我的代码。我的代码中有错误是 - Warning: mysql_fetch_array() expects parameter 1 to be resource ...请解决它

我只想从id获取调用状态,这是从我的表中的存储过程获取的。

           <?php
          echo "Result from SP procOutput_sum:::::$SP_VAL";
          $mysqli = mysql_connect("localhost", "root", "", "call_conference");
          if (!$mysqli) {
           die('Could not connect: ' . mysql_error());
            }

             ?>
           <?php
           $select="select call_status from tbl_call_origin where id='$SP_VAL'";
           while ($row = mysql_fetch_array($select)){
         echo 'Status: '.$row['call_status'];
            }
            ?>

2 个答案:

答案 0 :(得分:1)

您缺少mysql_query函数来获取$select并返回$result以传递给mysql_fetch_array

$select="select call_status from tbl_call_origin where id='$SP_VAL'";
$result = mysql_query($select);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
    ...
}

答案 1 :(得分:0)

<?php
      echo "Result from SP procOutput_sum:::::$SP_VAL";
      $mysqli = mysql_connect("localhost", "root", "", "call_conference");
      if (!$mysqli) {
       die('Could not connect: ' . mysql_error());
        }

         ?>
       <?php
       $select="select call_status from tbl_call_origin where id='$SP_VAL'";
       $results = mysql_query($select);
       while ($row = mysql_fetch_array($results)){
     echo 'Status: '.$row['call_status'];
        }
        ?>