I am reading PHP and mySQL web development book and so far have been doing all PHP and mysql using procedural. But then he talks about accessing mysql with objects.
This works for me:
$query="select * FROM testing";
$result=mysqli_query($db,$query);
while($row=mysqli_fetch_array($result)){
}
But when I try to do it with classes, it doesn't
@ $db=new mysqli('localhost','root','','test');
if(mysqli_connect_errno()){
echo "ERROR:";
exit;
}
$query="select * FROM testing";
$result=$db->query($query);
$row=$result->fetch_assoc();
Do I have to write my own class so that it determines what the request and fetch_assoc do? Or what?
source
share