Hallo daniweb!, Im new here *hehe* anyway I've been working on our companys website for a while now but I just cant get it to work... the error is @ the 26:th line.
btw we're using: Cirtex hosting
the defination "myusername" and "mypassword" is in the prev. .php file (main_login.php) this is suppost to check if the account name and password is correct if it is send to succes.php. from there a profile session is comming, but now to this problem!
wanna look on the error you could also go from our main-page
http://test.infernixe.com/portal/checklogin.php
just to mention it works on my localhost with wamp 2.1 ....
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/***/***/checklogin.php on line 26
*dont bother about this Wrong Username or Password*
I would appreciate alot if you helped me!
thanks
- Mattias
here's the code
<?php
$host="localhost"; // Host name
$username="infernix_root"; // Mysql username
$password="******"; // Mysql password
$db_name="infernix_accounts"; // Database name
$tbl_name="_accounts"; // Table name
// Connect to server and select the databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form in main_login
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// 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 login='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row counting table row now
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>