Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Location
    UK
    Posts
    151
    Thanks
    9
    Thanked 2 Times in 2 Posts

    MySQLi STMT Multiple Queries

    Hey,
    I'm having a problem with sending more than one MySQLi Query in a function the first query executes successfully:
    PHP Code:
    $stmt mysqli_prepare($link"SELECT userEmail FROM onlinestorage.users WHERE userEmail=? LIMIT 1");
    // Bind Param
    mysqli_stmt_bind_param($stmt"s"$email);
        
    // Execute
    mysqli_stmt_execute($stmt);

    // Store Result
    mysqli_stmt_store_result($stmt);

    // Fetch Result
    $NumRows mysqli_stmt_num_rows($stmt);
    mysqli_stmt_free_result($stmt);
    mysqli_stmt_close($stmt); 
    Then later in the function I have called MySQLi again to do an insert query but it gives errors. Here is the code for the second query:
    PHP Code:
    // Store Information In Database
    $stmt mysqli_prepare($link"INSERT INTO onlinestorage.users(userFullName, userEmail, userMemorableInfo) VALUES(?, ?, ?)");
                
    // Bind Param
    mysqli_stmt_bind_param($stmt"sss"$userFullName$userEmail$userMemInfo);
                
    // Execute
    mysqli_stmt_execute($stmt); 
    And I get the following errors:
    Code:
    Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given.
    
    Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given.
    Any ideas to what the problem may be? Is there anything you have to do after running a MySQLi query?

    Thanks for any help.
    Last edited by tyanque; 04-16-2012 at 08:15 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    False indicates that your statement failed to compile. Make sure you have a space between the VALUES and the (, as well as double checking the field and table names.

  • Users who have thanked Fou-Lu for this post:

    tyanque (04-16-2012)


  •  

    Posting Permissions

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