Current location: Hot Scripts Forums » Programming Languages » PHP » What is wrong with this script


What is wrong with this script

Reply
  #1 (permalink)  
Old 10-26-04, 08:01 PM
donkon donkon is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
What is wrong with this script

Hello,

I am doing my first tutorial in the web development for php and mysql book and i dunno wtf is wrong with this script:

please help


Quote:
<?php
//create short variable names
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];



?>
<html>
<head>
<title> Bobs auto Parts - Order Results</title>
</head>
<body>
<h1>Bobs Auto Parts</h1>
<h2>Order Results</h2>

<?php

echo '<p>Order Processed at ';
echo date('H:i, jS F');
echo '</p>';

?>

</body>
</html>

<?php
echo '<p>Your order is as follows: </p>;
echo $tireqty." tires<br />";
echo $oilqty." bottles of oil<br />";
echo $sparkqty." spark plugs<br />";
?>
Reply With Quote
  #2 (permalink)  
Old 10-26-04, 08:11 PM
Sabu Sabu is offline
Junior Code Guru
 
Join Date: Sep 2004
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
Change
PHP Code:

echo '<p>Your order is as follows: </p>; 

to
PHP Code:

echo '<p>Your order is as follows: </p>'
( Note the added apostrophe )
Reply With Quote
  #3 (permalink)  
Old 10-26-04, 08:29 PM
donkon donkon is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Oh man thx alot, i was killing myself with this little error.
Reply With Quote
  #4 (permalink)  
Old 10-28-04, 02:36 AM
marklar's Avatar
marklar marklar is offline
Newbie Coder
 
Join Date: May 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
I just thought it was worth pointing this out.

<?php
$myString = "99";
// $2 = "Two dollars"; // This is wrong
echo $myString . " red balloons for only $2<br />";
echo "$myString red balloons for only $2<br />";
echo '$myString red balloons for only $2<br />';
?>

Will output:

99 red balloons for only $2
99 red balloons for only $2
$myString red balloons for only $2

Because php will read within " double quotes looking for variables whereas it will not look inside ' single quotes. However, because php is brilliant it knows that variables cannot begin with a number so it will not attempt to use $2 as a variable and you will get an error if you un-comment the variable line.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats wrong with this php line of script? ldm Script Requests 2 10-16-04 03:20 AM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
what is wrong with my script tisza PHP 1 07-01-04 10:49 AM
This is a very simple script that wont work..Please tell me what is wrong with it. ^^ fusion Script Requests 1 06-03-04 10:19 AM
PHP email script problems (bounces go to wrong address). MTO PHP 1 04-28-04 11:13 PM


All times are GMT -5. The time now is 04:41 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.