Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-13-2012, 12:52 PM   PM User | #1
sahkan_dengran
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
sahkan_dengran is an unknown quantity at this point
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!!
sahkan_dengran is offline   Reply With Quote
Old 10-13-2012, 01:27 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
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.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

Last edited by abduraooft; 10-13-2012 at 02:35 PM..
abduraooft is offline   Reply With Quote
Old 10-13-2012, 03:01 PM   PM User | #3
sahkan_dengran
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
sahkan_dengran is an unknown quantity at this point
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?
sahkan_dengran is offline   Reply With Quote
Old 10-13-2012, 06:36 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:17 AM.


Advertisement
Log in to turn off these ads.