I need help. Before i was using mysql then my work is working but when i changed it to mysqli the “Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /var/www/1/checklogin.php on line 15 cannot select DB” comes out.
[php]
<?php session_start(); $host="localhost"; // Host name $username="root"; // Mysql username $password="LNKmis000"; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysqli_connect("$host", "$username", "$password")or die("cannot connect"); mysqli_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysqli_real_escape_string($myusername); $mypassword = mysqli_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysqli_query($sql); // Mysql_num_row is counting table row $count=mysqli_num_rows($result); if($count==1){ $_SESSION['isLogged'] = true; session_register("myusername"); session_register("mypassword"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ?><p><a href="main_login.php">back</a></p>
[/php]
checklogin.doc (23 KB)