0

Hai frnds,
Ahh...:?: I started learning PHP by my self frm somr Online tuts,And tried my first
script.yes here it is

<html>
<Head>
My first PHP By my own
</head>
<body>
<?php
echo "My first program and its a failure"
?>
</BODY>
</html>

But,The problem is..:confused: that iam not getting desired output
My compiler is spitting at me
THIS
hsetaknev@hsetaknev-desktop:~$ php as.php
<html>
<Head>
My first PHP By my own
</head>
<body>
My first program and its a failure</BODY>
</html>
hsetaknev@hsetaknev-desktop:~$

Please Help me

10
Contributors
21
Replies
23
Views
6 Years
Discussion Span
Last Post by hsetaknev
Featured Replies
  • 3

    Try this: [code] <html> <head> <title>My first PHP By my own</title> </head> <body> <?php echo "My first program and its a failure"; ?> </body> </html> [/code] You should not have the plain text directly between the head tags. You can do in body tags. Also, you must write semi-colon ';' … Read More

0

What is your "desired output"? Because this output looks fine to me

3

Try this:

<html>
<head>
<title>My first PHP By my own</title>
</head>
<body>
<?php
echo "My first program and its a failure";
?>
</body>
</html>

You should not have the plain text directly between the head tags. You can do in body tags. Also, you must write semi-colon ';' at the end of every PHP statements.

Votes + Comments
useful
0

Zero13 is correct. Also don't forget to save the file with a ,php extention, also save it in htdocs folder if your are using APACHE.

0

What is your "desired output"? Because this output looks fine to me

wont i get an out put like a homepage of website

0

Zero13 is correct. Also don't forget to save the file with a ,php extention, also save it in htdocs folder if your are using APACHE.

what is ZERO13

0

Try this:

<html>
<head>
<title>My first PHP By my own</title>
</head>
<body>
<?php
echo "My first program and its a failure";
?>
</body>
</html>

You should not have the plain text directly between the head tags. You can do in body tags. Also, you must write semi-colon ';' at the end of every PHP statements.

@zero13 i tried what u told still i got this as output

venkatesh@venkatesh-desktop:~$ php asp.php
<html>
<head>
<title>My first PHP By my own</title>
</head>
<body>
My first program and its a failure</body>
</html>venkatesh@venkatesh-desktop:~$

0

what is ZERO13

sorry @zero13 i only later noted u r screen name

0

Are you sure you've already downloaded PHP and it is properly setup on your machine ? What server are you using ? Microsoft IIS or any third-party ? I suggest to use WAMPP or XAMPP if you're windows user, you can also use MAMPP on Mac. So, check the above question. You must install and configure PHP engine on your machine first. You can download PHP manually here. Download XAMPP here.

0

Are you sure you've already downloaded PHP and it is properly setup on your machine ? What server are you using ? Microsoft IIS or any third-party ? I suggest to use WAMPP or XAMPP if you're windows user, you can also use MAMPP on Mac. So, check the above question. You must install and configure PHP engine on your machine first. You can download PHP manually here. Download XAMPP here.

]@Zero13 am using Ubuntu 10.10
I used sudo apt-get install php-**
in my terminal so i am very sure that ive installed it

0

Exactly, you need to install apache2, php for apache and mysql for apache. Use the packet installer (don't remember what is called in ubuntu)

Anyway, you've installed php correctly. The output you get from the terminal is correct.

php parses the code, then outputs HTML code. So the result you're getting is correct and will be interpreted by a web browser as a webpage. The problem is that you're parsing the code at the terminal, so that's the output you get, the html code.

Install apache and its php module and then put your file inside the HTML directory of apache. Then just access your file through your browser

http://localhost/asp.php

0

@zERO13 ARE THERE ANY DESIGN MODE EDITOR OR KINDA FRONTEND TOOL like FRONTPAGE
IN WINDOWS FOR UBUNTU

0

It seems to me that you are trying to run the script from the command line instead of displaying it in a browser.

In general with PHP you can make two types of scripts:
- applications which are run from command line (php scriptname.php)
- and scripts which are processed on the web server and the result displayed in a browser

You seem to want to do the later since you have PHP within Html code. In this case you have to set up a web server (Apache, Lamp,...) or get web hosting, put the script in appropriate directory and open it with a web browser pointing to specific address.

Judging from your post you have Linux so install and start Apache, put the script in /var/www/html (or similar) and open it with the browser at http://localhost. There are many tutorials arround on how to install, configure and startApache.

0

As far as editors are concerned for serious use most people recommend PHP Eclipse http://www.phpeclipse.com/, but it might be to overwhelming for a beginner. If you have Gnome then gedit is very good to start with, if you use KDE then KWrite is equivalent. Try one of these and plan to start learning Eclipse as you get more proficient in PHP.

0

I think AppServ has the integrated needed package (PHP, MySQL) and Recently ZEND and a PHP text processor.

0

Friend, copy\paste this into new .php file , save it as something.php and it will work:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Lang" content="en">
<meta name="author" content="">
<meta http-equiv="Reply-to" content="@.com">
<meta name="generator" content="PhpED 5.8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="creation-date" content="01/01/2009">
<meta name="revisit-after" content="15 days">
<title>MySite</title>
<link rel="stylesheet" type="text/css" href="my.css">
</head>
<body>
  <?php
      echo("This is my crazy script!");
    ?>
</body>
</html>
0

Hi there,

To fix your PHP code,

<?php

echo "My first program and its a failure" ;

?>

a semi-colon was missing.

Also, to fix your HTML

<head> 
              <title> My first PHP program </title>
        </head>

Always, try keeping your tags in lower case letters like <head> </head> <body> </body>. You should be able to run a successful one now. Here is a good site to learn PHP http://phpacademy.org/videos/index.php?all

0

@zero13 sry fr bugging u again.I've installed Apche-2 ,now what to do

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.