你能告诉我MySql语法有什么问题吗?
$sql
使用Warning: PDOStatement::execute():
SQLSTATE[42000]: Syntax error or access violation: 1064 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
''submission' (project_id) VALUES ('1')' at line 1 in /app/model/ProjectModel.php on line 54
运行此操作后,我收到此错误:
$sql2
如果我使用$sql
运行查询并且没有参数,则执行并插入所需的值。 {"status":"ok"}++ Starting Swift_Transport_EsmtpTransport<br />
<< 220-s206.avahost.net ESMTP Exim 4.86 #2 Fri, 20 Nov 2015 16:42:03 +0200
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
<br />
>> EHLO znaidusvoe.com
<br />
<< 250-s206.avahost.net Hello s206.avahost.net [77.120.110.175]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
<br />
>> AUTH LOGIN
<br />
<< 334 VXNlcm5hbWU6
<br />
>> c3VwcG9ydEB6bmFpZHVzdm9lLmNvbQ==
<br />
<< 334 UGFzc3dvcmQ6
<br />
>> YWRtaW4xcTJ3M2U0cjV0
<br />
<< 235 Authentication succeeded
<br />
++ Swift_Transport_EsmtpTransport started<br />
>> MAIL FROM:<support@znaidusvoe.com>
<br />
<< 250 OK
<br />
>> RCPT TO:<vladislav.kosko@gmail.com>
<br />
<< 250 Accepted
<br />
>> DATA
<br />
<< 354 Enter message, ending with "." on a line by itself
<br />
>>
.
<br />
<< 250 OK id=1Zzmt1-002Hws-Op
<br />
++ Stopping Swift_Transport_EsmtpTransport<br />
>> QUIT
<br />
<< 221 s206.avahost.net closing connection
<br />
++ Swift_Transport_EsmtpTransport stopped<br />
查询有什么问题?
答案 0 :(得分:2)
http://us3.php.net/manual/en/book.pdo.php#69304
请注意:
赢得了工作:
$sth = $dbh->prepare('SELECT name, colour, calories FROM ? WHERE calories < ?');
这个工作!
$sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ?');
该参数不能应用于表名!!
正如您在此评论中看到的那样,您无法使用PDO中的参数替换表名或列名。
但您可以使用变量来填充表名或列名,例如
select * from $table where $column_name = "bla bla"