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. #2
    Master Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    5,002
    Thanks
    104
    Thanked 585 Times in 572 Posts
    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>";
     
    ?>
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.

  3. #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. #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. #5
    Master Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    5,002
    Thanks
    104
    Thanked 585 Times in 572 Posts
    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;
    ?>
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.


 

Posting Permissions

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