...

View Full Version : i cant see an error , can u?



matthew_haworth
10-25-2004, 11:42 PM
I was teaching my friend basic php can u spot whats wrong with this?



<?
//food at the pavilion

$chips = 1.00;
$pie = 0.85;
$crisp = 0.50;
$lobster = 15.00;
$king_prawn = 13.50;
$cake = 0.95;

// seamus gets pie and chips, unfortunately he has amnesia, how much does that cost
$seamus_meal = $chips+$pie;

echo(I just remembered seamus, your meal costs .$seamus_meal);

// seamus has only brought 2 quid to school with him

$seamus_money = '2.00';


// If seamus' money is more than the mean then......

if ($seamus_money>$seamus_meal) {

// work out seamus' change

$seamus_change = $seamus_money-$seamus_meal;

// then tell him that he can afford his meal with the amount of change to spare he has left

echo("Seamus can afford his meal with ".$seamus_change." to spare.");

// if seamus money is lower than the meal price then....

} ($seamus_money<$seamus_meal) {

// tell seamus he cant afford it

echo("Seamus cannot afford his meal");

// end the if
}

?>

trib4lmaniac
10-26-2004, 12:06 AM
It would've help if you posted exactly what error message you were getting :cool:
I think it's the line: echo(I just remembered seamus, your meal costs .$seamus_meal);
Those aren't quotation marks. I don't know what thy are, but they probably aren't string delimiters! Try using either " or ' and see if that fixes it.

matthew_haworth
10-26-2004, 12:09 AM
I just get a blank screen, and the same problem with this too



<?
//Times gone for a piss in the last 10mins
$Times_had_a_piss[1]=1;
$Times_had_a_piss[2]=2;
$Times_had_a_piss[3]=3;
$Times_had_a_piss[4]=4;
$Times_had_a_piss[5]=5;
$Times_had_a_piss[6]=6;

$times_been_to_tiolet= $Times_had_a_piss[4];

$How_many_doctor_said_is_healthy=2;

if ($times_been_to_tiolet < $How_many_doctor_said_is_healthy) {
echo("BOOO");
} ($times_been_to_tiolet < $How_many_doctor_said_is_healthy) {
echo("QUICK CALL 999");
}

?>

matthew_haworth
10-26-2004, 12:11 AM
It would've help if you posted exactly what error message you were getting :cool:
I think it's the line: echo(I just remembered seamus, your meal costs .$seamus_meal);
Those aren't quotation marks. I don't know what thy are, but they probably aren't string delimiters! Try using either " or ' and see if that fixes it.


i realised that and changed em to ", but it still does not work

raf
10-26-2004, 12:16 AM
maybe PHP isn't installed on the server? or maybe shorttags are not allowed on that server? or maybe you're not showing the complete code?

matthew_haworth
10-26-2004, 12:18 AM
maybe PHP isn't installed on the server? or maybe shorttags are not allowed on that server? or maybe you're not showing the complete code?

php is on the server
http://mhaworth.zapto.org/ (http://mhaworth.zapto.org)

and the files in question are thingy4.php and thingy5.php

i have used short tags before on my server

i am showing you the complete code,

i have added your msn (trb4l guy) and by the way what is the code for all error reporting?

trib4lmaniac
10-26-2004, 12:35 AM
i have added your msn (trb4l guy)
Oh, must be you I just blocked :rolleyes:

trib4lmaniac
10-26-2004, 12:47 AM
Ok, we got it sorted. Simple in the end. Re-read the lines

// if seamus money is lower than the meal price then....

} ($seamus_money<$seamus_meal) {

// tell seamus he cant afford it and

if ($times_been_to_tiolet < $How_many_doctor_said_is_healthy) {
echo("BOOO");
} ($times_been_to_tiolet < $How_many_doctor_said_is_healthy) {
echo("QUICK CALL 999");
}
He'd missed the "else if's" :p



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum