Welcome! Log In Create A New Profile

Advanced

Topic 2C

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Re: Topic 2C
March 06, 2006 12:01PM
No I did not get this sort of output
I got a parse error together with the correct outcome

when I removed the comments it was no longer given this error.
when I placed the // inside the comments /*

*/ I got the correct output of the program but it was repeated three times

here is the offending code, perhaps you can try it

it is the function.php file content please try it with and without the // inside the comments

<html>
<head><title>Calculating the purchase price</title></head>
<body>
<!--INSERT CODE HERE-->


<?php
$price = $_POST['price'];
$items = $_POST['items'];
//So, always use $whatever=$_POST['the_formarea_input']; when using forms.
function total ($price, $items)
{
$cost = $price * $items;
echo "the total price is $$cost";
}

echo total($price,$items);
?>


/*
libby - $cost=$_POST['cost']; is not going to bring you anywhere - cost was not passsed from cost.html to functions.php.
price and items were.

Note: the $ meant as a dollar as here above could cause problems. Better to print it outside php, like:

<?php
$price=$_POST['price'];
$items=$_POST['items'];

//function total($price, $items)
{
$cost=$price* $items;echo "the total price is"; ?>$<?php echo "$cost";}

echo total($price,$items);
?>
*/

</body>
</html>

avatar
Mac
Re: Topic 2C
March 06, 2006 12:31PM
Please put the code you want me to test inside two "containers" like

<---from here ---->

your code to test

<----to here ----->

since the code here above is deurmekaar. Did you mean to include the bottom part (between the /* */ comments?)

If so, then its wrong, since /* comments */ should be inside <?php ?> tags.

Comments, used OUTSIDE PHP tags, are done like this
<!-- comment-->

Comments, used inside PHP tags, are done like this
/* comment*/

or

// comment

Re: Topic 2C
March 06, 2006 01:14PM
Thank you
now I have learnt

I will try to keep my code from being deurmekaar in the future. drinking smiley


Re: Topic 2C
March 07, 2006 07:46PM
thanks or the help - I hae completed this topic now
Re: Topic 2C
March 10, 2006 12:28AM
Topic Complete
Re: Topic 2C
March 12, 2006 11:59PM
All done

tongue sticking out smiley


Re: Topic 2C
March 13, 2006 01:56PM
All good here smiling smiley
Re: Topic 2C
March 14, 2006 03:39PM
It some times helps ALLOT if somebody else has a look at your code before going into hair pull out mode.

$price = $_POST['$price']; smiling smiley

All done.
Re: Topic 2C
March 17, 2006 07:51AM
done with minor probs.
Nothing google couldn't solve.
smiling smiley

Murphy's Technology Law 7
-- The attention span of a computer
is only as long as its electrical cord.
Re: Topic 2C
May 05, 2006 01:21PM
Completed Successfully
Sorry, you do not have permission to post/reply in this forum.