Jump to content

Problem w/ First PHP Lesson...


davidianstyle

Recommended Posts

I am a complete PHP noob (I just opened up a PHP book and am reading the first chapter).

 

So I have installed MySQL, PHP, and Apache on my computer and did all the necessary setup (I'm pretty sure) I even created a test.php which included

 

<? phpinfo(); ?>

 

and gave me the correct screen

 

however...when I did this:

 

<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
  echo '<p>Order processed</p>';
?>
</body>
</html>

 

the output looked something like this:

 

Bob's Auto Parts

Order Results

 

Order processed

 

'; ?>

 

I don't know why that extra '; ?> keeps showing up...

What am I doing wrong? plz help! Thanks.

Link to comment
https://forums.phpfreaks.com/topic/36583-problem-w-first-php-lesson/
Share on other sites

The first one gives the same result and the second one

 

<?php
  $foo = '<p>Order processed</p>';
  print $foo;
?>

 

gives this:

 

Bob's Auto Parts

Order Results

Order processed

 

'; print $foo; ?>

 

I am using "PHP and MySQL Web Development" 3rd Ed. by Luke Welling and Laura Thomson

Of course I just had to name the wrong book. I would recommend the one I guessed...I found the one your reading a little complicated and I couldn't get what they were saying to stick.

 

The one by "Andy Harris" explained perfectly to where I understood everything. Then again, we all have different learning styles, so it might not be the best one for you.

What if you do this:

<?php

  $foo = '<p>Order processed</p>';

  print $foo

?>

 

(note, the lack of the closing ; - try this one)

 

Also, check through your phpinfo - what settings are different from default? You can try looking those up, see if any are causing problems?

works fine this end double or single quotes wiered

 


<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
  echo "<p>Order processed</p>";
?>
</body>
</html>

 

 

result

X-Powered-By: PHP/4.4.1

Content-type: text/html

<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<p>Order processed</p></body>
</html>

 

have you added to the php.ini .html .php

 

I am using "PHP and MySQL Web Development" 3rd Ed. by Luke Welling and Laura Thomson

 

i didn't like that one. that was my first book, as well. i found the coding style to be really bad practice. and not very a definitive guide. i did learn from it tho. when you know nothing, you can learn from an idiot, i guess.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.