php - mysqli_connect(): (HY000/1045) -
here code
<?php $host="localhost"; $dbuser="root"; $pass=""; $dbname="online_exam"; $conn=mysqli_connect($host,$dbuser,$pass,$dbname); // echo "$conn"; if(mysqli_connect_errno()) {die("connection failed!".mysqli_connect_error()); } ?> <html> <body background="bg/hero8.jpg" text="white"> <table cellspacing="15px" border="0px" align="center"> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <form action="logins.php" method="post"> <tr> <td>students login</td></tr> <tr> <td>enter user name:<input type="text" name="uname"></td></tr> <tr> <td>enter password:<input type="password" name="pwd"></td></tr> <tr><td><input type="submit" name="submit" value="login"></td></tr> </table> </body> </html> <?php if(isset($_post['submit'])){ $uname = $_post['uname']; $pswd=$_post['pwd']; if(empty($uname) || empty($pswd)) {echo"oops! suppose not leave of constrains empty ";} else{ $sql="select * student email='{$uname}'and pass='{$pswd}';"; //q_no, ques, op_1, op_2, op_3, op_4, ans $res=mysqli_query($conn,$sql); if(!$res){ //die("query failed".mysqli_error($conn)); echo "user name or password wrong"; } else{$flag=0; while($row=mysqli_fetch_array($res)){ //$course = $row['course']; //$question_array[$i]=$row['ques']; $name = $row['name']; $lastresult= $row['lastresult']; $usn=$row['usn']; $flag=1; } if($flag==0) {echo "wrong password or username"; exit;} session_start(); $_session['myvalue']=$lastresult; $_session['myvalue1']=$name; $_session['myvalue2']=$usn; header("location: student_menu.php"); exit; } } } ?>
my error occurs in line 6
i using xampp
warning: mysqli_connect(): (hy000/1045): access denied user 'root'@'localhost' (using password: yes) in c:\xampp\htdocs\xampp\dbms\logins.php on line 6 connection failed!access denied user 'root'@'localhost' (using password: yes)
Comments
Post a Comment