note 116901 added to pdostatement.execute

From: Date: Tue, 17 Mar 2015 15:15:54 +0000
Subject: note 116901 added to pdostatement.execute
Groups: php.notes 
Request: Send a blank email to php-notes+get-201972@lists.php.net to get a copy of this message
Rami's code snippet is a very good solution for using an associated array to insert a line. However, there's a small, but hard to spot, syntax error which may take a few moments to figure out what's gone wrong. So I thought I should provide the corrected line: Instead of: $placeholder = substr(str_repeat('?,',count($keys),0,-1)); The correct code you'll want to use is: $placeholder = substr(str_repeat('?,',count($keys)),0,-1); (Notice that substr has 3 parameters, and str_repeat has 2). ---- Server IP: 72.52.91.14 Probable Submitter: 46.233.116.167 ---- Manual Page -- http://php.net/manual/en/pdostatement.execute.php Edit -- https://master.php.net/note/edit/116901 Del: integrated -- https://master.php.net/note/delete/116901/integrated Del: useless -- https://master.php.net/note/delete/116901/useless Del: bad code -- https://master.php.net/note/delete/116901/bad+code Del: spam -- https://master.php.net/note/delete/116901/spam Del: non-english -- https://master.php.net/note/delete/116901/non-english Del: in docs -- https://master.php.net/note/delete/116901/in+docs Del: other reasons-- https://master.php.net/note/delete/116901 Reject -- https://master.php.net/note/reject/116901 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201972) next »