Jump to content

SQL DB Sending old results


Go to solution Solved by requinix,

Recommended Posts

I am creating a website which uses a mysql database.

Which holds user information and there balance.

 

When a user purchases tokens (via Stripe) They are redirected back to the account management page.

 

I have checked stripe and they have confirmed the payment.

 

I have checked the sql database and the token value has been added.

 

But on the management page the token value is still the same.

 

(cacheing has been disabled.) Here is the code: 

            <?php 
                
                $query = $conn->prepare("SELECT ID, username, fname, lname, email, tokens FROM `users` WHERE ID = ?");
                $query->bind_param("s",$_SESSION['ID']);
                $query->execute();
                $query->bind_result($ID, $username, $firstname, $lastname, $email, $tokens);
                $query->fetch();
                $query->close();
            ?>
            <p class="my-account-p-padded">
    
                <br>
                Username: <?php echo $username; ?><br>
                First Name: <?php echo $firstname; ?><br>
                Last Name: <?php echo $lastname; ?><br>
                Account Tokens: <?php echo $tokens; ?> <a href="javascript:void(0)" onclick="showlightbox();" id="addmoretokensbtn">Add More</a><br>
                <span id="explain" style="display: none;">(Scroll Up to see screen)</span>
                
            </p>

Screenshot of db: 

Attached.

 

Screenshot of Page:

Attached.

post-192156-0-43306200-1505456604_thumb.png

post-192156-0-03514300-1505456659_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/304988-sql-db-sending-old-results/
Share on other sites

  • Solution

Add a little bit to the code:

            <?php 
                
                $query = $conn->prepare("SELECT ID, username, fname, lname, email, tokens, NOW() FROM `users` WHERE ID = ?");
                $query->bind_param("s",$_SESSION['ID']);
                $query->execute();
                $query->bind_result($ID, $username, $firstname, $lastname, $email, $tokens, $now);
                $query->fetch();
                $query->close();
            ?>
            <p class="my-account-p-padded">
    
                <br>
                Username: <?php echo $username; ?><br>
                First Name: <?php echo $firstname; ?><br>
                Last Name: <?php echo $lastname; ?><br>
                Account Tokens: <?php echo $tokens; ?> <a href="javascript:void(0)" onclick="showlightbox();" id="addmoretokensbtn">Add More</a><br>
                PHP Time: <?php echo date("Y-m-d H:i:s"); ?><br>
                DB Time: <?php echo $now; ?><br>
                <span id="explain" style="display: none;">(Scroll Up to see screen)</span>
                
            </p>
Do you see the two times changing?
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.