SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php if statement error

    I'm trying to get the following if statement to work:
    if (($_SESSION['col4'] == 1 or $_SESSION['col4'] == 2) AND $Recordset2->Fields('col22')==1){
    }else{
    echo '<a href="#" class="linksdetails1" onclick="window.open('118.php?recordid25=<?php echo $Recordset5->Fields('col1fromtbl24') ;?>','popup','width='+(screen.availWidth-100)+',height='+(screen.availHeight-100)+',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,status=yes,left=50,top=50'); return false">';
    }
    ?>

    But get this error:

    Parse error: parse error, unexpected T_DNUMBER, expecting ',' or ';' in c:\inetpub\wwwroot\test2\76.php on line 270

    line 270 is this line in the if statement:
    echo '<a href="#" class="linksdetails1" onclick="window.open('118.php?recordid25=<?php echo $Recordset5->Fields('col1fromtbl24') ;?>','popup','width='+(screen.availWidth-100)+',height='+(screen.availHeight-100)+',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,status=yes,left=50,top=50'); return false">';

    can anyone see what's wrong?

  2. #2
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    California
    Posts
    267
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by johnjohn2
    Parse error: parse error, unexpected T_DNUMBER, expecting ',' or ';' in c:\inetpub\wwwroot\test2\76.php on line 270

    line 270 is this line in the if statement:
    echo '<a href="#" class="linksdetails1" onclick="window.open('118.php?recordid25=<?php echo $Recordset5->Fields('col1fromtbl24') ;?>','popup','width='+(screen.availWidth-100)+',height='+(screen.availHeight-100)+',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,menubar=yes,status=yes,left=50,top=50'); return false">';

    can anyone see what's wrong?
    The single quotes must be escaped.

    PHP Code:
    echo '<a href="#" class="linksdetails1" onclick="window.open(\'118.php?recordid25=' $Recordset5->Fields('col1fromtbl24') . '\',\'popup\', \'width=\'+(screen.availWidth-100)+\',height=\'+(screen.availHeight-100)+\',return false">'

  3. #3
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    789
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this code instead:
    PHP Code:
    echo "<a href='#' class='linksdetails1' onclick='window.open('118.php?recordid25= $Recordset5->Fields('col1fromtbl24')','popup',width='+(screen.availWidth-100)+',height='+(screen.availHeight-100)+',scrollbars=yes,resizable=yes,toolbar=yes,directories=yes,location=yes,m enubar=yes,status=yes,left=50,top=50'); return false">'; 
    I think its better to always put echo details inside " and put single quotes for everything else. I removed <?php echo that was in the code because that was probably casuing the error too.

    Regards,

    James
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .


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
  •