Jump to content

If statment and set vars


orre

Recommended Posts

I am inplanting a bonus system to a game i have.

I want to say at first that i am not good at php am reading alot and go by learn by doing.

But after a few hours i kinda gave up.

 

Here is the code.

 

The page end up blank.

And i tested so my syntax work $cost and $points with only the db stuff and this code

<div class="yellow_12_bold"><? print (number_format($points)); ?> </div>

<div class="yellow_12_bold"><? print (number_format($cost)); ?> </div>

And it does.

 

 

Anyway here is the code  :confused:


<?


$dbq = $db->execute("select * from Bonus where username='$username'");
$points = $dbq->fields['points'];
$allpoints = $dbq->fields['points_total'];

$dbq->close();






if ($cost == "5" && $amount == "3000") {


     if ($points == "5" || $points > "5") {

        $sqlb = "update UserData set turns=turns+'3000' WHERE turns < 50000 and location != '9' and frozen = '0'";
        $result1 = mysql_query($sqlb);

        $sqlc = "update Bonus set points=points-'5' WHERE username = '$username';
        $result2 = mysql_query($sqlb);


        $points2 = ($points - 5);

           <p align="center" class="black">Thank you! 3000 turns have been added to everyone.
           You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left. </p>
}
            else {  <p align="center" class="black">Sorry you dont have $cost points. You have <div class="yellow_12_bold"><? print (number_format($points)); ?> </div> bonus points left.</p>
}



} ?>


Link to comment
Share on other sites

If the page is completely blank, there is probably a fatal error in your code.  Put the following lines directly below your opening<?php tag (which you shouldn't be using short tags).

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Link to comment
Share on other sites

To start off, you have html code in your php tags. If you really want to interlace html and php together, you need to close and reopen the php tags around the html.

also, are we to assume $db is a database object that has already been instantiated and connected to the database?

Any time you get the blank page ("white screen of death" as some people like to call it) always check your php error logs first.

Link to comment
Share on other sites

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.