#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    31
    Rep Power
    13

    PHP with javascript inside doesn't work...PLEASE HELP


    I have a php script with a javascript inside. But nomather what i do, I get errors...

    Se the attached file
    Attached Files
  2. #2
  3. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    You get error in PHP or in Javascript ?

    Puttin only code up doesnt help. Put up error too.

    JD
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    31
    Rep Power
    13
    Here is the error:

    Parse error: parse error in /home/sites/site300/web/shop/shop_checkout.php on line 449

    But line 449 does not contain any text at all...
  6. #4
  7. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    Actually you have missed closing of single or double quotes or a semicolon.

    In that case, parser gets confused and gives wrong line number.

    It is not compulsory that error is on that line only. It may be on that line or previous lines.

    As such your code is lengthy and not formatted properly so its hard to debug, you would have"to do it yourself.

    JD
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Den Haag, Netherlands
    Posts
    69
    Rep Power
    13
    It helps if you don't mix large pieces of HTML and PHP, and definitely not in PHP control structures. For example, line 48-50,

    PHP Code:
    if ($num_rows == "0") {
        echo 
    "<P><strong>There are no items in your cart.</p>";
    } else { 
    and then follows a lot of HTML. Where does the else block end? No wonder you get confused.

    What I usually do, is first arrange all the complicated PHP stuff, then put all the HTML as 'here doc' text, in which you can insert PHP variables. Example:

    PHP Code:
    <?php
    // First all PHP stuff
    if( $something )  {
       
    $message "Some message";
    } else {
       
    $message "Another message";
    }
    // Now the HTML stuff
    echo <<<PAGE
    <HTML>
    ...
    <p>Message: 
    $message</p>
    ...
    </HTML>
    PAGE;
    ?>
    Code:
    Groetjes van Harry!   8-)

IMN logo majestic logo threadwatch logo seochat tools logo