0
结果这是我的代码:库MySQLi不返回从数据库
<?php
include('config.php');
$mysqli = new mysqli($db['host'], $db['user'], $db['pass'], $db['name']);
if ($mysqli->connect_error)
throw new Exception('Couldn\'t connect to MySQL: ' . $mysqli->connect_error);
// Check for a ID parameter
if(isset($_GET['id']) && !empty($_GET['id']))
{
$skinId = (int)$_GET['id'];
// Build a query to get skin info from the database
$stmt = $mysqli->prepare('SELECT name, description, author, timestamp, url FROM `skins` WHERE id=?');
$stmt->bind_param('i', $skinId);
// Execute query
$stmt->execute();
$stmt->bind_result($result['name'], $result['desc'], $result['auth'], $result['time'], $result['url']);
echo $result['name'];
} else {
// Show a 404 page
echo "bad";
}
$mysqli->close();
?>
当这样跑,我没有得到任何结果回来。当我尝试时,我可以验证$skinId
的确拥有有效的皮肤ID,并且它不是一个空变量。当我使用phpMyAdmin在本地主机上运行相同的语句时,我会得到正确的行,并返回查询中请求的所有信息。当我做print_r($result)
我得到这个:
Array
(
[name] =>
[desc] =>
[auth] =>
[time] =>
[url] =>
)
任何人都知道是怎么回事?提前致谢。 :)
确定该ID是在数据库? – ircmaxell 2011-05-16 17:05:43