orre Posted April 25, 2011 Share Posted April 25, 2011 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 <? $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> } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234703-if-statment-and-set-vars/ Share on other sites More sharing options...
Maq Posted April 25, 2011 Share Posted April 25, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/234703-if-statment-and-set-vars/#findComment-1206095 Share on other sites More sharing options...
markjoe Posted April 25, 2011 Share Posted April 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234703-if-statment-and-set-vars/#findComment-1206098 Share on other sites More sharing options...
hyster Posted April 26, 2011 Share Posted April 26, 2011 ur also using short php tags <? ?> use <?php ?> instead. some servers dont support short tags Quote Link to comment https://forums.phpfreaks.com/topic/234703-if-statment-and-set-vars/#findComment-1206284 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.