Select 连字符列名失败
Select failing on hyphenated column name
我想 select 来自数据库的两个字段,id
和 photo-url
。
代码是:
$results = mysqli_query($connecDB,"SELECT id, photo-url FROM list ORDER BY id ASC LIMIT ".$position.", ".$item_per_page."");
while($row = mysqli_fetch_array($results)){
echo '<li id="item_'.$row["id"].'">'.$row["id"].'. <span class="page_name">'.$row["photo-url"].'</li>';
}
echo '</ul>';
问题是:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,
boolean given in...(line while).
$results = mysqli_query($connecDB, "SELECT `id`, `photo-url` FROM `list` ORDER BY `id` ASC LIMIT ".$position.", ".$item_per_page."");
在查询中使用 `
符号来引用字段或表的名称。
photo-url
用刻度线包裹该列名称。 SQL 将其解释为 "photo MINUS url"。
SELECT id, `photo-url`
或使用下划线重命名
SELECT id, photo_url
这样你就不必使用刻度。
我想 select 来自数据库的两个字段,id
和 photo-url
。
代码是:
$results = mysqli_query($connecDB,"SELECT id, photo-url FROM list ORDER BY id ASC LIMIT ".$position.", ".$item_per_page."");
while($row = mysqli_fetch_array($results)){
echo '<li id="item_'.$row["id"].'">'.$row["id"].'. <span class="page_name">'.$row["photo-url"].'</li>';
}
echo '</ul>';
问题是:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in...(line while).
$results = mysqli_query($connecDB, "SELECT `id`, `photo-url` FROM `list` ORDER BY `id` ASC LIMIT ".$position.", ".$item_per_page."");
在查询中使用 `
符号来引用字段或表的名称。
photo-url
用刻度线包裹该列名称。 SQL 将其解释为 "photo MINUS url"。
SELECT id, `photo-url`
或使用下划线重命名
SELECT id, photo_url
这样你就不必使用刻度。