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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.