在mysql创建表的名称中使用php变量 [英] use php variable in name of mysql create table
本文介绍了在mysql创建表的名称中使用php变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我想使用一个 php 变量作为我使用查询创建的 mysql 表名称的一部分.我使用了两种类型的引号,就像我在互联网上看到的一个例子.它应该创建一个单独的表名.$cn
不是数组,而是单个值.我启用了 php 错误报告,但没有显示任何错误.这是我尝试过的:
Hey guys i want to use an php variable as a part of a name of a mysql table which i create with a query. I used two types of quotes like a example i saw on the internet. It should create an individual table name. $cn
is not an array it is an single value. I have php error reporting enabled and it doesn't show any errors. Here is what i tried:
$sql2 = "CREATE TABLE lm_Warenkorb_`".$cn."`
(
Index TEXT,
)";
为什么这不起作用?这可能吗?希望很清楚我想做什么.
Why isn't this working? Is this possible or not? Hope it is clear what i want to do.
推荐答案
$sql2 = "CREATE TABLE `lm_Warenkorb_".$cn."`
(
Index TEXT,
)";
这篇关于在mysql创建表的名称中使用php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文