|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
2 errors, numrows not returning correct result
Hi, I seem to be getting these two errors:
"mysql(): This function is now deprecated; use mysql_query() instead" "mysql_numrows(): Supplied argument is not a valid MySQL result resource" I already have a user in the users table with a username of test and a password of test. When I type these into my input fields and press the login button, it keeps returning the else statement even though $numrows == 1, when really it should be returning the if statement which should say "Login Successful". I set $numrows to == 0 and it returned the if statement, so for some reason, it's not realising that there is a row in the database. Below is my code for the login_check page: <? session_start(); ?> <html> <head> <title>User Registration</title> </head> <body> <?php $username = "username"; $password = "password"; mysql_connect("localhost") or die ("Couldn't connect to the server"); $result = mysql('infuzionmail', "SELECT * FROM users WHERE username = '$username' AND password = '$password'"); $numrows = mysql_numrows("$result"); if ($numrows == 1){ session_register("username"); session_register("password"); $HTTP_SESSION_VARS["username"] = $username; $HTTP_SESSION_VARS["password"] = $password; ?> <script language=javascript> document.location.href="index.php?result=3" </script> <? } else { ?> <script language=javascript> document.location.href="index.php?result=2" </script> <? } ?> </body> </html> |
|
#2
|
|||
|
|||
|
You should probably pay attention to those error messages. Don't use mysql() (you should also use mysql_num_rows() instead of mysql_numrows(), but that's not a script-killer). If your function's erroring, of course it's not going to return what you want.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > 2 errors, numrows not returning correct result |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|