FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Blank Web Page shows but works well on Command Prompt.
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Blank Web Page shows but works well on Command Prompt. [message #32719 is a reply to message #24851] Mon, 17 July 2006 18:02 Go to previous message
satovey is currently offline  satovey   United States
Messages: 3
Registered: July 2006
Karma:
Junior Member
nayeem wrote on Tue, 17 May 2005 05:11

I'm new to PHP programming and I just try to display small information from database on web page but its shows blank page. So my code is mention below and let me know what's wrong in it but when I execute same program on command prompt then its shows all result correctly with HTML Tags

<?php

PutEnv("ORACLE_SID=TSH1");
PutEnv("ORACLE_HOME=/u01/app/oracle/product/10.1.0/db_1");
PutEnv("TNS_ADMIN=/var/opt/oracle");

$db_conn = ocilogon("scott", "tiger", "");

$cmdstr = "select ename, sal from emp";
$parsed = ociparse($db_conn, $cmdstr);
ociexecute($parsed);
$nrows = ocifetchstatement($parsed, $results);
echo "Found: $nrows results<br><br>\n";

echo "<table border=1 cellspacing='0' width='50%'>\n";



Improper syntax on table line. It should read:
echo "<table border=1 celspacing=0 width=50%>\n"
or
echo "<table border=1 cellspacing=\"0\" width=\"50%\">\n";

nayeem wrote on Tue, 17 May 2005 05:11


echo "<tr>\n";
echo "<td><b>Name</b></td>\n";
echo "<td><b>Salary</b></td>\n";
echo "</tr>\n";

for ($i = 0; $i < $nrows; $i++ ) {
echo "<tr>\n";
echo "<td>" . $results["ENAME"][$i] . "</td>";



If you still have trouble, seperate the above line into three.

echo "<td>";
echo $results["ENAME"][$i];
echo "</td>";

nayeem wrote on Tue, 17 May 2005 05:11


echo "<td>$ " . number_format($results["SAL"][$i], 2). "</td>";




The above line is another potential killer.
echo "<td>";
echo number_format($results["SAL"][$i],2);
echo "</td>";

nayeem wrote on Tue, 17 May 2005 05:11


echo "</tr>\n";
}

echo "</table>\n";

?>




The reason I seperated the previous two lines is because
I have found that these types of echo commands tend to
cause unresolvable errors that resolve once they are
seperated.

Here is a quick debugging trick I use to find the lines that
are breaking my code.

I put echo "hello"; at the beginning of my script just
after the <?PHP.

Then I comment every thing else out by placing them
between the comment area tags; /* */.

My script then looks like this:

<?php

echo "hello";

/*

My code is in here

*/

?>

When I run the script I see hello at the top of the
web-page.

Then I move the /* tag below each subsequent line of
code. As long as the code is working correctly hello
will appear at the top of the page.

When I move the /* down below a line that breaks the
script (causes it to end prematurely) the page will
come up blank.

Now all I need to do is focus on that particular line
until I get the syntax correct and hello once again
appears at the top of the web page.

I can then test the whole script again by adding the
beginning and end comment out tags to their perspective
lines so that each line has /* and */.

This can be a long and tedious way of finding the broken
code, but it definitely works. You can skip several lines
of code at once making it quicker to find the broken line.
Once you jump below several lines that break your code,
go back up until the page renders again.


Scott
Yevotas® Site
Yevotas.biz
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: A date question
Next Topic: edit proxy number in header information usgin php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 19:29:04 GMT 2024

Total time taken to generate the page: 0.05721 seconds