Author Topic: Apache/php  (Read 4477 times)

0 Members and 1 Guest are viewing this topic.

Offline SSG Snuggle Bunny

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 23049
  • Reputation: +2234/-269
  • Voted Rookie-of-the-Year, 3 years running
Apache/php
« on: April 04, 2012, 10:50:42 AM »
Trying to learn php.

I DL'ed and installed WAMP and it appears to be running correctly.

I open my notepad and type the following, per the instructions of my "How-To" book:

Code: [Select]
<?php
echo  "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">n";
for (
$y=1$y<=12$y++) {
echo "<tr> \n";
for ($x=1$x<=12$x++) {
echo "<td>";
echo ($x $y);
echo "</td> \n";
}
echo "</tr> \n";
}
echo 
"</table>";
?>

The book says to save it as a .php file and put it in the document directory and then open using a web browser.

However, when I open using FF or IE all I get is the above code.

I even tried throwing html-head-body tags around it.


So what did I miss?
According to the Bible, "know" means "yes."

Offline Maxiest

  • Chief Interruptor Officer
  • Hero Member
  • *****
  • Posts: 2471
  • Reputation: +155/-101
  • IT Guru - Social Media Wizard - Recovery Advocate
Re: Apache/php
« Reply #1 on: April 04, 2012, 10:53:42 AM »
Did you name it index.php?
"The society that puts equality before freedom will end up with neither; the society that puts freedom before equality will end up with a great measure of both."

"Nothing is so permanent as a temporary government program."

"We have a system that increasingly taxes work and subsidizes nonwork."

-Milton Friedman

Offline SSG Snuggle Bunny

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 23049
  • Reputation: +2234/-269
  • Voted Rookie-of-the-Year, 3 years running
Re: Apache/php
« Reply #2 on: April 04, 2012, 11:02:47 AM »
Did you name it index.php?

Das Book says to name it: testnestfor.php because it's teaching the nesting of loops.
According to the Bible, "know" means "yes."

Offline Maxiest

  • Chief Interruptor Officer
  • Hero Member
  • *****
  • Posts: 2471
  • Reputation: +155/-101
  • IT Guru - Social Media Wizard - Recovery Advocate
Re: Apache/php
« Reply #3 on: April 04, 2012, 11:11:20 AM »
Das Book says to name it: testnestfor.php because it's teaching the nesting of loops.

Yeah I guess you can do that too.

And you have IIS or Apache installed on your test machine?
"The society that puts equality before freedom will end up with neither; the society that puts freedom before equality will end up with a great measure of both."

"Nothing is so permanent as a temporary government program."

"We have a system that increasingly taxes work and subsidizes nonwork."

-Milton Friedman

Offline SSG Snuggle Bunny

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 23049
  • Reputation: +2234/-269
  • Voted Rookie-of-the-Year, 3 years running
Re: Apache/php
« Reply #4 on: April 04, 2012, 11:36:38 AM »
Yeah I guess you can do that too.

And you have IIS or Apache installed on your test machine?

Yep. Apache.

And it is running...near as I can tell.

I'm not really trying to be a server admin. I'm trying to learn mySQL, XML, JavaScript etc. but to do that I need an Apache-esque server to run the documents thru.
According to the Bible, "know" means "yes."

Offline Maxiest

  • Chief Interruptor Officer
  • Hero Member
  • *****
  • Posts: 2471
  • Reputation: +155/-101
  • IT Guru - Social Media Wizard - Recovery Advocate
Re: Apache/php
« Reply #5 on: April 04, 2012, 11:45:25 AM »
Yep. Apache.

And it is running...near as I can tell.

I'm not really trying to be a server admin. I'm trying to learn mySQL, XML, JavaScript etc. but to do that I need an Apache-esque server to run the documents thru.

Yes you do.  I don't see anything wrong with your code.
"The society that puts equality before freedom will end up with neither; the society that puts freedom before equality will end up with a great measure of both."

"Nothing is so permanent as a temporary government program."

"We have a system that increasingly taxes work and subsidizes nonwork."

-Milton Friedman

Offline LC EFA

  • Hickus Australianus
  • In Memoriam
  • Hero Member
  • *****
  • Posts: 4527
  • Reputation: +414/-33
Re: Apache/php
« Reply #6 on: April 10, 2012, 02:30:11 AM »
When I was learning PHP I had to install a MySQL server , PHP Server and Apache server. All were free downloads and all ran on the same machine.

Offline CactusCarlos

  • Pray, eat your vitamins, and one day you too could be a
  • Hero Member
  • *****
  • Posts: 4113
  • Reputation: +296/-100
  • If I agree with you, then we'll both be wrong.
Re: Apache/php
« Reply #7 on: April 10, 2012, 10:01:42 AM »
Trying to learn php.

I DL'ed and installed WAMP and it appears to be running correctly.

I open my notepad and type the following, per the instructions of my "How-To" book:

Code: [Select]
<?php
echo  "<table border=\"1\" cellpadding=\"4\" cellspacing=\"4\">n";
for (
$y=1$y<=12$y++) {
echo "<tr> \n";
for ($x=1$x<=12$x++) {
echo "<td>";
echo ($x $y);
echo "</td> \n";
}
echo "</tr> \n";
}
echo 
"</table>";
?>

The book says to save it as a .php file and put it in the document directory and then open using a web browser.

However, when I open using FF or IE all I get is the above code.

I even tried throwing html-head-body tags around it.


So what did I miss?

Not versed in php at all but do you have to chmod php scripts so that they're executable?
"The American people will never knowingly adopt socialism, but under the name of liberalism they will adopt every fragment of the socialist program until one day America will be a socialist nation without ever knowing how it happened."
  -- Norman Thomas, six-time Socialist Party presidential candidate and one of the founders of the ACLU