这是我的php代码
<?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;
}
?>
我已经验证了凭据,并且表中也有数据,但我仍然没有得到任何记录。任何任何指出为什么?
更新::
工作代码
<?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;
}
?>