Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    i cant see an error , can u?

    I was teaching my friend basic php can u spot whats wrong with this?

    PHP Code:
    <?
    //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 seamusyour 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
    }

    ?>

  • #2
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would've help if you posted exactly what error message you were getting
    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.

  • #3
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just get a blank screen, and the same problem with this too

    PHP Code:
    <?
    //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");
    }

    ?>

  • #4
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by trib4lmaniac
    It would've help if you posted exactly what error message you were getting
    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

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    New Coder
    Join Date
    Oct 2004
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by raf
    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/

    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?

  • #7
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by matthew_haworth
    i have added your msn (trb4l guy)
    Oh, must be you I just blocked

  • #8
    Regular Coder trib4lmaniac's Avatar
    Join Date
    Feb 2004
    Location
    Cornwall, UK
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, we got it sorted. Simple in the end. Re-read the lines
    PHP Code:
    // if seamus money is lower than the meal price then....

    } ($seamus_money<$seamus_meal) {

    // tell seamus he cant afford it 
    and
    PHP Code:
    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"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •