I am very new to php and I am trying to write a few simple php scripts just to get a feel for the language.

I am having a problem with one script that keeps on returning this warning message:
Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/solare11/public_html/rk/test-connect.php on line 27

Source line 27 is:

I am not attempting to write cutting edge code here, I just want to experiment with how certain things work. So, I am not interested in recoding this as PDO, nor security faults etc. I just want to know what is wrong with this code and how I should correct it.

I have read the php documentation and searched the web for answers to this and I have seen so many different answers that I am just totally confused ???

Can any friendly person out there give me a solution?



[php]// define database variables
$host = ‘localhost’;
$user = $_SERVER[‘DBUSER’];
$pass = $_SERVER[‘DBPASS’];
$db = $_SERVER[‘DBRK’];

if(mysqli_connect_errno()) die('Connection Error ‘.mysqli_connect_errno().’ : '.mysqli_connect_error());

echo “
We are here 01

$query=“SELECT * FROM customer”;
echo "Customer id: " . $row[‘custid’] . " Password: " . $row[‘password’] . “

echo “
We are here 02

$query=“UPDATE customer SET password=‘aaabbb’ WHERE custid=‘71’”;

echo “
Result02 is:
” . $result02;


INSERT, UPDATE and DELETE queries return true or false so $result01 is not a mysqli result. No need to call mysqli_free_result() on it.

Absolutely brilliant, AbraCadaver, Simple language that even I can understand :wink:

Many thanks for taking the effort to sort that out for me - you wouldn’t beleve how long I spent looking for the answer !

Sponsor our Newsletter | Privacy Policy | Terms of Service