| | |
Display output on webpage
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2005
Posts: 30
Reputation:
Solved Threads: 0
Hello all,
I'm a PHP newbie and have my apache Server and PHP in place. I have been able to run simple programs that work well. However, since then when I do "http ://localhost/filename.php" I either get 2 messages.
1. An error message if there's an error in my code
2. A blank page if I don't get an error message.
For example, the code below gives a blank screen. Pls help me with this.
I'm a PHP newbie and have my apache Server and PHP in place. I have been able to run simple programs that work well. However, since then when I do "http ://localhost/filename.php" I either get 2 messages.
1. An error message if there's an error in my code
2. A blank page if I don't get an error message.
For example, the code below gives a blank screen. Pls help me with this.
PHP Syntax (Toggle Plain Text)
<?php $pictures = array('PixsIMG_0037.jpg','PixsIMG_0038.jpg','PixsIMG_0039.jpg ','PixsIMG_0040.jpg'); shuffle($pictures); ?> <html> <head> <title>Doe Cafe</title> </head> <body> <center> <h1>Doe Cafe</h1> <table width = '100%' > <tr> <?php for( $i = 0; $i < 3; $i++) { echo '<td align="center"><img src =" '; // echo $pictures[$i]; echo $i; echo ' "width ="100" height ="100"></td>; } <? </tr> </table> </center> </body> </html>
There is many errors in your PHP statement thats in the body of your page which I will explain below. Try somthing like this:
Your errors were here:
- Your if statment will only display 3 photos while there is 4 in your array. You can either change the number to test for to 4, or change your tester to less than or equal to .... <=.
- You commented out the part that places the picture filename into the image tag. (the // makes PHP ignore it.)
-You put the value of $i in the src part of your image tag.
- You did not close the third echo after the </td> tag
- Your PHP closing tag is backwards. Should be ?>
php Syntax (Toggle Plain Text)
<?php for( $i = 0; $i < 4; $i++) { echo "<td align='center'><img src='" . $pictures[$i] . "' width='100' height='100' alt='" . $i . "'></td>"; } ?>
Your errors were here:
- Your if statment will only display 3 photos while there is 4 in your array. You can either change the number to test for to 4, or change your tester to less than or equal to .... <=.
- You commented out the part that places the picture filename into the image tag. (the // makes PHP ignore it.)
-You put the value of $i in the src part of your image tag.
- You did not close the third echo after the </td> tag
- Your PHP closing tag is backwards. Should be ?>
Last edited by GliderPilot; Feb 19th, 2007 at 5:10 pm.
•
•
Join Date: Mar 2005
Posts: 30
Reputation:
Solved Threads: 0
•
•
•
•
There is many errors in your PHP statement thats in the body of your page which I will explain below. Try somthing like this:
php Syntax (Toggle Plain Text)
<?php for( $i = 0; $i < 4; $i++) { echo "<td align='center'><img src='" . $pictures[$i] . "' width='100' height='100' alt='" . $i . "'></td>"; } ?>
Your errors were here:
- Your if statment will only display 3 photos while there is 4 in your array. You can either change the number to test for to 4, or change your tester to less than or equal to .... <=.
- You commented out the part that places the picture filename into the image tag. (the // makes PHP ignore it.)
-You put the value of $i in the src part of your image tag.
- You did not close the third echo after the </td> tag
- Your PHP closing tag is backwards. Should be ?>
How do I see what errors I have with my PHP codes?(I mean is there like something similar to a debug window where errors and / or lines where they are will be displayed for my PHP codes)
Thanks
•
•
•
•
First I want to thank you for pointing out my errors, but I also have a question for you.
How do I see what errors I have with my PHP codes?(I mean is there like something similar to a debug window where errors and / or lines where they are will be displayed for my PHP codes)
Thanks
If you want to see errors, you have to modify your php.ini file to show the errors along with the code on the page, or, you can review the apache error log - it contains all errors occured in the PHP code.
Note errors are similar to this :
Error: Unexpected T_VARIABLE , expecting ',' or ';' on line 65 in "C:\php\my_php_file.php"
![]() |
Similar Threads
- can't display the output! can somebody help me?!! PLS.. (C)
- Program Output Display Tweak Help (Java)
- Am not able to get a radio button selection to display in output (PHP)
- Time display program (C++)
Other Threads in the PHP Forum
- Previous Thread: PHP for application/software development
- Next Thread: My script needs help-Calculate a Paycheck
| Thread Tools | Search this Thread |
.htaccess ajax alerts apache api array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database date directory display dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google hack href htaccess html htmlspecialchars image include insert integration ip java javascript joomla keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql network object oop paypal pdf php problem query radio random recursion redirect regex remote replace script search securephp server sessions sms soap source space sql syntax system table tutorial update upload url validation validator variable video web xml youtube





