Jump to content


Photo

[SOLVED] Browser not recognising Php


  • This topic is locked This topic is locked
5 replies to this topic

#1 Nooble

Nooble

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 16 June 2009 - 07:05 AM

Can somebody help me out with getting started?

Php doesn't work for me, I've tried a simple HelloWorld.php script and I'm just getting a blank page in my browser.
The file is saved in the correct directory (file:///C:/xampp/htdocs/mystuffchris/helloWorld.php) as far as I know.
The code used is...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   <title>Hello World</title>
</head>

<body>
    <p><?php echo "Hello World"; ?></p>
</body>

</hmtl>


I've also tried using Php with a Html form with action="borderMaker.php". Here's borderMaker.php sourcecode...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Your Output</title>
</head>
<body>
<h1>Your Output</h1>
<div style = "text-align: center">
<?php 

//retrieve all the variables
$basicText = filter_input(INPUT_POST, "basicText");
$borderSize = filter_input(INPUT_POST, "borderSize");
$sizeType = filter_input(INPUT_POST, "sizeType");
$borderStyle = filter_input(INPUT_POST, "borderStyle");


$theStyle = <<<HERE
"border-width:$borderSize$sizeType;
border-style:$borderStyle;
border-color:green"
HERE;

print "<div style = $theStyle>";
print $basicText;
print "</div>";

?>
</div>

</body>
</html>

When I use the Html form and click the Submit button I just get text in the browser like this...

YOUR OUTPUT

";print $basicText;print "
"; ?>

The files are saved with the correct extensions. I have tried using Firefox and Internet Explorer, tried both Xampp and Wampserver, my browser just won't recognise the Php.

I know this is a log post for what I suspect is a real Noob problem but I'd be really greatful of any advice, thanks.

EDITED BY akitchin: please use code tags in future postings.

#2 PFMaBiSmAd

PFMaBiSmAd

    Advanced Member

  • Staff Alumni
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 16 June 2009 - 10:29 AM

my browser just won't recognize the Php

That is because browsers don't have anything to do with php. Php is a server-side scripting language and it is executed on the web server when the page is requested.

What is the URL that you are using in your browser?
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#3 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 16 June 2009 - 02:02 PM

As you have XAMPP installed you need to be going to http://localhost to run your PHP scripts. Loading your PHP scripts directly into the web browser will not work.

#4 Nooble

Nooble

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 17 June 2009 - 09:35 AM

Yes I have been told that I have to use my server to load the page, before I was loading the page by simply using windows explorer and navigating to the xampp htdocs folder (C:\xampp\htdocs\mystuffchris\helloWorld.php) and double-clicking the file.

But I have also tried typing "http://localhost/helloWorld.php" in the address bar, also have tried "http://localhost/xam...elloWorld.php".
Although the result is...
----------------------------------------------------------------------------
Object not found!

The requested URL was found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.

Error 404
  localhost
06/17/09 15:04:15
    Apache/2.2.9 (win32)/DAV/2 mod_ssl/2.2.9 OpenSSL/0.9.8h mod_autoindex_color PHP
/5.2.6
----------------------------------------------------------------------------------

Am I using the URL address bar correctly? XAMPP is running, could I have it configured incorrectly?

Thanks for the help.

#5 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 17 June 2009 - 12:58 PM

Looking at your url you need to be going to

http://localhost/mys.../helloWorld.php

#6 Nooble

Nooble

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 18 June 2009 - 09:21 AM

Yes, "http://localhost/mys...helloworld.php" solved it...

Thanks very much! Well Chuffed now! 8)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com