我想在我的数据库中获取我的表的列表,并将这些名称变成变量,但无论我尝试什么,我都会收到“意外的T_LNUMBER,期待T_VARIABLE”错误。 这是有问题的部分:如何将表名变成变量?
$result1 = mysqli_query($connection, "SHOW TABLES LIKE '%".$date3."%'");
$row1 = mysqli_fetch_row($result1);
if (isset($row1[0])) { $01 = $row1[0];}
if (isset($row1[1])) { $02 = $row1[1];}
我在做什么错?
可能是你需要阅读这http://stackoverflow.com/questions/2468497/php-using-regex-to- get-the-tablename-from-a-mysql-query –
根据$ date3'的分配情况,你可能会打开SQL代码注入。您应该使用参数化查询。 – chris85
假设你的表名是用户,你需要用户作为$ user或其他东西。 –