Insert returning null and no error message from the script


#21

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);

#22

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


#23

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