Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page takes forever to load and then displays an empty browser screen 2

Status
Not open for further replies.

DoubleV

Programmer
Jan 11, 2002
358
US
my first attempts in php and here i go:
the url looks like:
http;//and the php code looks like this:
Code:
<?php
 if ($_REQUEST['firstname'] == &quot;Valeria&quot;) {
   echo(&quot;match&quot;)
 }
 else {
  echo(&quot;no match&quot;)
 } 
?> 
when i insert the url into the address bar and press &quot;enter&quot; the ages won't load for a very long time and then a blank screen is displayd (no text at all).
the php is installed and non-conditional statements like
Code:
<?php
 echo(&quot;Welcome to my web site, &quot; . $_GET['firstname'] . &quot; &quot; . $_GET['lastname'] . &quot;!&quot;)
?> 
work fine.
what could be the problem?


--------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
 
First, I recommend using $_GET or $_POST rather than $_REQUEST. Since $_REQUEST contains all of $_GET, $_POST, and $_COOKIE (and $_FILES, if PHP version < 4.3.0), values can overwrite each other, which can poison your inputs.

Second, what version of PHP are you running, on what platform? Is this the entire script, or a snippet? If you view source on the page, do you seen anything? Want the best answers? Ask the best questions: TANSTAAFL!
 
i was using $_GET at first, but then i thought may be i was not retrieving the variable correctly, so i changed it and that's how it gor posted in here.
i'm on free bsd unix running php 4.3 (installed yesterday, so i am very &quot;green&quot; in all of this)
as far as the content of the script goes, that's it. i just started learning, so i am trying to do simple little things to test different things.
i just tried the following with the same result:
Code:
<?php
$firstname = &quot;Valeria&quot;
 if ($firstname == &quot;Valeria&quot;) {
   echo(&quot;match&quot;)
 }
 else {
  echo(&quot;no match&quot;)
 } 
?>
could it be that i did not configure something correctly on the server?
--------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
 
For that second script to work, register_globals must be set to &quot;on&quot;. PHP sets it to &quot;off&quot; by default for very good reasons.

Modify the script so that it reads:
<?php
print '<pre>';
print_r ($_GET);
?>

then point to it in your browser with the URL which includes the &quot;?firstname=blah&quot;

What do you get? Want the best answers? Ask the best questions: TANSTAAFL!
 
i searched through the file and whereever error-reporting is written, the lines are commented out (i.e start with &quot;;&quot;).
what should i set it to be?
and as long as we are talking about php.ini - everything in it is commented out besides the modules i have installed. what else should be uncommented and set? --------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
 
In a development environment, I'd have:

error_reporting = E_ALL & ~E_NOTICE
display_errors = on

Because you could be having errors that are not being reported.

In general I prefer:
register_globals = off (lots of reasons)
short_open_tag = off (forces you to use the most portable tags)

there are some others which you might need, depending on what you want to do.

file_uploads = &quot;on&quot; will permit you to do HTTP file uploads.


Generally, the default php.ini that comes with the installation works for me. Take a look here: to see what you need. Want the best answers? Ask the best questions: TANSTAAFL!
 
Correct me if I'm wrong... but just in case this is a silly thing...

I thought PHP required semi colons once the program got longer than one line... so perhaps if you did actually just cut'n paste those scripts above, it's bombing the parse because of that?

-Rob
 
skiflyer:
True. In fact, I didn't cut-and-paste his code, but typed it in. Your comment made me notice that I did put semicolons at the end of the lines. Removing them generated an error, which he's not seeing.

But that's why I'm recommending that he add the error reporting lines to php.ini. He should either get output or an error.

DoubleV:
One thing I forgot in my recommendation. If you are running PHP as an Apache module, you'll have to shut down and restart httpd for the changes to take effect. Want the best answers? Ask the best questions: TANSTAAFL!
 
you guys both get a star.
and yep - it was the semicolons i was missing. hard to believe it turned out to be so simple, but true.
THANKS! --------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
 
i went into my php.ini file and error_reporting  =  E_ALL & ~E_NOTICE was turned on, but display_errors was off. i turned it on and tested my script without the &quot;;&quot; and got an error message rigth away &quot;Parse error: parse error, expecting `','' or `';'' in /usr/local/etc/httpd/htdocs/phpv/welcome3.php on line 4
&quot; - gee, that helps immensely! --------------------------------------------------
Goals are dreams with deadlines
-------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top