所以我想为Users创建一个数据库,并使用变量将值插入到字段中。最初我尝试使用它来调用do函数,但它没有正确读取变量所以我决定只使用prepare并单独执行。这是我的代码:
$dbh->do("DROP TABLE IF EXISTS Users");
$dbh->do("CREATE TABLE Users(
zid TEXT,
Name TEXT,
Email TEXT,
password TEXT,
Mates TEXT,
Program TEXT,
Courses TEXT,
Suburb TEXT,
Birthday TEXT)");
$zid = "z33432523";
$name = "John Doe";
$email = "email@gmail.com";
$password = "alien";
$mates = "z3459148 z3458291";
$program = "";
$courses = "";
$suburb = "";
$birthday = "13/5/1992";
$sth = $dbh->prepare('INSERT INTO Users VALUES (?, ?, ?, ?, ?. ?, ?, ?, ?)');
$sth->execute($zid, $name, $email, $password, $mates, $program, $courses, $suburb, $birthday);
$dbh->disconnect();
但是,如果我尝试运行此代码,则会收到以下错误:
DBD::SQLite::db prepare failed: near ".": syntax error at ./dbm.pl line 35.
我不确定问题到底是什么?
答案 0 :(得分:1)
a