|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-05-23 20:04 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Description: ------------ This problem occurs at different times on different OS's/versions. MySQL version is 5.0.21-Debian_3-log On Ubuntu Linux (Apache2): PHP: 5.1.2 PDO: 1.0.3 PDO_MYSQL: 1.0.2 On Windows XP (cli): PHP: 5.1.4 PDO: 1.0.3 PDO_MYSQL: 1.0.2 Reproduce code: --------------- <?php $pdo = new PDO('mysql:host=HOST;dbname=DBNAME', 'USERNAME', 'PASSWORD'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $statement = $pdo->prepare("SELECT * FROM ?"); $statement->execute(array ('agent')); ?> Expected result: ---------------- [Successful execution] Actual result: -------------- On Ubuntu 5.1.2, this fails at prepare(): 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 '?' at line 1' in /www/data/realestate/site/test.php:10 Stack trace: #0 /www/data/realestate/site/test.php(10): PDO->prepare('SELECT * FROM ?') #1 {main} thrown in /www/data/realestate/site/test.php on line 10 On Windows 5.1.4, this fails at execute (): PHP 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 ''agent'' at line 1' in C:\pdo.php:12 Stack trace: #0 C:\pdo.php(12): PDOStatement->execute(Array) #1 {main} thrown in C:\pdo.php on line 12