Jump to content
Larry Ullman's Book Forums
dmx1

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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...