Forum Moderators: coopster

Message Too Old, No Replies

Mysql connect - small problem

I can't see it, shouldn't be much...

         

firemaster

12:25 am on Jul 13, 2003 (gmt 0)

10+ Year Member



Here is the error I get:
[2]
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/imperial/public_html/fire/html/forgot_password_fns.php on line 11

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/imperial/public_html/fire/html/forgot_password_fns.php on line 12
The username you entered does not exist in our database, please go back and try again.[/2]

my code:

[2]
include("db_fns.php");
$username = $_POST['username'];
if($username == "") {
echo "You have not entered a username, so please go back and enter one.";
exit;
}
$check = "SELECT * FROM members WHERE name = '$username'";
$exist = mysql_query($check, $dbconn); // line 11
if(mysql_num_rows($exist) == 0) { // line 12
echo "The username you entered does not exist in our database, please go back and try again.";
exit;
}[/2]

It is just a simple forgot password script.. I don't see the problem.. maybe someone else can.

vincevincevince

12:55 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1 - have you connected to the database and stored the value as $dbconn?

2 - is the table called "members" and is the field called "name" (check it's not actually "username" or something... common mistake)

3 - add after line 10 the code:


echo $check;

and then copy and paste this SQL statement into myadmin SQL box - this provides some useful feedback on the error

The error is NOT with line 12, it is 11 or before.

firemaster

3:06 am on Jul 13, 2003 (gmt 0)

10+ Year Member



$check echos as:
SELECT * FROM members WHERE name = 'firemaster'

I already checked the fields and they are correct.
thanks,
-Mike

jamesa

4:34 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using a newer version of PHP or MySQL? I don't know when or why this changed, but i've had the same trouble. See if this works...

Try adding this after the include:

mysql_select_db($dbconn) or die("Could not select database");

and change this:

$exist = mysql_query($check, $dbconn);

to this:

$exist = mysql_query($check);

jaski

5:10 am on Jul 13, 2003 (gmt 0)

10+ Year Member



Its not clear why the error is coming .. so add this after line 11

echo mysql_error();

this should tell what the problem is.

firemaster

1:22 am on Jul 14, 2003 (gmt 0)

10+ Year Member



Thanks for the help, I added:
mysql_select_db("imperial_gzfm", $db_conn) or die("Could not select database");
after the include and removed the $db_conn from exist and it works, I am still not sure why it did this though, thanks again.
-Mike