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 4 of 4

Thread: another problem

  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    another problem

    Hii i have another problem.
    it is write to me:
    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/****/public_html/search.php on line 23
    and i dont know why.
    (i do the ***** because there was wroten the username and i dont wanna to be hacked)
    this is the code:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html>

       <head> 
          <title>Search</title>
       </head>
    <body>
    <?php
    if(isset($_POST['submited']))
    {
        function 
    my_err($my_msg)
            {
                    global 
    $failed;
                    global 
    $err_msg;
                    if (
    $failed == FALSE)
                    {
                        
    $failed=TRUE;
                        
    $err_msg .="Error(s): <br /> \n";
                    }
                    
    $err_msg .= "$my_msg <br /> \n";
            }
        
    $start=mysql_query("SELECT `link`, `username` FROM `users` WHERE `username` LIKE '%".$_POST['searchTXT']."%' LIMIT ".$_GET['page'] * 10 10.", ".$_GET['page'] * 10);
        if(
    mysql_num_rows($start) == 0)
        {
                
    my_err('User not found');
        }
        else
        {
            while(
    $info=mysql_fetch_array($start))
            {
                    
    $info['username'] = str_replace($info['username'], '<b>'.$info['username'].'</b>;
                    echo '
    <div>';
                    echo $info['
    username'].'<br />';
                    echo '
    <a href="'.$info['link'].'">Go to profile</a>';
                    echo '
    </div>';
                    echo '
    <br />';
            }
            $start=mysql_query("SELECT `id` FROM `users` WHERE `username` LIKE '
    %".$_POST['searchTXT']."%'");
            $rows=round(mysql_num_rows($start));
            for($i = 1; $i <= $rows; $i++);
            {
                    if($i == $_GET['
    page'])
                    {
                        echo '
    <a href="search.php?page='.$i.'"><b>'.$i.'</b></a>';
                        continue;
                    }
                    echo '
    <a href="search.php?page='.$i.'">'.$i.'</a>';
            }
            echo '
    </span>';
            echo '
    </body>
            </
    html>';
            exit;
        }
    ?>   
        <?php
        if($failed)
            echo '
    <span>'.$err_msg.'</span>;
        
    ?>
        <form action="search.php" method="post">
            <span>Search :</span><input type="text" name="searchTXT" />
            <input type="submit" name="submited" value="TRUE" />
        </form>
    </body>
    </html>
    And i check and the db have all the fields.
    PLEASE HELP ME!!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,855
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    You may get it by having a look at the color difference in the string, highlighted by the PHP editor in your post.

    PS: Please avoid the use bold tags for the entire text in your posts, which may make a tone of shout.
    Last edited by abduraooft; 10-13-2012 at 02:35 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    You may get it by having a look at the color difference in the string, highlighted by the PHP editor in your post.

    PS: Please avoid the use bold tags for the entire text in your posts, which may make a tone of shout.
    i dont understand.....................
    can you give me the full fixed code?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Look at your code above. PHP markup highlight strings in red. Where you see a red echo that indicates that you have a previously opened single or double quote that has not been closed. The error will indicate on which line it detects that a failure happened, so it will be somewhere <= the line number in the error for a T_CONSTANT_ENCAPSED_STRING error. It ignores anything out of <?php?> blocks for line numbering.


  •  

    Posting Permissions

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