php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77373 The "bind_param" is called too early in examples, the variable is undefined
Submitted: 2018-12-30 10:08 UTC Modified: 2018-12-30 10:11 UTC
From: buughost+php at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 7.3.0 OS: WIN10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: buughost+php at gmail dot com
New email:
PHP Version: OS:

 

 [2018-12-30 10:08 UTC] buughost+php at gmail dot com
Description:
------------
---
From manual page: https://php.net/mysqli-stmt.get-result
---

In both examples:

// Not a variable : $continent
$stmt->bind_param("s", $continent);

$continent_array = array('Europe','Africa','Asia','North America');

// Here it is:
foreach($continent_array as $continent)


  $stmt->execute(); // Just executing the same query multiple times
  $result = $stmt->get_result();
  while ($row = $result->fetch_array(MYSQLI_NUM))
  {


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-30 10:11 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-12-30 10:11 UTC] requinix@php.net
No, the code is correct. bind_param takes variables by-reference which means they do not have to exist at the time the method is called. The query will use the values of the variables at the time execute() is called.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 20 18:01:26 2020 UTC