1

这是我的数据库连接代码和查询代码:

// 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");
  • 连接、选择或查询时没有“或死”错误
  • 没有error_log文件
  • 如果我在我的 sql 浏览器中运行 sql 查询,它就会执行

到底是怎么回事???

4

2 回答 2

2
$sql = "SELECT ID, vcImageName FROM corp_images WHERE idPage = 6"

它不见了;

$sql = "SELECT ID, vcImageName FROM corp_images WHERE idPage = 6";
于 2012-06-26T17:40:10.420 回答
1

看起来是正确的...尝试从手册中添加此改编代码以进一步调试并查看您学到了什么:

// 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'];
}
于 2012-06-26T17:38:46.513 回答