我正在使用这个php代码来拉出我创建的测试表中的列标题。然而,每当我尝试运行代码时,它都会给我这个错误:There was an error running the query [Table 'meta_test.information_schema' doesn't exist]
从我在网上看到的信息看起来我的代码应该可行,但这是我第一次尝试这样的事情。这是我的代码:
$camp = $_POST['campaign'];
$query = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA WHERE TABLE_NAME = '$camp'";
try{
if(!$result = $db->query($query)){
die('There was an error running the query [' . $db->error . ']');
}
echo "<pre>";
print_r($result);
echo "</pre>";
}catch(exception $e){
echo $e;
}
答案 0 :(得分:1)
您需要指定表名:
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '$camp'