这是我的数据库连接代码和查询代码:
// Connecting, selecting database
$link = mysql_connect('MySQLA22.webcontrolcenter.com', 'shudson', '*******')
or die('Could not connect: ' . mysql_error());
mysql_select_db('henrybuilt') or die('Could not select database');
$sql = "SELECT ID, vcImageName FROM corp_images WHERE idPage = 6";
$query = mysql_query($sql) or die ("Error");
发生了什么事?
答案 0 :(得分:2)
$sql = "SELECT ID, vcImageName FROM corp_images WHERE idPage = 6"
它失踪了;
$sql = "SELECT ID, vcImageName FROM corp_images WHERE idPage = 6";
答案 1 :(得分:1)
出现正确...尝试添加此适应代码from the manual以进一步调试并查看您所学的内容:
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$query) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $sql;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($query)) {
echo $row['ID'];
echo $row['vcImageName'];
}