php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29530 mysqli->prepare() Error (00000/1047)
Submitted: 2004-08-05 11:50 UTC Modified: 2004-08-05 12:17 UTC
From: chenxi at shine dot com dot cn Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.0.0 OS: Redhat Linux 9
Private report: No CVE-ID: None
 [2004-08-05 11:50 UTC] chenxi at shine dot com dot cn
Description:
------------
give me following error message:
Warning: mysqli_prepare() [function.mysqli-prepare]: Error (00000/1047): Unknown command in /shine/htdocs/test.php on line 16

Reproduce code:
---------------
$mysqli = new mysqli("localhost", "root", "root", "hotel");
if (mysqli_connect_errno()) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();
}
	
if ($stmt = $mysqli->prepare($link, "SELECT id, name FROM program")) {
   $stmt->execute();

   $stmt->bind_result($col1, $col2);

   while ($stmt->fetch()) {
      printf("%i %s\n", $col1, $col2);
   }

   $stmt->close();
} else {
   print "stmt failed<br/>";
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-05 11:51 UTC] chenxi at shine dot com dot cn
i make a mistake:
$stmt = $mysqli->prepare("SELECT id, name FROM program")
 [2004-08-05 12:17 UTC] georg@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please note the difference between procedural and OO: 
 
$mysql->prepare("SELECT .....") 
this is a method, you don't have to specify an object 
 
mysqli_prepare($mysql, "SELECT ...") 
this is a procedural function, where you have to specify 
the object. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 12:01:33 2024 UTC