Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 注意:未定义索引:中的主题\u创建者_Php_Mysql - Fatal编程技术网

Php 注意:未定义索引:中的主题\u创建者

Php 注意:未定义索引:中的主题\u创建者,php,mysql,Php,Mysql,如何修复注意:未定义索引:C:\wamp\www\forum\view\u category.php第313行的topic\u creator。 我确实在一页上读到,在$topic_creator的前面放上@可能会有帮助,但我没有。我找不到一个地方说明如何修理它,所以请帮助我。 这是我的密码 include_once("connect.php"); $sql = "SELECT id FROM categories WHERE id='".$cid."' LIMIT 1"; $res = mys

如何修复
注意:未定义索引:C:\wamp\www\forum\view\u category.php第313行的topic\u creator。
我确实在一页上读到,在$topic_creator的前面放上@可能会有帮助,但我没有。我找不到一个地方说明如何修理它,所以请帮助我。
这是我的密码

include_once("connect.php");
$sql = "SELECT id FROM categories WHERE id='".$cid."' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) == 1) {
    $sql2 = "SELECT * FROM topics WHERE category_id='".$cid."' ORDER BY topic_reply_date DESC";
    $res2 = mysql_query($sql2) or die(mysql_error());
    if (mysql_num_rows($res2) > 0) {
    while ($row = mysql_fetch_assoc($res)) {

    **Line 313** if($row['topic_last_user']== "") { $last_user = getusername($row['topic_creator']); } else { $last_user = getusername($row['topic_creator']); }

        $topics .="
        <li class='category'><div class='left_cat'>
        <a class='underline' href='view_topic.php?cid=".$cid."&tid=".$tid."'>
        <div class='title'><i class='icon-comment'></i>&nbsp;".$title."</div></a>
        <div class='info'><i class='icon-comments icon-1'></i>&nbsp;".topicreplies($cid, $tid)." Comments&nbsp; &nbsp; &nbsp;<i class='icon-user icon-1'>
        &nbsp;</i>".$last2_user."&nbsp; ".$last_user."
include_once(“connect.php”);
$sql=“从id=”的类别中选择id。”$cid。”“限制1”;
$res=mysql\u query($sql)或die(mysql\u error());
if(mysql_num_rows($res)==1){
$sql2=“从类别为“$cid”的主题中选择*”,“按主题的顺序回复日期描述”;
$res2=mysql\u query($sql2)或die(mysql\u error());
如果(mysql_num_rows($res2)>0){
while($row=mysql\u fetch\u assoc($res)){
**第313行**如果($row['topic\u last\u user']==”){$last\u user=getusername($row['topic\u creator']);}其他{$last\u user=getusername($row['topic\u creator']);}
$topics.=”
  • “.topicreplies($cid,$tid)。”评论 “$last2\u用户。”“$last\u用户。”
  • $row
    var\u dump($row)中没有键
    topic\u creator
    看看你有什么密钥。哦,这就是我这里的
    布尔false
    。@u muldera也看到了-你的代码容易受到sql注入的攻击。你应该小心地在代码中使用
    @
    -它会抑制错误,并确保你真的知道你在做什么。我想你在你的代码中可能是指
    $res2
    while loop,而不是
    $res
    ?(根据变量的实际用途而不是通用名称命名变量有助于避免这种混淆。)谢谢@CBroe:)这就是问题所在$res2而不是$res