php - how do i solve this error " Catchable fatal error: Object of class mysqli_result could not be converted to string"? -


$sql = "insert placed_req(username,goodsauto,minitruck,largetruck,price,qty) values('$user_check','$ga','$mt','$lt','$r','$qty')"; $result = mysqli_query($con,$sql); $sql2="select reqid placed_req username='$user_check' , price='$r'"; $ret=mysqli_query($con,$sql2); $sql1 = "insert inv_detail (inv_id,p_name,qty,price) values('$ret','$user_check','$qty','$r')"; //i'm getting error in line $result1 = mysqli_query($con,$sql1); if(isset($result1))     echo "<br></br> invoice generated successfully";     header("refresh:10,url=placeorders.php"); } else {     echo "<br></br> values not selected"; } 

if want put req_id insert query must firts fetch req_id correctly

$sql2="select reqid placed_req username='$user_check' , price='$r'";  $ret=mysqli_query($con,$sql2);  $row = mysqli_fetch_assoc($ret); /* above instruction fetch record database*/  $inv_id = $row['reqid']; 

and put $inv_id insert query statement

$sql1 = "insert inv_detail (inv_id,p_name,qty,price) values('$inv_id','$user_check','$qty','$r')"; //i'm getting error in line $result1 = mysqli_query($con,$sql1); 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -