mysql - Sql query not running in php and maybe an issue related to sql -


function running , other query of inserting data running commented below.
error getting "error: select max(product_id) product_attribute "

  public function add_tbl1($attribute_id , $attribute_description){     $con=$this->con;     $id = mysqli_real_escape_string($con, $attribute_id);     $description = mysqli_real_escape_string($con, $attribute_description);     $sql2="select max(product_id) product_attribute ";     $no=0;       if ($con->query($sql2) === true) {         $no= $con->query($sql2);         $no=$no+1;         echo $no;       } else {         echo "error: " . $sql2 . "<br>" . $con->error;     }         /*$sql = "insert product_attribute ( attribute_id, attribute_description)     values ( '$id', '$description')";      if ($con->query($sql) === true) {         echo "new record created successfully";     } else {         echo "error: " . $sql . "<br>" . $con->error;     }   */      } 

if $con mysqli-connection, $con->query select never return true. either return false or resource.

you should rather check with

 $con->query($sql2) !== false)) 

from http://php.net/manual/en/mysqli.query.php

returns false on failure. successful select, show, describe or explain queries mysqli_query() return mysqli_result object. other successful queries mysqli_query() return true.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -