0

I am trying to connect to mysql database via php, check if a given entry is there in the database and act accordingly. Even when I try the php with entries that exist in the database, the query is returning null.

   <?php
        $host='host';
        $uname='username';
        $pwd='password';
        $db="db";

        $con = new mysqli($host,$uname,$pwd,$db) or die("connection failed");

        if(mysqli_connect_error($con)){
                echo "Failed To connect to database";
            }

        $name=$_REQUEST['name'];
        $number=$_REQUEST["number"];
        $email=$_REQUEST['email'];


        $sqlc = $con -> prepare('select * from customer where contact = ? ');
        $sqlc -> bind_param('s', $number);
        $sqlc -> execute();
        $slqc -> store_result();
        $row_cnt = mysqli_num_rows($sqlc);
        if ($row_cnt>=1){
                echo "number already registered";
            }
        else {
                //do something else
             }
        mysqli_close($con);
        ?>

I tried without using store_result() first but to the same effect. Edit: After checking out one of the solutions provided, I have to add that I don't have access to the php.ini settings file. So I cannot use report_error

Sharan
  • 59
  • 8

0 Answers0