我尝试从名为test.php的独立php文件中查询wordpress数据库,该文件位于wp安装文件夹的根文件夹中,但是查询不显示任何内容,var dump不显示任何内容,我做错了什么以及如何测试主机是否支持mysqli?(凭据已从数据库连接中删除) enter image description here
<?php
$mysqli = new mysqli('localhost', 'username', 'passwd', 'dbname');
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
/* Select queries return a resultset */
$result = $mysqli->query("select meta_value from wpde_postmeta where meta_key = '_product_attributes' and post_id = '41'") ;
echo $result;
var_dump($result);
/* free result set */
$result->close();
$mysqli->close();
?>
答案 0 :(得分:1)
您缺少数据获取部分:
// Just below $result = $mysqli->query("...") ;
while($obj = $result->fetch_object()){
// Do something with $obj->meta_value
}