Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Script Showing Up Blank in Browser
Old 03-19-2011, 08:41 PM PHP Script Showing Up Blank in Browser
Experienced Talker

Posts: 40
Name: Andrew Benson
Trades: 0
This is part of a billing software i am creating.
This file's permissions are set to 644 and I uploaded it via SCP. I logged in via SSH to make sure the file contents were written correctly. (and they were)

Whenever i try to open the script in my browser it shows up blank. There is no content. My system administrator assures me its nothing on the server and its something with this code. I think he is right because i tried echoing a hello world it shows up correctly. When i move the contents of this file to a new file, it shows up blank still. What is wrong with this script that is causing it to not show up in my browser?

Thanks!
PHP Code:
<?php
 
// Connects to your Database 
 
require("../libraries/db/dbconnect.php");
 
 
//checks cookies to make sure they are logged in 
 
if(isset($_COOKIE['ID_my_site'])) 
 { 
     
$username $_COOKIE['ID_my_site']; 
     
$pass $_COOKIE['Key_my_site']; 
          
$check mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
     while(
$info mysql_fetch_array$check ))      
         { 
 
 
//if the cookie has the wrong password, they are taken to the login page 
         
if ($pass != $info['password']) 
             {             
header("Location: login.php"); 
             } 
 
 
//otherwise they are shown the admin area     

     
else 
             { 
   
// Include Header
  
include("template/header.php");
  
// begin page content
  
?>
<script type="text/javascript">
// RAI Confirm Payments Javascript
// (C) 2010 DJAB Networks

var raicid;
function RAIConfirm(raicid)
    {
    window.location = "confirmpayments_process.php?pid=" + raicid;
    }
    
var raieid;
function RAIEdit(raieid)
    {
    window.location = "confirmpayments_edit.php?pid=" + raieid;
    }
</script>
<?php 
//SQL Query for the first while loop
    
$sql1 mysql_query("SELECT * FROM payroll where confirmed = '0' ORDER BY PID ASC");
//If user has no payrolls    
 
if (mysql_num_rows($sql1) == 0) {
     echo 
"No past payments available";
     include(
"template/footer.php");
     exit;
     }    
// Open our table up
    
echo "<table align=\"center\" width=\"700\">\r\n";

//First while loop
while($row mysql_fetch_array($sql1))
    {
    
//Show who submitted this payroll request
    
$user_Name $row['username'];
    
$name mysql_result(mysql_query("select name from users where username = '$user_Name'"), 0);
    echo 
"<tr><td></td><td><b>Name</b></td><td><b>".$name."</b></td>\r\n";
    echo 
"<td><input type=\"button\" name=\"button-confirm-".$row['PID']."\" value=\"Confirm &raquo;\" onclick=\"RAIConfirm('".$row['PID']."');\" /><br /><input type=\"button\" name=\"button-edit-".$row['PID']."\" value=\"Edit &raquo;\" onclick=\"RAIEdit('".$row['PID']."');\" /></td></tr>";
    echo 
"<tr><td></td><td></td><td></td></tr>";
    
// Configure the columns of the table
    
echo "<tr><td></td><td><strong>Unit</strong></td><td><strong>Rate</strong></td><td><strong>Total</strong></td></tr>\r\n"
    
// Table is opened. Let's bring in our Timestamp:
    // We'll put this on hold for now - echo "<tr><td>Timestamp</td><td>".$row2['timestamp']."</td><td><i>N/A</i></td></tr>";
    // Bring in our variables now    
//SQL Query for the second while loop
    
$sql2 mysql_query("SELECT * FROM vars ORDER BY ID ASC");
    while(
$row2 mysql_fetch_array($sql2))
        {
        
// Determine variables
        
$varName $row2['varName'];
        
$aliasName $row2['varAlias'];
        
$aliasRate $row2['varAlias']."_rate";
        
$varTotal $row[$aliasName] * $row[$aliasRate];
        
$subTotal $row['subTotal'];
        
$total $row['total'];
        
// Parse into table
        
echo "<tr><td>".$varName."</td><td>".$row[$aliasName]."</td><td>$".$row[$aliasRate]."</td><td>$".$varTotal."</td></tr>\r\n";
        }
        
       
// Begin swaps
     
$swaps mysql_result(mysql_query("select amount from swaps where PID = ".$row['PID'].""),0);
     echo 
"<tr></tr><tr><td>Swaps</td><td></td><td></td><td>".$swaps."</td></tr>\r\n"
     
// Begin Reimbursements
     
$remTotal mysql_result(mysql_query("select total from reimbursements where PID = ".$row['PID'].""),0);
     echo 
"<tr></tr><tr><td><b>Reimbursements</b></td><td></td><td></td><td>$" $remTotal "</td></tr>\r\n"
     
$sql3 mysql_query("select * from rems order by ID asc");
     while(
$row3 mysql_fetch_array($sql3))
         {
         
$remName $row3['remName'];
         
$remAlias $row3['remAlias'];
        
$varTotal mysql_result(mysql_query("select ".$remAlias." from reimbursements where PID = '".$row['PID']."'"),0);
        echo 
"<tr><td>".$remName."</td><td></td><td></td><td>$".$varTotal."</td></tr>\r\n";
         } 
     
//Begin Taxes
     
$taxesTotal mysql_result(mysql_query("select total from taxrecords where PID = ".$row['PID'].""),0);
     echo 
"<tr></tr><tr><td><b>Taxes</b></td><td></td><td></td><td>$" $taxesTotal "</td></tr>\r\n"
     
$sql4 mysql_query("select * from taxes order by ID asc");
     while(
$row4 mysql_fetch_array($sql4))
         {
         
$taxName $row4['taxName'];
         
$taxAlias $row4['taxAlias'];
         
$taxNameRate $taxName "_rate";
         
$varTotal mysql_result(mysql_query("select ".$taxAlias." from taxrecords where PID = '".$row['PID']."'"),0);
        
$taxRate mysql_result(mysql_query("select ".$taxNameRate." from taxrecords where PID = ".$row['PID'].""),0); 
        
$taxTotal $taxRate $varTotal;
        echo 
"<tr><td>".$taxName."</td><td>".$varTotal."</td><td>".$taxRate."</td><td>$".$taxTotal."</td></tr>\r\n";
         } 
                   
     }
      echo 
"<tr><td><strong>Sub Total</strong></td><td><strong>$".$subTotal."</strong></td><td></td></tr>";
      
//Taxes will load here
      
echo "<tr><td><strong>Total</strong></td><td><strong>$".$total."</strong></td><td></td></tr>";
      echo 
"<tr><td></td><td></td><td></td></tr>";
      echo 
"<tr><td></td><td></td><td></td></tr>";
      echo 
"<tr><td></td><td></td><td></td></tr>";
      echo 
"<tr><td></td><td></td><td></td></tr>";
    }
// End table
    
echo "</table>\r\n";   
// Footer Template
  //end page content
              
}
         } 
         } 
 else 
 
 
