Blank result of a php page - help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Saqib
Forum Newbie
Posts: 3
Joined: Thu May 22, 2003 5:08 am

Blank result of a php page - help!

Post by Saqib »

Hi
Apache, PHP, and mysql working together nicely. All php pages being parsed, except one!! All i get is a blank output. The source view from the browser gives:

</body></html>

Here's what i get from the command prompt:

# php register.php3
X-Powered-By: PHP/4.1.2
Content-type: text/html


</body></html>

And thats it. No errors, no nothing.
Anybody knows whats going on here??

Your help would be appreciated
thanx

-Saqib
lcidw
Forum Commoner
Posts: 58
Joined: Mon Apr 28, 2003 8:55 am
Location: Netherlands

Post by lcidw »

What's the code?

It could be a simple error in your code, like a character where it doesn't belong, a ; or } missing, or just a spelling fault.

If you use a database connection or query which fails, and you php.ini is set to no errors screen output, it could be blank too.
Saqib
Forum Newbie
Posts: 3
Joined: Thu May 22, 2003 5:08 am

Post by Saqib »

Ive checked the php.ini, the error reporting is set to ALL_ERRORS (or something like that) The ini seems fine. If I deliberately add a ; or a { etc, it does generate errors.
I am using db connectivity here.
Here's the code :D

Thanx for the help..
----------------------------------------------------------

Code: Select all

<?php

function intrTab(){

  topTab("Welcome to XtremWeb.",400) ?>

 This page will help you to get an account on the Xtremweb server.<br> 
    Once, this few questions answered, you will be able to download
    and run the XtremWeb softwares.<br>
 This will also permit you to access the online statistics of your
 machine. And as many project of this kind you may organise yourself
 and your friends as team.

<?php
    bottomTab();
}

function validTab( $l,$p,$e,$f,$n,$t,$c,$cfgBase )
{ 
     // echo "l:" . $l ." p: " . $p . " e: " . $e . "<br>\n";
   if ((!$l)||(!$p)||(!$e)) {
    headerRegister(1);
    topTab("Bad Filling.",400) ;
    
?>

 <CENTER><h2><font color=red><bf>ERROR</bf></font></h2></CENTER>
 You must fill the following fields to get an account on XtremWeb ! <br>

   <ul>
<?php 
    if (!$l)
      echo "<li><font color=red><bf>Login</bf></font><br></li>";
    if (!$p)
      echo "<li><font color=red><bf>Password</bf></font><br></li>";
    if (!$e)
      echo "<li><font color=red><bf>Email</bf></font><br></li>";
?>
	</ul>

	    Please, update the next part and repost your form. 
<?php

	    bottomTab();
    return 0;
  } else {
    $sql = "SELECT code FROM users WHERE login = '". $l ."'";
    $resultat = mysql_db_query($cfgBase, $sql); 
    $nb_enr = mysql_num_rows($resultat);
    
    if ($nb_enr>0) {
      headerRegister(1);
      topTab("Bad Filling.",400) ;
      
	echo "<CENTER><h2><font color=red><bf>ERROR</bf></font></h2></CENTER>";
	echo "Sorry, but user <font color=red>". $l ."</font> has already registred to XtremWeb.<br> Please choose a different login.\n";
	bottomTab();
	return 0;
      } else {
	$sql = "INSERT INTO users VALUES ( '" . $l ."', '". codePassword ($p) . "', '" . $e . "', '" . $f ."', '" . $n ."', '" . $t ."', '" . $c ."', NULL)";

	$resultat = mysql_db_query($cfgBase, $sql); 
	return makeSession($l);
	  }
    }
}

function confirmRegister($l,$s) {
  headerRegister(0);
  topTab("Operation successfull.",400) ;

  echo " You have been successfully registred to XtremWeb with
  login <font color=red>". $l ."</font>.<br>No go to the download page.\n ";?>
    <FORM method="Get" action="download.php3">
       <TABLE border="0">
       
       <INPUT  TYPE=HIDDEN  NAME=login  VALUE=<?php echo $l; ?>>
       <INPUT  TYPE=HIDDEN  NAME=session  VALUE=<?php echo $s; ?>>
	  <TR><TD><INPUT type="submit" value="Continue"></TD></TR>
	     </TABLE></FORM>
	     <?php
	     bottomTab();	     
}


function surveyTab(  $l,$p,$e,$f,$n,$t,$c ){

  topTab("Identity. Field in red are Required.",400);
    ?>


Please fill this little survey .</TR></TD>

<tr><td ALIGN = 'CENTER'>

<TABLE ALIGN="TOP">

<form method="POST" action="register.php3" >

<TR><TD CLASS='required' >&nbsp;Login&nbsp;</TD><TD  ALIGN='LEFT'>
					       <input
					  type=text  name=login 
					  <?php if ($l)  echo " value=".$l; ?>
					  size=+15></TD></TR>   

<TR><TD CLASS='required'>&nbsp;Password&nbsp;</TD><TD
					  ALIGN='LEFT'>
						 <input
					  type=password
					  name=password  
					  <?php if ($p)  echo " value=".$p; ?>
						 size=+15></TD></TR>

 <TR><TD CLASS='required' >&nbsp;Email&nbsp;</TD><TD ALIGN='LEFT'>
						<input type=text
						name=email
					  <?php if ($e)  echo " value=".$e; ?> 
						size=+15></TD></TR>

<TR><TD>&nbsp;</TD></TR>

 <TR><TD>&nbsp;First Name&nbsp;</TD><TD ALIGN='LEFT'>
				   <input type=text name=fname 
				   <?php if ($f)  echo " value=".$f; ?> 
				   size=+15></TD></TR>

 <TR><TD>&nbsp;Last Name&nbsp;</TD><TD ALIGN='LEFT'>
				  <input type=text name=lname 
				  <?php if ($n)  echo " value=".$n; ?> 
				  size=+15></TD></TR>

<TR><TD>&nbsp;</TD></TR>
<TR><TD>&nbsp;Team&nbsp;</TD><TD ALIGN='LEFT'>
			     <input type=text name=team 
			     <?php if ($t)  echo " value=".$t; ?> 
			     size=+15></TD></TR>

 <TR><TD>&nbsp;Country&nbsp;</TD><TD ALIGN='LEFT'>
				<input type=text name=country 
				<?php if ($c)  echo " value=".$c; ?> 
				size=+15></TD></TR>

 <TR><TD ALIGN='CENTER' COLSPAN=2><input type=submit value="submit"></TD></TR>

</TD></TR></TABLE>
</form>
</CENTER>

   <?php   bottomTab();
}
 ?>




<?php
//-------------------------------------------
require("./XWlib.php3");
require("./header.php3");
require("./config.php3");

$connecte = @mysql_connect($cfgHote, $cfgUser, $cfgPass);
  
if ($connecte) {
  //  intrTab();

  if (($login || $password || $email)) {
    $session =
       validTab($login,$password,$email,$fname,$lname,$team,$country,$cfgBase);
    if ($session)
      confirmRegister($login,$session);
    else
      surveyTab($login,$password,$email,$fname,$lname,$team,$country);
  } else {
    headerRegister(0);
    intrTab();
    surveyTab($login,$password,$email,$fname,$lname,$team,$country);
  }
  

 } 
//fin if 

print_footer();
?>
mod_edit: added php tags
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

maybe the mysql connection has been refused?

Code: Select all

if ($connecte) {
...
} 
else
	die(mysql_error());
lcidw
Forum Commoner
Posts: 58
Joined: Mon Apr 28, 2003 8:55 am
Location: Netherlands

Post by lcidw »

thanks for the mod edit :)

Why not put a

Code: Select all

or die();
behind the

Code: Select all

mysql_db_query($cfgBase, $sql);
and

Code: Select all

$nb_enr = mysql_num_rows($resultat);
and on other places an echo "IntrTab works"; etcetera throughout the script to see what works does and what not..

I'd like to advise you to use " " using input tags, to be sure it goes right..

Code: Select all

<input type=text name=team .. to <input type="text" name="team"
Sorry i just don't understand this pile of code. People should comment a lot more :? I wonder if you'd still understand your own code in 2 years. Could be me though, i have a problem with reading large texts.
Saqib
Forum Newbie
Posts: 3
Joined: Thu May 22, 2003 5:08 am

Post by Saqib »

Thanx a lot people. Problem was here:

$connecte = @mysql_connect($cfgHote, $cfgUser, $cfgPass);

Did a little debugging and voila. Just removed the @. Dunno why it was there. I'm new to PHP, and this isnt my code btw. Could definitely use some commenting :)
Thanx again
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

Te @ is there to tell php not to use its preset error logging so that you can build custom error logs, i am not sure why removing it fixed it tho.
Post Reply