Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wwwroot\horeca\action.php on line 24
No database selected
In action.php heb ik ondermeer hetvolgende staan:
Code: Selecteer alles
$username = $_POST['username'];
$password = $_POST['password'];
$query = "SELECT * FROM profile WHERE profile_name='$username' AND profile_password='$password'";
$sql = mysql_query($query);
if (mysql_num_rows($sql) == 1){ // = line 24
$row = mysql_fetch_array($sql);
while (list($key, $val) = each($row)) {
session_register($key);
$_SESSION[$key] = $val;
}
}
in db.php hetvolgende:
Code: Selecteer alles
$host = "localhost";
$user = "root";
$password = "";
$database = "horeca";
@$connection = mysql_pconnect($host, $user, $password) or die ("Couldn't connect to server.");
@$db = mysql_select_db($database);
De database bestaat en tabel ziet er zo uit:
Code: Selecteer alles
CREATE TABLE `profile` (
`profile_id` int(25) NOT NULL auto_increment,
`profile_name` varchar(25) character set latin1 collate latin1_general_ci NOT NULL default '',
`profile_password` varchar(255) NOT NULL default '',
PRIMARY KEY (`profile_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Teneinde raad vraag ik hier hulp, wat doe ik fout?
Stino...