Doc #62598 [Opn]: Mistake in user comment

From: Date: Wed, 18 Jul 2012 21:34:35 +0000
Subject: Doc #62598 [Opn]: Mistake in user comment
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8575@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62598&edit=1 ID: 62598 User updated by: the dot music dot of dot the dot ainur at gmail dot com Reported by: the dot music dot of dot the dot ainur at gmail dot com Summary: Mistake in user comment Status: Open Type: Documentation Problem Package: Documentation problem Operating System: N/A PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I reported a bug because, when adding a comment, I get a page whi says this : [...] What not to enter [...] - References to other notes or authors. This is not a forum, so we neither encourage nor permit discussions here. Further, if a note is referenced directly, and that note is later removed or modified, it can cause confusion. - Code collaboration or improvements. This is not to suggest that your code modification is not good, perhaps even great, but this just isn't the place to show it off. We don't even accept all original code submissions. Your best bet is to publish it on your blog or via another medium. [...] Previous Comments: ------------------------------------------------------------------------ [2012-07-18 19:26:57] mail+php at requinix dot net Feel free to post your own comment correcting the mistake :) ------------------------------------------------------------------------ [2012-07-18 12:23:55] the dot music dot of dot the dot ainur at gmail dot com Description: ------------ On this documument page : http://php.net/manual/fr/mysqli-stmt.bind-param.php Last user comment (nick9v at hotmail dot com 30-Jun-2012 10:12) is very useful but contains a little mistake. The function public function add( $type, $value ){ $this->values[] = $value; $this->types .= $type; } Should be public function add( $type, &$value ){ $this->values[] = $value; $this->types .= $type; } Otherwise, this : call_user_func_array( array($stm, 'bind_param'), $bindParam->get()); Will return this : Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given Test script: --------------- // class BindParam copied from user comment $bindParam = new BindParam(); $qArray = array(); $column1NewValue = $_POST['column1']; $column2NewValue = $_POST['column1']; $qArray[] = 'Column1 = ?'; $bindParam->add('i', $column1NewValue ); $qArray[] = 'Column2 = ?'; $bindParam->add('s', $column2NewValue ); $query = 'UPDATE myTable SET '; $query.= implode(' , ', $qArray); $query.= ' WHERE PKeyID= ?'; $bindParam->add('i', $lineToUpdate); $stmt = $mysqli->prepare($query); call_user_func_array(array($stmt, 'bind_param'), $bindParam->get()); $stmt->execute(); $stmt->close(); Expected result: ---------------- Row in database properly updated. Actual result: -------------- ( ! ) Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in c:\path\myfile.php on line 157 Call Stack # Time Memory Function Location 1 0.0010 297832 {main}( ) ..\myfile.php:0 2 0.0059 322952 call_user_func_array ( ) ..\myfile.php:157 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62598&edit=1

« previous php.doc.bugs (#8575) next »