PHP PDO抛出致命错误1064(PHP PDO throwing Fatal error 1064)
我正在学习PDO和准备好的语句,并遇到了问题。 我一直收到这个错误:
Fatal error: Uncaught exception 'PDOException' with message '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 ''Users' WHERE Username = 'yayu'' at line 1' in /home/u230594705/public_html/pages/panel.php:33 Stack trace:#0 /home/u230594705/public_html/pages/panel.php(33): PDOStatement->execute(Array) #1 {main} thrown in /home/u230594705/public_html/pages/panel.php on line 33
使用此代码:
session_start(); $user = $_SESSION["user"]; $table = "Users"; //Establish Connection $dsn = "mysql:host=$dbHost;dbname=$dbName;charset=utf8"; $opt = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $pdo = new PDO($dsn,$dbUser,$dbPass, $opt); //Prepare query to execute $stmt = $pdo->prepare("SELECT Username, Password, Email FROM ? WHERE Username = ?"); $stmt->execute(array($table, $user)); $row = $stmt->fetch(); //Check echo $row['Username'];
任何帮助,将不胜感激!
I'm learning about PDO and prepared statements and have run into a problem. I keep getting this error:
Fatal error: Uncaught exception 'PDOException' with message '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 ''Users' WHERE Username = 'yayu'' at line 1' in /home/u230594705/public_html/pages/panel.php:33 Stack trace:#0 /home/u230594705/public_html/pages/panel.php(33): PDOStatement->execute(Array) #1 {main} thrown in /home/u230594705/public_html/pages/panel.php on line 33
with this code:
session_start(); $user = $_SESSION["user"]; $table = "Users"; //Establish Connection $dsn = "mysql:host=$dbHost;dbname=$dbName;charset=utf8"; $opt = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ); $pdo = new PDO($dsn,$dbUser,$dbPass, $opt); //Prepare query to execute $stmt = $pdo->prepare("SELECT Username, Password, Email FROM ? WHERE Username = ?"); $stmt->execute(array($table, $user)); $row = $stmt->fetch(); //Check echo $row['Username'];
Any help would be appreciated!
原文:https://stackoverflow.com/questions/18049805
最满意答案
请统计numberOfRecordsOnYourDB并执行以下操作:
set ROWCOUNT (numberOfRecordsOnYourDB - 1000 ) delete from hugetable Go
这将删除表中的记录,但会在指定的行数之后停止处理。
哦,不要忘记将ROWCOUNT设置回大值,或者只是打开一个新的连接来完成其他任务
count the numberOfRecordsOnYourDB and do:
set ROWCOUNT (numberOfRecordsOnYourDB - 1000 ) delete from hugetable Go
This will delete records from your table but stop processing after the specified number of rows.
oh and don't forget to set the ROWCOUNT back to a big value, or just open a new connection to do the other tasks
相关问答
更多-
张家港哪里的计算机培训班专业一点[2022-07-06]
1000 -
讯腾国际天津滨海新区软件人才培训基地学费是多少[2022-01-25]
1000 -
在济宁海天计算机学校学习计算机维修需要多少钱[2022-03-15]
1000 -
广西容县的笔记本计算机最便宜多少?[2023-09-14]
1000 -
有一篇Oracle知识文章, 文档ID 884712.1 这表明您需要编辑instanceconfig.xml并在
标记内添加以下内容。 显然将其设置为您想要的值。 但是,对于基于选择的提示,已经有6,500个值。 It looks like a limitation in the version we are using(11.1.1.6.7). R ...XXXX -
如何删除最老的mysql表记录,但留下最新的1000个(how to delete oldest mysql table records, but leave 1000 newest)[2022-08-17]
delete from your_table where id not in ( select * from ( select id from your_table order by id desc limit 1000 ) x ) inner select返回最近的1000个ID。 另一个delete删除所有记录,但删除内部select 。 delete from your_table where id not in ( select * f ... -
请统计numberOfRecordsOnYourDB并执行以下操作: set ROWCOUNT (numberOfRecordsOnYourDB - 1000 ) delete from hugetable Go 这将删除表中的记录,但会在指定的行数之后停止处理。 哦,不要忘记将ROWCOUNT设置回大值,或者只是打开一个新的连接来完成其他任务 count the numberOfRecordsOnYourDB and do: set ROWCOUNT (numberOfRecordsOnYourDB ...
-
它适用于11.2.0.2: with seq as (select to_char (level) p from dual connect by level <= 10) select old_value, new_value from (select t1.p old_value, t2.p new_value from (select row_number () over (ord ...