开发者

problem during data modification

here my code -

if($pin == '105') {
 $sqltree = "INSERT INTO tbltree (`userId`, `level`, `superId`, `rootId`, `childcount`) 
                            VALUES ('$child1', '1', '$newid', '$myroot', '0');";
    mysql_query($sqltree);
    update_level($newid);
}
function update_level()
    {
        //for 1st level
            $newid = $_SESSION['newid'];
            //getting senior's level 1 and to increase by 1
            $sqlgetlevel = "SELECT superId,level1 FROM tbltree WHERE userID='$newid'";
            echo "<br>test:".$sqlgetlevel;
            $result = mysql_query($sqlgetlevel,$link)or die(mysql_error());  //line 340
            $row = mysql_fetch_array($result, MYSQL_ASSOC);
            $level1 = $row["level1"];
            $level1 = $level1 + 1;

            //update increased level
            $sqlupdate = "UPDATE tbltree SET level1='$level1' WHERE userId='$newid';";
 开发者_JAVA技巧           mysql_query($sqlupdate,$link)or die(mysql_error()); 

            //change superId for new level
            $superid = $row["superId"];
}

ERROR - test:SELECT superId,level1 FROM tbltree WHERE userID='29277640'

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\303\levelupdate.php on line 340


$link is unknown inside your function, make it a global variable or just don't use it.

$result = mysql_query($sqlgetlevel)or die(mysql_error()); //line 340

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