Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 语法错误。正在尝试显示表名和字段名_Php_Mysql - Fatal编程技术网

Php 语法错误。正在尝试显示表名和字段名

Php 语法错误。正在尝试显示表名和字段名,php,mysql,Php,Mysql,我要做的是显示表名,然后在其后显示每个字段名。 它似乎一直工作,直到我进入我的字符表,它不会显示字段名,并返回我这个错误 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“character”附近使用的正确语法 我想升级我的MySQL,但什么也没发生,我还是设法得到了错误 $showtablequery = "SHOW TABLES"; $showtablequery_result = mysql_query($showtablequery); while($showt

我要做的是显示表名,然后在其后显示每个字段名。 它似乎一直工作,直到我进入我的字符表,它不会显示字段名,并返回我这个错误

您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“character”附近使用的正确语法

我想升级我的MySQL,但什么也没发生,我还是设法得到了错误

$showtablequery = "SHOW TABLES";
$showtablequery_result  = mysql_query($showtablequery);
while($showtablerow = mysql_fetch_array($showtablequery_result))
{
        echo "<b>$showtablerow[0]</b> - ";

        $showcolumnquery = "SHOW COLUMNS FROM $showtablerow[0]";
        $showcolumnquery_result = mysql_query($showcolumnquery) or die("Query failed with error: ".mysql_error());

        while($showcolumnfield = mysql_fetch_array($showcolumnquery_result))
        {
            echo "$showcolumnfield[0] | ";
        }
        echo "<br /><br />";
}
$showtablequery=“showtables”;
$showtablequery\u result=mysql\u query($showtablequery);
而($showtablerow=mysql\u fetch\u数组($showtablequery\u result))
{
回显“$showtablerow[0]-”;
$showcolumnquery=“显示来自$showtablerow[0]的列”;
$showcolumnquery\u result=mysql\u query($showcolumnquery)或die(“查询失败,错误:”.mysql\u error());
而($showcolumnfield=mysql\u fetch\u数组($showcolumnquery\u result))
{
echo“$showcolumnfield[0]|”;
}
回声“

”; }
将表名包装在`(勾号)中,这样它就不会将表名解释为命令

这会解决你的问题

"SHOW COLUMNS FROM `$showtablerow[0]`";