dt4233 2014-12-11 15:19
浏览 19

mysql_num_rows()期望参数1是第17行的资源[重复]

This question already has an answer here:

I know this question has been asked loads of times, and I have looked at the answers but I cant get my code to work correctly. The code I have tried is displayed below.

<?php

include 'connection.php';

$connection=mysqli_connect("localhost","root","","c3392262");

if (isset($_POST['search'])) {

  $search = $_POST['search'];

  if (!empty($search)) {

    $query = "SELECT name FROM products WHERE name LIKE '%$search%'";
    $query_run = mysqli_query($connection, $query);
    if (mysql_num_rows($query_run)>=1) {

      echo 'found';

    } else {

      echo 'No results found';
    }
  }
}

?>

<form name = "searchbar" method = "POST" action = "searchBar.php">
<input name = "search" type = "text" size = "40" maxlength = "50" >

<input type="submit" value="Submit">
</form>
</div>
  • 写回答

3条回答 默认 最新

  • douzhi9921 2014-12-11 15:21
    关注

    You are mixing mysql_ and mysqli_ functions. Don't do that, they are incompatible. Stick with mysqli_.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度