|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2007-10-29 22:37 UTC] iliaa@php.net
[2007-10-30 09:51 UTC] uw@php.net
[2007-12-08 17:21 UTC] sfox@php.net
[2011-12-27 16:48 UTC] mariuz@php.net
[2018-10-25 16:28 UTC] neelaraghavendra1 at gmail dot com
[2020-03-08 17:24 UTC] vinocuek51 at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 22:00:02 2025 UTC |
Description: ------------ Parameters to bind in a prepared statement cannot contain dashes (-) in the name. It probably assumes that "-value" should be another variable. If this cannot be fixed, then at least update the documentation to make it clear what names can and cannot be used. Using {} around the variable name would be nice too! Reproduce code: --------------- $db = new PDO("mysql:host=localhost;dbname=testing", 'xxxx', 'xxxx'); $stmt = $db->prepare("SELECT id FROM testing WHERE id=:id-value"); $stmt->bindParam(':id-value', $id); $id = 1; $stmt->execute(); var_dump($stmt->fetch()); Expected result: ---------------- array(2) { ["id"]=> string(1) "1" [0]=> string(1) "1" } Actual result: -------------- Warning: PDOStatement::execute() [function.PDOStatement-execute]: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\htdocs\test.php on line 8 bool(false)