我一直收到这个错误:
Warning: mysqli_error() expects exactly 1 parameter, 0 given in /Applications/MAMP/htdocs/dbViewer.php on line 71
无法获取数据:
来自此代码
$sql = "SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('Version') AND TABLE_SCHEMA = 'wp_plugin_db'";
$result = mysqli_query($con,$sql);
if(! $result )
{
die('Could not get data: ' . mysqli_error());
}
$arrayCount = 0;
while ($row=mysqli_fetch_array($result))
{
$tableNames[$arrayCount] = $row[0];
$arrayCount++;
}
foreach ($tableNames as $siteName) {
$siteName = mysqli_real_escape_string($con,$siteName);
$sql="SELECT Plugin_Name, Version, WPVersion FROM `".$siteName."` ORDER BY Plugin_Name";
$result=mysqli_query($con,$sql);
if(! $result )
{
die('Could not get data: ' . mysqli_error());
}
echo "Website Name: $siteName ---- " ;
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
echo " Plugin Name :{$row['Plugin_Name']} ".
" Version : {$row['Version']} ".
" Wordpress Version : {$row['WPVersion']} ".
" | ";
}
echo "<br>";
}
mysqli_close($con);
错误显示line 71
die('Could not get data: ' . mysqli_error());
真正的错误发生在$sql="SELECT Plugin_Name, WPVersion, Version FROM ".$siteName." ORDER BY Plugin_Name";
我知道这一点,因为当我从selec中取出WPVersion并注释掉该元素的echo时,它可以正常工作。请帮助我似乎无法解决这个问题,是语法吗?我觉得很傻哈哈。
提前谢谢!
答案 0 :(得分:3)
你真的读错了吗?你忘了将链接参数传递给mysql,ep>
mysqli_error($con);
^^^^--- missing