Saturday, April 25, 2009

PHP syntax shows up blank....why?

I'm new to PHP and MySQL and I'm trying to get a basic test to work. I can see the html but the PHP does not appear. I know how to save it in php format and upload it to my website, but I still get a blank screen when I visit that page. Any suggestions or ideas of what the problem might be? Do I have to put it in a certain spot on my website? I'm using Yahoo as my web host.





syntax:





%26lt;html%26gt;


%26lt;head%26gt;


%26lt;title%26gt;PHP Test%26lt;/title%26gt;


%26lt;/head%26gt;


%26lt;body%26gt;


%26lt;p%26gt;This is an HTML line


%26lt;p%26gt;


%26lt;?php echo "This is a PHP line";


phpinfo();


?%26gt;


%26lt;/body%26gt;


%26lt;/html%26gt;
PHP syntax shows up blank....why?
1. Make sure the webserver supports php


2. Make sure your file extension is php and not html (apache doesn't parse html for php by default)





This shouldn't be an issue with php, for for correctness, you should add end paragraph tags (%26lt;/p%26gt;).





Other than that, it looks all right, so it must be one of the first two suggestions.
PHP syntax shows up blank....why?
Well the first question should be: is php running on the webserver? If php is not running it can not parse your file and generate output.
Reply:Maybe Yahoo does not support php scripting. I put your script on my website and it works fine - see http://ccgi.origamimark.co.uk/test001.ph...
Reply:If that web page doesn't work on your web server and you've made sure it's saved as a .php file, then you most probably don't have PHP running on whatever hosting service you're using.





The simplest way to make sure php works is to make a file like so:





%26lt;?


echo "Hello World";


?%26gt;


And save that as test.php. Then access it through the web and see what happens. I'm not educated in yahoo's web hosting but if you can get to a command prompt, you can also type "php" to see if it's installed.


No comments:

Post a Comment