My php code will not execute and I'm not sure why. Below is the code:

<!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>Before.html </title>
<meta name="Generator" content="Alleycode HTML Editor" />
<meta name="Description" content="Your description here..." />
<meta name="Keywords" content="Your keywords here..." />
</head>

Before #1, Test php
<br />

<?php
echo "Hello World!; <br> 
?>

<br />
Before #2, Variables
<br />

<?php
$name = "Name
$age = Age;
echo "My name is $name and I am $age years old.";
?>

<br />
Before #3, Comments
<br />

<?php
//-----------------------------------------variables------------------------------------
$name = "Name";
$age = Age;
$color = "Color" ;
echo "Welcome<br>";
echo "Enjoy it?<br>";
echo "Messages<br>";
?>

<body>
</body>
</html>

Any suggestions would be greatly appreciated
Thanks
Tina

Member Avatar for LastMitch

@tinabina22

My php code will not execute and I'm not sure why. Below is the code:

I think in the future try to copy and paste you code correctly.

Regarding about the issue you are having:

Where is your query?

What error are you getting?

The reason why I ask because you didn't mention it at all?

How can you expect someone or anyone understand what you are talking about.

I did paste the code as it reads. Query? No error, I am new to php so I gues I "expected" someone with experience to have some idea what I was talking about!
I don't see where being rude is any help!

This is what I get when I bring up the code, remember I am new at this:

Before #1, Test php
?>
Before #2, Variables

Before #3, Comments
"; echo "Enjoy it?
"; echo "Messages
"; ?>

Member Avatar for LastMitch

@tinabina22

I did paste the code as it reads.

Well, now your code is pasted correctly before it was all text and white background.

Query? No error, I am new to php so I gues I "expected" someone with experience to have some idea what I was talking about!

What is the issue then?

All I see is just echoing. How does it echo? I got no idea because there's no query.

A query is statement.

There's has to be at least a code that show what is echoing.

<!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>Before.html </title>
<meta name="Generator" content="Alleycode HTML Editor" />
<meta name="Description" content="Your description here..." />
<meta name="Keywords" content="Your keywords here..." />
</head>

Before #1, Test php
<br />

<?php
echo "Hello World!; <br>
?>

<br />
Before #2, Variables
<br />

<?php
$name = "Name
$age = Age;
echo "My name is $name and I am $age years old.";
?>

<br />
Before #3, Comments
<br />

<?php
//-----------------------------------------variables------------------------------------
$name = "Name";
$age = Age;
$color = "Color" ;
echo "Welcome<br>";
echo "Enjoy it?<br>";
echo "Messages<br>";
?>

<body>
</body>
</html>

But this is the same thing I posted in the beginning?

Member Avatar for LastMitch

You don't need to repost it again. I can see it fine now.

Make some adjustments:

<?php
$name = "Name";
$age = "Age";
echo "My name is $name and I am $age years old.";
?>

Can you explain a little more about his:

<?php
//-----------------------------------------variables------------------------------------
$name = "Name";
$age = Age;
$color = "Color" ;
echo "Welcome<br>";
echo "Enjoy it?<br>";
echo "Messages<br>";
?>

Hi double check this part

  • "" -make sure it has a opening and closing
  • ; - make sure you put it at the end of your variable and at the end of every echo

This problem had been resolved, thanks for all your help.

@ tinabina22
pls try to use this http://codepad.org its an online compiler...
and here is your problem's solution http://codepad.org/7zpCmnoW
also pls check those things that ehpratah said like

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.