dqkxo44488 2015-02-26 09:16
浏览 22

相同的代码适用于localhost,但在服务器上不起作用

I am going to insert some data into database. Before inserting into database, it will check whether the record is exist or not by using mysqli_num_rows. Below is my part of code

$agentSQL = 'SELECT * FROM members WHERE agent_no = "'.$agentNo.'" and id = "'.$agentMemberID.'"';

if (!$agentChk = mysqli_query($dbCon, $agentSQL)) {
    echo "<script>alert('Error: %s
', mysqli_error($dbCon));</script>";
    exit();
}

$agentChkrow = mysqli_num_rows($agentChk);

if ($agentChkrow != 0) {
  //insert data
} else {
  //record exist
}

It has several types of agent, eg. USA agent, Fr agent, Kr agent. So that it will be look like:

if($_POST['type'] == "USA agent"){
  //above code
} else if ($_POST['type'] == "Fr agent"){
  //above code
} else if ($_POST['type'] == "Kr agent"){
  //above code
} else {
  //blablabla
}

And the current problem is the entire code is worked on localhost, and only the part of Fr agent didn't work. When I get the error message from the script and the error is

MySQL server has gone away

also it will get Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in error without using or die(mysqli_error($dbCon)

I've searched some of solution by this error message. But it seems not relevant to wait_timeout, interactive_timeout and max allowed packet since only a part of code didn't work and the remaining code work normally. How can I solve this problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?