//if the cookie does not exist, they are taken to the login screen 
 
{             
 
header("Location: login.php"); 
 } 
 include(
"template/footer.php");
 
?>

Last edited by djab; 03-19-2011 at 08:42 PM..
djab is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-19-2011, 09:00 PM Re: PHP Script Showing Up Blank in Browser
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Is error reporting enabled? I don't see any errors at first glance, but if there is a fatal error and display errors is off you'll just get a blank page.

You can also check your error log if you have one.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-19-2011, 09:18 PM Re: PHP Script Showing Up Blank in Browser
Experienced Talker

Posts: 40
Name: Andrew Benson
Trades: 0
I checked my error log. Nothing in there.
I enabled error reporting in the php.ini file.
I changed the line from:
Code:
; - display_errors = Off           [Security]
To:
Code:
; - display_errors = On           [Security]
The page still shows up blank. Any ideas?
djab is offline
Reply With Quote
View Public Profile
 
Old 03-19-2011, 09:35 PM Re: PHP Script Showing Up Blank in Browser
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The ";" character indicates a comment. Try:
Code:
display_errors = On
and make sure that the display_errors directive isn't being set anywhere afterward in the file.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-19-2011, 09:41 PM Re: PHP Script Showing Up Blank in Browser
Experienced Talker

Posts: 40
Name: Andrew Benson
Trades: 0
Quote:
Originally Posted by NullPointer View Post
The ";" character indicates a comment. Try:
Code:
display_errors = On
and make sure that the display_errors directive isn't being set anywhere afterward in the file.
Alright, I tried that and the file is still blank. There are no other php.ini files over writing these settings for this directory.
Any ideas?!?!?

Last edited by djab; 03-20-2011 at 10:52 AM..
djab is offline
Reply With Quote
View Public Profile
 
Old 03-20-2011, 02:00 PM Re: PHP Script Showing Up Blank in Browser
Super Spam Talker

Posts: 880
Name: Paul W
Trades: 0
Restructuring your code to flow logically would be a start. You realise the first thing you're doing is connecting to the db regardless of whether you need to - then potetially doing a header call away (and no exit() after it either!). You have a query that doesn't vary inside the main loop for each confirmed PID - why? Should be moved.

What happens in dbconnect.php? Error handling? Error reporting? First thing I'd do is write a two line script - that include followed by an echo to make sure I was connecting. Then, not having access to MySQL at the moment, I'd comment out chunks of code systematically until every chunk had been tested (don't stop when you find one error). That will handle syntax errors. I'd simplify the main body by abstracting some of the HTML generation to small functuions - make it readable (and a vague nod at maintainability).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE

Last edited by PaulW; 03-20-2011 at 02:02 PM..
PaulW is online now
Reply With Quote
View Public Profile
 
Old 03-26-2011, 07:30 PM Re: PHP Script Showing Up Blank in Browser
Average Talker

Posts: 26
Name: Prithwiraj Bose
Location: Kalyani, West Bengal, India
Trades: 0
may be dbconnect.php generates some output (check for whitespaces) and header() call fails.
__________________

Please login or register to view this content. Registration is FREE
in Kolkata
|
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
| Become a
Please login or register to view this content. Registration is FREE
for Free.
techbongo is offline
Reply With Quote
View Public Profile
 
Old 03-27-2011, 08:41 PM Re: PHP Script Showing Up Blank in Browser
Experienced Talker

Posts: 40
Name: Andrew Benson
Trades: 0
I found out I had an extra } inside the code and it works great now.
Thanks!
djab is offline
Reply With Quote
View Public Profile
 
Old 03-27-2011, 08:51 PM Re: PHP Script Showing Up Blank in Browser
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by djab View Post
I found out I had an extra } inside the code and it works great now.
Thanks!
That should have generated a syntax error. Are other errors being displayed?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-27-2011, 08:52 PM Re: PHP Script Showing Up Blank in Browser
Experienced Talker

Posts: 40
Name: Andrew Benson
Trades: 0
Nope. Its all good and working now! Thanks!
djab is offline
Reply With Quote
View Public Profile
 
Old 03-27-2011, 09:20 PM Re: PHP Script Showing Up Blank in Browser
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by djab View Post
Nope. Its all good and working now! Thanks!
What I meant was if there is an error, is it displayed? If errors aren't being displayed even simple problems can take forever to debug, which is what happened here.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to PHP Script Showing Up Blank in Browser
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.05925 seconds with 12 queries