mysql - SHOW TABLES LIKE 上的语法错误

标签 mysql php-5.5

我不明白为什么它说You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''User_notifications''关于此查询:

<?php
include 'constants.php';
$username=$_POST['username'];
$notiftable=$username.'_notifications';
$con=new mysqli('',databaseuser,databasepassword,database);
if($con)
{
    $q="SHOW TABLES LIKE '$notiftable'";

最佳答案

您的表名User_notifications正在被双重转义(即它被转义两次)。这种情况很可能发生,因为 PHP 函数已经对其进行了转义,而您正在第二次执行此操作。尝试不要自己转义表名称,即:

 $q = "SHOW TABLES LIKE $notiftable";

关于mysql - SHOW TABLES LIKE 上的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36996108/

相关文章:

mysql_ -> PDO |我怎样才能达到相同的结果

php - 不同地区的锂电路线

php - 升级到 PHP5.5 时 Wordpress 崩溃

php - 与被识别为构造函数的类同名的小写方法

MySQL 选择查询值

php - 使用 try {} catch {} 与 if {} else {} 相比有什么优势?

MySQL - 比较两个表的值并记录它们

MySQL:添加非索引字表

php - 当作为参数传递时,PHP 如何解释和评估函数和匿名函数?

PHP:带有 mysqli 的未知 MySQL 服务器主机