Insert returning null and no error message from the script

it has something to do with my code.here is it.

$sql=“INSERT INTO property (property_name, property_location, property_price, category_id, status)VALUES (?, ?, ?, ?, ?)”;

  	     $params=[$property_name, $property_location, $property_price, 
					$category_id, $status];

   $insert=$db->runQuery($sql,$params);
					if($insert){
						
						echo "good";
					}
					else { echo "bad";}
				
  	     var_dump($sql);
  	     var_dump($params);
  	    var_dump($insert);

That’s the same code that you put above, and $insert will always be null because your runQuery() function does not return a value, whether the query worked or not. So you must return a value to be able to decide whether the query worked or did not work.

http://php.net/manual/en/function.return.php

thanks it’s working now. i appreciate all your effort.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.