当我使用时:
CREATE TABLE test(cardname TEXT, qty TINYINT);
在MySQL中,它工作正常,但我一直在尝试用PHP和mysqli_query做同样的事情,我一直在努力:
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 'CREATE TABLE test(cardname TEXT, qty TINYINT);' at line 3
有人可以帮忙吗?
编辑: 以下是您要求的一些代码:
$con = mysqli_connect("127.2.83.1", "jenerikgs", "", "members");
$username = $_POST['username'];
$q = "INSERT INTO users
VALUES('$username', '$password', 20, '../res/logo.png', 0, 0, 0, 'I have not set up a description yet.');
CREATE TABLE $username(cardname TEXT, qty TINYINT);";
mysqli_query($con, $q);
echo mysqli_error($con);
echo "<br/>";
echo "<br/>";
echo "<br/>";
echo $q;
答案 0 :(得分:2)
您可以尝试这个吗,mysqli_multi_query()
函数对数据库执行一个或多个查询。查询用分号分隔。
mysqli_multi_query($con,$q);
而不是
mysqli_query($con, $q);