Sunday, March 4, 2012

PHP script shows up in my display window. Please Help!?

When I type in smaller passages of php script with the opening and ending of %26lt;?php and ending of ?%26gt; it works fine. But when I get in to if statments with many lines of script it doesn't work. Some of the script shows up in my display area instead of just the source code look. Also when I use query urls they don't work. For example, I've used the following code:

%26lt;A HREF="welcome.php?name=Kevin"%26gt; Hi, I'm Kevin! %26lt;/A%26gt;

in my regular html page and I use the following:

%26lt;?php echo( "Welcome to our Web site, $name!" );?%26gt;

for my php page. These are very simple, but I'm just trying to work out the problems with basic scripts. With the name=kevin it should work if I use the $name command. Shouldn't it? Thanks for your time, I appriciate any of the help you could give me.PHP script shows up in my display window. Please Help!?
hmmm sounds like ur not doing something correct on the server or client side,, u should allow scripts to run if u have anything obstructing that php is included, that the options of the browser,, that can be a result of php trying to execute and being hendered by browser security thats to high,, also sounds like if the script teXt is showing in browser u are missing delimeter characters and %26gt;'s somewhere i suggest coding from a php aware editor =) and u should check the web server ur using as well,, u may need to kik the server or check the php.ini file to be sure it is correct,, also check the server configuration that it has proper access to phpPHP script shows up in my display window. Please Help!?
You're probably escaping out of php and into html without realizing it, so the text after you leave php is being rendered as-is. Use something like Edit Plus, so you can see where you are by the color of the text.



As far as $name, that's just a variable you create - it has no inherent value. url?name=Kevin gives the page it's calling a POST variable named 'name' with a value of 'Kevin', but you have to write code to get the value into your variable (test it first - if 'name' isn't set, don't use it). POST and GET variables are in the manual.PHP script shows up in my display window. Please Help!?
Be careful with your quote characters, comments and other punctuation... if they get out of balance, it can throw off the PHP interpreter.



As for the query URLS, the variables sent in a URL will be found in the $_GET array, as in $_GET['name'] . Likewise, if you POST a form, the variables are going to be in $_POST.

No comments:

Post a Comment