doudu6100 2014-08-21 10:09
浏览 26
已采纳

PHP mysql查询返回一个空白屏幕

I've commented out the bottom part, and the SQL query works fine. Its the displaying of the query where the error is coming from i believe.

$host = "127.0.0.1"; 
$user = "root"; 
$pass = "Toom13371!";

$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().":     ".mysql_error()."<BR>");

// 2. Selecting DB.

$dbname = "filters"; 
mysql_select_db($dbname);

// 3. Build/Test SQL Query

$sql = ("select * from filter_bandpass where start_passband=" . $_POST['Lowfreq'] . "         and stop_passband='" . $_POST['Highfreq'] . "'");
//echo $sql; //Comment/Uncomment to test sql query.

// 4. Retrieve info from MySQL.

$query = mysql_query($sql);

// 5. Display Query.

echo "<table border='1'>
<tr>
<th>Low Frequency</th>
<th>High Frequency</th>
</tr>";

while($row = mysql_fetch_array($query)) {
  echo "<tr>";
  echo "<td>" . $row['Lowfreq'] . "</td>";
  echo "<td>" . $row['Highfreq'] . "</td>";
  echo "</tr>";
}

echo "</table>";
  ?>

Any help would be appreciated, I'm sure it's going to be some small stupid error i've over looked.

Thanks in advance :)

  • 写回答

3条回答 默认 最新

  • douduan2272 2014-08-21 10:12
    关注

    I'm guessing, based on your query, that you need to change this

    mysql_select_db($dbname);
    

    to

    mysql_select_db($dbname, $connection);
    

    and

    while($row = mysql_fetch_array($query)) {
      echo "<tr>";
      echo "<td>" . $row['Lowfreq'] . "</td>";
      echo "<td>" . $row['Highfreq'] . "</td>";
      echo "</tr>";
    }
    

    to

    while($row = mysql_fetch_array($query)) {
      echo "<tr>";
      echo "<td>" . $row['start_passband'] . "</td>";
      echo "<td>" . $row['stop_passband'] . "</td>";
      echo "</tr>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集