Jump to content
Larry Ullman's Book Forums

mysqli_query not updating database


Recommended Posts

Hi Larry,

I wrote the following code:

                 $r = mysqli_query($dbc, "CALL get_users_info_from_carts('$uid')");
                
                
               
                 if (mysqli_num_rows($r) > 0) {
                    
                   while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
                      if ($row['users_id'] == '0')
                       
                       {
                        $usr_id = $_SESSION['user_id'];

                        mysqli_query($dbc, "CALL add_user_to_cart('$uid', $usr_id, '$e')");
                              
                       }
    
                   }
                }

 

The CALL add_user_to_cart('$uid', $usr_id, '$e') function is suppose to update the carts table, but for some reason, no update is happening.

I ran the scripts directly through phpmyadmin and they are executing fine, but for some reason, the code above is not generating an update.

mysqli_query() is not executing the stored procedure.

Is there anyting that you see  that may be a problem?

Can you help please.

Thanks

Link to comment
Share on other sites

There's nothing obvious in the code that's wrong. You'll need to do some debugging here. Start by verifying that the stored procedure is being called. Then verify the values of the variables. Run the stored procedure using phpMyAdmin (or the mysql client) using those same variable values, etc. In short, you'll need to use lots of print statements, trial and error, here!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...