Issue
Here is my php code
<?php
try
{
$mysqlConnection = mysqli_connect('localhost', 'root', 'root');
if($mysqlConnection)
{
echo "Connected"."\n";
mysqli_select_db('test',$mysqlConnection);
$result = mysqli_query("SELECT * from tbl_details");
$row = mysqli_fetch_array($result);
echo strlen($row);
}
else
{
echo "Not connected";
}
}
catch(Exception $exp)
{
echo $exp;
}
?>
i have verified the credentials and also there is data in the table but still i'm getting no records. Any any point out why??
Update::
Working piece of code
<?php
try
{
$mysqlConnection = mysqli_connect('localhost', 'root', 'root','test');
if($mysqlConnection)
{
echo "Connected"."\n";
$result = $mysqlConnection->query("SELECT NAME,State FROM tbl_details");
echo $result->num_rows."\n";
}
else
{
echo "Not connected";
}
}
catch(Exception $exp)
{
echo $exp;
}
?>
Solution
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');
$resultaat = $mysqli->query("SELECT * FROM tabel");
while ($record = $resultaat->fetch_assoc())
{
print_r($record);
}
Answered By - Jurgo
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.