doulipi3742 2016-05-21 20:40
浏览 46
已采纳

php代码没有给出正确的结果[关闭]

the below code is not being executed

 (edited)
   <?php error_reporting(E_ALL); ini_set('display_errors', 1);


     print "Hello world!"; 

$con = mysqli_connect($host,$uname,$pwd,$db) or die(mysqli_error());


     $sql1="SELECT * FROM USERS WHERE username= 'aya'");


   $result = mysqli_query($sql1);
 if ($result && mysqli_num_rows($result) > 0) {
     print "Hea!"; 
 }



// json response array
$response = array("error" => FALSE);


    $email = $_POST['username'];
    $password = $_POST['password'];


    $sql="SELECT * FROM USERS WHERE username= 'aya'";
    if(mysqli_query($con,$sql))
    {
     echo json_encode($response);
    }



?>

the error is here in this part because when I remove it , the link give results

  $sql="SELECT * FROM USERS WHERE username= 'aya'") or die(mysqli_error())";


     $result = mysqli_query($sql);
     if ($result && mysqli_num_rows($result) > 0) {
     print "Hea!"; 
      }
  • 写回答

4条回答 默认 最新

  • dszpyf4859 2016-05-21 20:50
    关注

    The code in question has an obvious syntax and logical errors.
    Correct your code as shown below:

     ...
     // stop script execution with error message if db connection fails
     $con = mysqli_connect($host, $uname, $pwd, $db) or die(mysqli_error());
    
     $sql1 = "SELECT * FROM USERS WHERE username= 'aya'";
    
     $result = mysqli_query($sql1);
     if ($result && mysqli_num_rows($result) > 0) {
         print "Hea!"; 
     }
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?