dylan smith dylan smith - 8 months ago 35
MySQL Question

I need so help! my php will not select a db

I have created a basic login in using php. I have fixed my previous error thanks to your help however i am now receiving a new error on line 36 - 'Call to undefined function session_register() in /Applications/XAMPP/xamppfiles/htdocs/game development/checklogin.php on line 36' im not sure why. Any ideas on how to fix this?

Can someone please tell me why and/or fix my code? thanks


$host="localhost"; // Host Name

$username="root"; // Mysql Username

$password=""; // Mysql Password

$db_name="DylansDB"; // Database Name


// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword

// To protect MySQL injection
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";

// Mysql_num_row is counting table row

// If result matched $myusername and $mypassword, table row must be 1 row

// Register $myusername, $mypassword and redirect to file "login_success.php"
else {
echo "Wrong Username or Password";

$host="localhost"; // Host Name 

$username="root"; // Mysql Username

 $password=""; // Mysql Password 

 $db_name="DylansDB"; // Database Name 

  $tbl_name="members"; // Table Name