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
Switch to threaded view of this topic Create a new topic Submit Reply
Blank Web Page shows but works well on Command Prompt. [message #24851] Tue, 17 May 2005 09:11 Go to next message
nayeem is currently offline  nayeem   Saudi Arabia
Messages: 1
Registered: May 2005
Location: Riaydh
Karma: 0
Junior Member

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";
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>";
echo "<td>$ " . number_format($results["SAL"][$i], 2). "</td>";
echo "</tr>\n";
}

echo "</table>\n";

?>


Re: Blank Web Page shows but works well on Command Prompt. [message #31407 is a reply to message #24851] Fri, 21 April 2006 09:10 Go to previous messageGo to next message
richardlynch is currently offline  richardlynch   United States
Messages: 8
Registered: April 2006
Karma: 0
Junior Member
Things to try:

#1. Use "View Source" in your browser to see if there are error messages being "hidden" by partial HTML tags.

#2. Take the command line output, and view it in a browser as static text.

#3. Check your Apache error logs (or whatever webserver). It's possible that there is an error message in there.

#4. I think there are cases when PutEnv is disabled by security-concious folks and that those might be your problem. While you "need" them to make Oracle work, try taking them out to get SOME output and add them back in after that. You may need to contact your webhost to resolve this one.

#5. Try a much simpler page like:
<?php phpinfo();?>
and surf to that.
If *that* doesn't work, you know you have a problem that PHP isn't even being run.

Hope that helps point you in a right direction.
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: 0
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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 11:48:40 GMT 2024

Total time taken to generate the page: 0.02331 seconds