使用未定义的常量uid

时间:2014-02-03 20:27:07

标签: php

<?php

include('config/config.php');

if($_POST)
{
    $q=$_POST['searchword'];
    $sql_res=mysql_query("select uid,username,email,media,country from select_tag where username like '%$q%' or email like '%$q%' order by uid LIMIT 5");
    while($row=mysql_fetch_array($sql_res))
    {
        $username=$row['username'];
        $email=$row['email'];
        $media=$row['media'];
        $country=$row['country'];
        $b_username='<b>'.$q.'</b>';
        $b_email='<b>'.$q.'</b>';
        $final_username = str_ireplace($q, $b_username, $username);
        $final_email = str_ireplace($q, $b_email, $email);
        ?>
        <div class="display_box" id="display">
        <img align="top" src="<?php echo $media; ?>" style="width:40px; height:40px;"  />
        <span class="name" id="name" data-ruid="<?php echo addslashes($row[uid]); ?>" style="position: relative;top:11px;" onclick="showselected_people();"><?php echo $final_username; ?></span></div>

        <?php
    }
}
?>

所以我编辑了帖子,但现在我收到错误“使用未定义的constatnt uid”.. ???

1 个答案:

答案 0 :(得分:3)

您的数组键周围缺少引号:

$row[uid]

应该是

$row['uid']