Vote count:
-1
I am new here. I have searched all but Unable to get exact answer. I am executing a mysql_query in login.php but it is not working. I tried checking by placing an if condition just after mysql_query and confirmed that query is not returning result as true. have I failed establishing a proper connection to mysql database? please guide.
//login.php
<?php
include_once("Connection.php");
if(!$con) {
die ("Cannot Connect" . mysql_error());
}
$username = $_POST['UserName'];
$password = $_POST['Password'];
$result = "SELECT * FROM log WHERE username = $username AND userpass = $password";
$sql=mysqli_query($con,$result);
if($sql == FALSE) {
echo "this"; // TODO: better error handling
}
else{
$res=mysql_fetch_array($sql);
}
$num_rows = mysql_num_rows($res);
echo $num_rows;
if ($num_rows > 0) {
session_start();
$_SESSION['login'] = "1";
header ("location: path.html");
}
else{
echo $num_rows;
//header ("location: index.htm");
//exit ();
}
?>
//connection.php
<?php
$con=mysqlI_connect("localhost","root","","taxisystem" ); /* Connecting to sql */
/* we have used $con to store it in variable as we will have to use it multiple times! */
/*update: Now we will use connection.php instead! :) */
?>
asked 37 secs ago
mysqli_query not working. Missing connection?
Aucun commentaire:
Enregistrer un commentaire