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
https://forums.phpfreaks.com/topic/234703-if-statment-and-set-vars/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.