MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old April 8th, 2005, 12:04 PM
ataaus ataaus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 ataaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 35 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old April 8th, 2005, 02:41 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > 2 errors, numrows not returning correct result


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway