www.webdeveloper.com
Results 1 to 2 of 2

Thread: mysqli binding of values and variables (Zend Cert)

  1. #1
    Join Date
    Apr 2006
    Posts
    246

    Question mysqli binding of values and variables (Zend Cert)

    Hey,

    I have came across this MySQLI question in my zend studies recently, hope someone can help......

    Consider the following code snippet:

    PHP Code:
    <?php
    $query 
    "INSERT INTO mytable 
              (myinteger, mydouble, myblob, myvarchar)
              VALUES (?, ?, ?, ?)"
    ;

    $statement mysqli_prepare($link$query);
        
    if(!
    $statement)
    {
      die(
    mysqli_error($link));
    }
        
    /* The variables being bound to by MySQLi
       don't need to exist prior to binding */
    mysqli_bind_param($statement"idbs",
      
    $myinteger$mydouble$myblob$myvarchar);
        
    /* ???????????? */ 
        
    /* execute the query, using the variables as defined. */
        
    if(!mysqli_execute($statement))
    {
      die(
    mysqli_error($link));
    }

    ?>
    Assuming this snippet is a smaller part of a correctly written script, what actions must occur in place of the ????? in the above code snippet to insert a row with the following values: 10, 20.2, foo, string ?

    The available options are:

    1. A transaction must be begun and the variables must be assigned
    2. Each value must be assigned prior to calling mysqli_bind_param(), and thus nothing should be done
    3. Use mysqli_bind_value() to assign each of the values
    4. Assign $myinteger, $mydouble, $myblob, $myvarchar the proper values

    Many thanks,
    Picco

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    The examples on the manual page look very similar to the question...perhaps you should look there for assistance?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles