Monday 15 February 2010

mysql - New to php. Just got this when making a login page: 'Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given' -



mysql - New to php. Just got this when making a login page: 'Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given' -

this question has reply here:

mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 32 answers

i've been working on login page time now, every time seek log in, message 'warning: mysqli_fetch_row() expects parameter 1 mysqli_result, boolean given'. ideas on how prepare issue?

<?php session_start(); if (isset($_post['username'])) { include_once("dbconnect.php"); $usname = strip_tags($_post["username"]); $paswd = strip_tags($_post["password"]); $usname = mysqli_real_escape_string($dbcon, $usname); $paswd = mysqli_real_escape_string($dbcon, $paswd); $sql = "select id, username, password users username = '$usname' , activated = '1' limit 1"; $query = mysqli_query($dbcon, $sql); $row = mysqli_fetch_row($query); $uid = $row[0]; $dbusname = $row[1]; $dbpassword = $row[2]; if ($usname == $dbusname && $paswd == $dbpassword) { // set session variables $_session['username'] = $usname; $_session['id'] = $uid; $msg = " "; $msg = "username: ".$usname." dbusername: ".$dbusname; // direct users feed //header("location: user.php"); } else { $msg = "<h2>that username or password wrong dumbass.</h2>"; } } else { $msg = " "; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <link href="css/reset.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <title>campus key</title> </head> <body> <header> <a href="#"> <img src="logowhite.png" alt="campus key" style="width:150px;height:41px"></a> </header> <nav class="navigation"> <div class="non_registerd"> <h2><a class="button" href="#">logged-in user's name</a></h2> </div> </nav> <form id="form" action="login.php" method="post" enctype="multipart/fprm-data"> <?php echo $msg; ?><br> uri email: <input class="input" id="email" type="text" name="username" value="user@my.uri.edu" size="30"><br> password: <input class="input" id="pass" type="password" name="password" size="30"><br> <input class="button" type="submit" name="submit" value="login"><br> </form> </body> <footer> <p><font color="#ffffff">campus key &copy whatever want</color></p> </footer> </html>

never mind, figured out. named primary key userid instead of id. changed name , bam! got it!

php mysql database warnings fetch

No comments:

Post a Comment