SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: [newbie] Parse errors in PHP - what causes this?

  1. #1
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [newbie] Parse errors in PHP - what causes this?

    Hello Chaps,

    I'm having much grief learning PHP - running up against Parse errors. I don't have much documentation on what causes there.

    I know that I must put a \ sign before any " characters when I'm mixing PHP with HTML. But what else could be causing a Parse error?

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  2. #2
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Normally it will be because you have a " or a ' in the wrong place or you have an uneven number of { } braces. The parse error message will normally give you a clue as to what is wrong. If you can't find the error in the line it specifies then it almost certainly means the actual mistake is in some of the lines before that line (and the error only becomes apparent to the parser in the line it has indicated).

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you post your code we will be able to help you find the problem

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thankyou!!

    Hi Guys,

    Brilliant, problem solved for now, thankyou.

    Appreciate your response and shall definately be visiting Sitepoint forums more often!!

    All the best,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: [newbie] Parse errors in PHP - what causes this?

    Originally posted by rawnet
    I know that I must put a \ sign before any " characters when I'm mixing PHP with HTML
    It is faster to go in and out of PHP mode, rather than mix in your HTML

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse Error Again!!



    Okay, I spoke a bit too soon!!

    I'm getting the following :

    Parse error: parse error in D:\http\servicepals.com\includes\center\phpscripts.php(23) : eval()'d code on line 18
    It's part of the vbPortal/vBulletin system, but it's the PHP that's falling over. I'm not sure why though, as it similar to that which I've used on others part of the page okay :

    PHP Code:
    echo "<p align='left'><a href='directory/default.cfm'><IMG height=10 alt='' src='images/layout/directory.gif' width=122 border=0></a><br>
    <table cellspacing=0 cellpadding=1 width='100%' border=0>
            <tr align=right bgcolor=#000066> 
              <td> 
                <table cellspacing=0 cellpadding=5 width='100%' border=0>
                  <tr bgcolor=#e9e9e9> 
                    <td>"
    ;
                    
    $query="SELECT    user.userid, userfield.field11, userfield.field12, userfield.field14, userfield.field15, userfield.field24
                    FROM user
                    LEFT JOIN userfield USING (userid)
                    ORDER BY user.joindate DESC
                    LIMIT 10"
    ;

    $result mysql_query($query);

    while(list (
    $userid$field11$field12$field14$field15$field24) = mysql_fetch_row($result))
    print(
    "<a href="forums/member.php?s=&action=getinfo&userid=$userid"><img src="images/small_arrow.gif" width=5 height=8 border=0><b>$field14 $field15</b></a><br>$field24$field11 - $field12<br>
    "
    );


    echo 
    "
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
    </table></p>"

    Any ideas guys? Not sure where I'm going wrong here!!

    Cheers,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  7. #7
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First of all, like Sean mentioned, try going in and out of PHP instead of doing it all in PHP. It's quiccker and cuts down the potential for errors. Try this:
    PHP Code:
    <p align='left'>
      <a href='directory/default.cfm'>
        <IMG height=10 alt='' src='images/layout/directory.gif' 
          width=122 border=0>
      </a><br>
        <table cellspacing=0 cellpadding=1 width='100%' 
        border=0>
          <tr align=right bgcolor=#000066> 
            <td> 
              <table cellspacing=0 cellpadding=5 width='100%' 
              border=0>
                <tr bgcolor=#e9e9e9> 
                  <td>
    <?php                
    $query
    ="SELECT user.userid, userfield.field11, userfield.field12, userfield.field14, userfield.field15, userfield.field24 FROM user LEFT JOIN userfield USING (userid)ORDER BY user.joindate DESC LIMIT 10";

    $result mysql_query($query);

    while(list (
    $userid$field11$field12$field14$field15$field24) = mysql_fetch_row($result)) ?>
             
                     <a href="forums/member.php?
                      s=&action=getinfo&userid=$userid">
                     <img src="images/small_arrow.gif" width=5 
                     height=8 border=0>
                     <b><?php echo $field14."&nbsp;".
                     
    $field15?></b>
                     </a><br>
                   <?php echo $field24$field11"-".
                   
    $field12 ?><br>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
    </table></p>
    I have not looked at the PHP, but perhaps writing it this way will solve your problem. Let us know.

    Sketch
    Aaron Brazell
    Technosailor



  8. #8
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :(

    Hi Sketch,

    Thankyou, but no joy. Cut and pasted that code but Getting this error still :

    PHP Code:
    Parse errorparse error in D:\http\servicepals.com\includes\center\phpscripts.php(23) : eval()'d code on line 1 
    Any ideas what else it could be?

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  9. #9
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, well unless <p align='left'> is your first line, I'd be looking at your first line of the file for your error. It can't be in what you gave us because line 1 is HTML not PHP.

    Sketch
    Aaron Brazell
    Technosailor



  10. #10
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ARRGGGGHHHHHHH!!!!

    Okay. Bugger. I'm using it with vbPortal - http://www.phpportals.com - and have tried there but no joy so far. That's what will be giving strange line numbers. Shall see if I can get any luck.

    Thanks anyway for the help,

    All the best,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

  11. #11
    Action! filmfoto's Avatar
    Join Date
    Dec 2001
    Location
    Sweden
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You haven't enclosed your while loop in {}. Example:
    PHP Code:
    while (expression) {
        
    /* do some code */




    Cheers.

  12. #12
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess no one noticed this line
    PHP Code:
    print("<a href="forums/member.php?s=&action=getinfo&userid=$userid"><img src="images/small_arrow.gif" width=5 height=8 border=0><b>$field14 $field15</b></a><br>$field24$field11 - $field12<br>
    "
    ); 
    You need to escape those double quotes or use single quotes dude.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  13. #13
    Apache Expert i_like_php's Avatar
    Join Date
    Nov 2001
    Location
    Dallas, Texas
    Posts
    1,342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs down

    i'm willing to bet you a million dollars, that you have includes within includes, trying to call it from a page not in the same directory.
    i love php

  14. #14
    Online Dating Guru rawnet's Avatar
    Join Date
    Jan 2002
    Location
    Windsor, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One MILLION Dollars!!

    Aaah, thankyou i_like_php - I'll take you up on that and you can give the dosh to Defender1 - I've changed the print statement to contain single quotes and all is now working great.

    Thanks for all your help guys - worked a treat - and very happy to have had so much support. I'm cross training onto PHP from Cold Fusion and am amazed how great and supportive everyone here is.

    Many thanks,

    All the best,

    Ross
    Ross Williams from WhiteLabelDating.com
    Webmasters - Add a dating channel to your website in minutes
    Earn 50% of all revenue generated - FREE SETUP

Bookmarks

Posting Permissions

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