Google Groups Home
Help | Sign in
Prepared statements not working, any suggestions?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
miken32@gmail.com  
View profile
 More options Jan 27 2006, 1:28 pm
From: "mike...@gmail.com" <mike...@gmail.com>
Date: Fri, 27 Jan 2006 10:28:45 -0800
Local: Fri, Jan 27 2006 1:28 pm
Subject: Prepared statements not working, any suggestions?
I can't get prepared statements to work in PHP 5.12 using their example
script and the 'world' database.  I've tried using prepared statements
directly from the mysql client, and it works fine.  Other functions
from ext/mysqli work fine as well.  But when I run the following code,
I only get "Amersfoort is in district "

<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
   printf("Connect failed: %s\n", mysqli_connect_error());
   exit();

}

$city = "Amersfoort";

$stmt =  $mysqli->stmt_init();
if ($stmt->prepare("SELECT District FROM City WHERE Name=?")) {
   $stmt->bind_param("s", $city);
   $stmt->execute();
   $stmt->bind_result($district);
   $stmt->fetch();
   printf("%s is in district %s\n", $city, $district);
   $stmt->close();

}

$mysqli->close();
?>

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Jawed  
View profile
 More options Jan 28 2006, 6:55 pm
From: John Jawed <johnja...@gmail.com>
Date: Sat, 28 Jan 2006 15:55:19 -0800
Local: Sat, Jan 28 2006 6:55 pm
Subject: Re: [MySQLi-g] Prepared statements not working, any suggestions?

What is the value of District in the table?

Also, see what var_dump($stmt->fetch()); returns.

Regards,
John

On 1/27/06, mike...@gmail.com <mike...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
miken32@gmail.com  
View profile
(1 user)  More options Feb 12 2006, 1:04 am
From: "mike...@gmail.com" <mike...@gmail.com>
Date: Sat, 11 Feb 2006 22:04:54 -0800
Local: Sun, Feb 12 2006 1:04 am
Subject: Re: Prepared statements not working, any suggestions?
The value is some string, Maastricht maybe?  var_dump is showing NULL,
and $mysqli->error is empty as well.  It's nothing to do with the
database, I had the same problems on my own code.  I just set up an
exact duplicate of the PHP example code to confirm that is is a
problem.  If it's relevant, I'm running PHP 5.12 and MySQL 5.0.18 on
Windows.  All other mysqli functions are working fine.  Thanks for any
suggestions!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
miken32@gmail.com  
View profile
 More options Feb 12 2006, 1:13 am
From: "mike...@gmail.com" <mike...@gmail.com>
Date: Sat, 11 Feb 2006 22:13:42 -0800
Local: Sun, Feb 12 2006 1:13 am
Subject: Re: Prepared statements not working, any suggestions?
My mistake, there is an error, but only after bind_result is called:
"Using unsupported buffer type: 254  (parameter: 1)"

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Jawed  
View profile
 More options Feb 12 2006, 2:25 am
From: John Jawed <johnja...@gmail.com>
Date: Sat, 11 Feb 2006 23:25:28 -0800
Local: Sun, Feb 12 2006 2:25 am
Subject: Re: [MySQLi-g] Re: Prepared statements not working, any suggestions?

Could you paste the code as you have it? Including where you bind it.

On 2/11/06, mike...@gmail.com <mike...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
miken32@gmail.com  
View profile
 More options Feb 13 2006, 1:55 pm
From: "mike...@gmail.com" <mike...@gmail.com>
Date: Mon, 13 Feb 2006 10:55:40 -0800
Local: Mon, Feb 13 2006 1:55 pm
Subject: Re: Prepared statements not working, any suggestions?

John Jawed wrote:
> Could you paste the code as you have it? Including where you bind it.

> On 2/11/06, mike...@gmail.com <mike...@gmail.com> wrote:

> > My mistake, there is an error, but only after bind_result is called:
> > "Using unsupported buffer type: 254  (parameter: 1)"

The code was actually in my first post, but I've got it figured out
anyway.

I installed the client library from MySQL and it fixed the problem.  So
much for PHP's big noise about keeping mysqli up to date with MySQL!
Strangely enough, phpinfo() claimed my client library version was
5.0.18 beforehand, but the new version seems to have fixed some
problem.

So next time somebody running Windows shows up here with a problem,
send them to http://dev.mysql.com/downloads/connector/php/ first to
make sure they have the latest client library.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Jawed  
View profile
 More options Feb 13 2006, 1:59 pm
From: John Jawed <johnja...@gmail.com>
Date: Mon, 13 Feb 2006 10:59:27 -0800
Local: Mon, Feb 13 2006 1:59 pm
Subject: Re: [MySQLi-g] Re: Prepared statements not working, any suggestions?

Good information, will have to keep that in mind. What OS are you using by
the way?

On 2/13/06, mike...@gmail.com <mike...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Jawed  
View profile
 More options Feb 13 2006, 2:00 pm
From: John Jawed <johnja...@gmail.com>
Date: Mon, 13 Feb 2006 11:00:48 -0800
Local: Mon, Feb 13 2006 2:00 pm
Subject: Re: [MySQLi-g] Re: Prepared statements not working, any suggestions?

Nevermind, you said you were running Windows before. Are you sure it doesn't
ship the binaries with that same library?

On 2/13/06, John Jawed <johnja...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google