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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Cant find error fix in my Script

    Hi im a bit of a noob at php but im creating forums on my site and I cant find why I am getting error in this code below
    I get this error

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a3783319/public_html/forum/online.php on line 30
    its for the online list am I even doing it right? thanks would be appreciated if someone helped
    PHP Code:
    <?php

    include 'connect.php';
    include 
    'header.php';

    $nuser=$_SESSION['user'];
     
    $auser=$_SESSION['admin'];
     
    if(
    $nuser){
     
    $userfinal=$nuser;
     }elseif(
    $auser){
     
    $userfinal=$auser;
     }
     if(isset(
    $userfinal)){
     
    $Members mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error());
     
    $numRowsMembers mysql_num_rows($Members);
     
    ?>
     

     
    <?php
     
    for($count 1$count <= $numRowsMembers$count++)
     {
     
    $name mysql_fetch_array($Members);
     
    ?>

     <tr>
     <?php
     
    echo '<td><a href='/redirect/"member_profile.php?username=''. $name['user'] . '">' . $name['user'] . '</a></td>';
     ?>
     </tr>

     <?php
     }
     ?>
     </table>
    echo '
    </td>';
    echo '
    <br />';
    echo '
    <a href="index.php">Home</a>';
    echo '
    </tr>';        
    include '
    footer.php;
    ?>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,341
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Look at the colours of your code - near the bottom there is a lot of red indicating a string which means you've got your quote marks wrong. Use this:

    PHP Code:
     <?php
    echo '<td><a href="/redirect/member_profile.php?username=' .$name['user'] .'">' .$name['user'] .'</a></td>';
     
    ?>
    OR you can do this:
    PHP Code:
     <?php
    echo "<td><a href=\"/redirect/member_profile.php?username={$name['user']}\">{$name['user']}</a></td>";
     
    ?>
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks but its still giving same error i dont see nothing wrong anywhere

  • #4
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts
    The following should work
    Code:
     echo "<td><a href=\"/redirect/member_profile.php?username=".$name['user']."\">".$name['user']."</a></td>";

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,341
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Nile you've just over complicated my own answer - you're using double quotes for things that don't even need them. I suggest you read the quotes tip in my signature for an explanation of how to use them, when and why.

    @Matt: Try adding <?php after </table> like this:

    </table>
    <?php

    Your whole code should then look like this (actually just copy and paste this):
    PHP Code:
    <?php

    include 'connect.php';
    include 
    'header.php';

    $nuser=$_SESSION['user'];
     
    $auser=$_SESSION['admin'];
     
    if(
    $nuser){
     
    $userfinal=$nuser;
     }elseif(
    $auser){
     
    $userfinal=$auser;
     }
     if(isset(
    $userfinal)){
     
    $Members mysql_query("SELECT user FROM characters WHERE level ='1' ORDER BY exp DESC") or die(mysql_error());
     
    $numRowsMembers mysql_num_rows($Members);
     
    ?>
     

     
    <?php
     
    for($count 1$count <= $numRowsMembers$count++)
     {
     
    $name mysql_fetch_array($Members);
     
    ?>

     <tr>
     <?php
    echo '<td><a href="/redirect/member_profile.php?username=' .$name['user'] .'">' .$name['user'] .'</a></td>';
     
    ?>
     </tr>

     <?php
     
    }
     
    ?>
     </table>
    <?php   //<==here
    echo '</td>';
    echo 
    '<br />';
    echo 
    '<a href="index.php">Home</a>';
    echo 
    '</tr>';        
    include 
    footer.php;
    ?>
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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