Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-03 Thread tamouse mailing lists
On Sun, Sep 2, 2012 at 10:24 PM, Ethan Rosenberg, PhD
erosenb...@hygeiabiomedical.com wrote:
 mysqli_stmt_bind_result(): Number of bind variables doesn't match number of
 fields in prepared statement

What exactly is unclear about that?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-03 Thread Jim Giner

On 9/3/2012 2:44 AM, tamouse mailing lists wrote:

On Sun, Sep 2, 2012 at 10:24 PM, Ethan Rosenberg, PhD
erosenb...@hygeiabiomedical.com wrote:

mysqli_stmt_bind_result(): Number of bind variables doesn't match number of
fields in prepared statement


What exactly is unclear about that?

Actually - from looking at the code the OP posted, I don't see the 
mis-match either, assuming that the post contains the actual code.  I do 
have a question tho.  Not being familiar with mysqli yet (soon, I know), 
I'm wondering what his die clause is actually saying when it mentions:

... mysqli_stmt($stmt)

Does the reference to 'mysqli_stmt' mean something special, since it 
doesn't reference any particular function?


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-03 Thread tamouse mailing lists
On Mon, Sep 3, 2012 at 7:45 AM, Jim Giner jim.gi...@albanyhandball.com wrote:
 On 9/3/2012 2:44 AM, tamouse mailing lists wrote:
 On Sun, Sep 2, 2012 at 10:24 PM, Ethan Rosenberg, PhD
 erosenb...@hygeiabiomedical.com wrote:

 mysqli_stmt_bind_result(): Number of bind variables doesn't match number
 of
 fields in prepared statement

 What exactly is unclear about that?

 Actually - from looking at the code the OP posted, I don't see the mis-match
 either, assuming that the post contains the actual code.

That would be a question, considering the OP code was incorrect as it stood.

 I do have a
 question tho.  Not being familiar with mysqli yet (soon, I know), I'm
 wondering what his die clause is actually saying when it mentions:
 ... mysqli_stmt($stmt)

 Does the reference to 'mysqli_stmt' mean something special, since it doesn't
 reference any particular function?

It seems like it should just give a Fatal error for a call to an
undefined function, as mysqli_stmt itself is a class, with no
constructor method of it's own, as it's created via the
mysql_prepare(). I get a little confused when mixing OO and procedural
versions, though, so it might do something...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-02 Thread Jim Giner
So do u have the revised code to show us?


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: Prepared Statements Insert Problem

2012-09-02 Thread tamouse mailing lists
 if($stmt = mysqli_stmt_prepare($stmt, INSERT INTO Intake3 (Site, MedRec, 
 Fname, Lname, Phone, Height, Sex, Hx, Bday, Age) 
 VALUES(?,?,?,?,?,?,?,?,?,?)!=0)

Let me break this into smaller chunks:

if ($a = $b != 0)

Precedence rules show that comparisons (!= in this case) come before
assignment (=).

So, what you're doing is this adding parens:

if ($a = ($b != 0) )

when, in fact, you want this:

if ( ($a = $b) != 0)

which is syntactically equivalent to:

if ( ($a = $b) )

This is the first part of your problem.

The second part, is that you are assigning to $stmt, which is what you
pass in the mysqli_stmt_prepare function, thus, after you've prepared
the statement, you overwrite it with the return value of the function,
which in procedural context, is either TRUE or FALSE, thus destroying
the work you just performed.

What you need here is:

$sql = INSERT INTO Intake3
(Site, MedRec, Fname, Lname,
 Phone, Height, Sex, Hx, Bday, Age)
VALUES (?,?,?,?,?,?,?,?,?,?);
if ( mysqli_stmt_prepare( $stmt,  $sql ) )
{
   // bind and process the stmt
}
else
{
   die('Error occured during statement prepare: ' .
   mysqli_stmt($stmt) );
}

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php