FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem with mysqli_stmt_bind_param()
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Problem with mysqli_stmt_bind_param() [message #179572] Thu, 08 November 2012 21:38 Go to previous message
rayven is currently offline  rayven
Messages: 3
Registered: November 2012
Karma:
Junior Member
Can anyone help as I am at my wits end.
On my PHP page, the following code works perefectly:

<?php
$connection = new mysqli("localhost", "...", "...", "...");
$sql="SELECT field1, field2 FROM mytable";
if($stmt = mysqli_prepare($connection, $sql))
{
mysqli_stmt_bind_param($stmt, "s", $emailaddress);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $clientid, $siteadmin);
mysqli_stmt_fetch($stmt);
echo($clientid);
echo($siteadmin);
mysqli_stmt_close($stmt);
}
mysqli_close($connection);
?>

But the moment I introduce mysqli_stmt_bind_param() and a parameter on the SELECT statement, I get rows_affected = -1 and no error returned, and no data is returned either. But if I run the same statement with the same parameters (and I have checked the parameter variables are populated correctly) in the mysql administrator, it works!

<?php
$connection = new mysqli("localhost", "...", "...", "...");
$sql="SELECT field1, field2 FROM mytable WHERE field3=?";
if($stmt = mysqli_prepare($connection, $sql))
{
mysqli_stmt_bind_param($stmt, "s", $myparam);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $clientid, $siteadmin);
mysqli_stmt_fetch($stmt);
echo($clientid);
echo($siteadmin);
mysqli_stmt_close($stmt);
}
mysqli_close($connection);
?>

What on earth am I doing wrong?

Thanks in advance.
Any responses posted here, or emailed to me directly will be very much appreciated.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Analista Programador PHP
Next Topic: Using += assignment recursively on an array w/o notice
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 10:00:06 GMT 2024

Total time taken to generate the page: 0.03568 seconds