Re: Prepared statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 05, 2006 at 04:03:17AM +0100, Julius Hacker wrote:
> > On 3/4/06, Julius Hacker <julius@xxxxxxxxxxxxxx> wrote:
> >   
> >>>
> >>> Before that foreach, I use mysqli_stmt_init, mysql_stmt_prepare and
> >>> mysql_stmt_bind_param.
> >>> In the foreach-loop I give the variables, which I bound with bind_param,
> >>> their values and want to execute the statement.
> >>>
> >>> But now MySQL returns always an error.
> >>> It seems that the values I gave the variables in the loop aren't used
> >>> because I used bind_param before that.
> >>>
> >>> In the example for mysql_bind_param they do it like me.
> >>> Is the example also wrong or do I have to consider something special?
> >>>
> ...
> >   
> MySQL returns "Column 'auction_house' cannot be null".
> Here're some parts of my code:
> 
> --- code ---
> ...
>
> $insert = $this->sql->stmt_init();
> $insert->prepare("INSERT INTO auctions (auction_house, name, link,
> prize, runtime, bids, picture) VALUES (?, ?, ?, ?, ?, ?, ?)");
> $insert->bind_param("issdsis", $auction_house["id"],
> $auction_parts["name"], $auction_parts["link"], $auction_parts["prize"],
> $auction_parts["runtime"], $auction_parts["bids"],
> $auction_parts["picture"]);
> 
> --- /code ---

I assume your loop is something like:
  while(condition) {
    $auction_parts['id'] = 'some value';
    $auction_parts['name'] = 'some value';
    ...
    $insert->execute();
  }

My first guess would be, if not aleady done, initialize
$auction_parts before you do your bind_param() with something like:

  $auction_parts = array('id' => null, 'name' => null, ...);
  $insert->bind_param("issdsis", $auction_house["id"], ...);


Curt.
-- 
cat .signature: No such file or directory

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux