Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Two errors that are driving me mad ..please help

I'm afraid I'm losing it :)



11:58 pm on Mar 3, 2002 (gmt 0)

I am new to PHP so it may well be that these are "silly and simple" but I'm willing to have my name ridiculed if anyone will supply the solutions.

I'm having two problems that I can't find the answers to, I have looked all around the community and in the manual but it has me beat.

1. From this code...
(line 10) $result = mysql_query ("SELECT password,email FROM table WHERE username = '$user' ");
(line 11) $myrow = mysql_fetch_array($result);

I get this error...
Warning: Supplied argument is not a valid MySQL result resource in [host details]/lostpassword.php3 on line 11

2. This code will not update my table

$sql = "UPDATE table SET user='$username',password='$password' WHERE id=$id";

I hope I have given you enough info.

Thanks in advance for any help.


11:54 am on Mar 4, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Is this on a local machine or on a host? Are you connecting with a user/password that has appropriate permissions?

> SET user='$username',password='$password' WHERE id=$id

Try putting $id in single quotes, although again this could be a permissions issue...


12:10 pm on Mar 4, 2002 (gmt 0)

all the permissions are ok, I'm performing an INSERT earlier in the script


2:52 pm on Mar 4, 2002 (gmt 0)

10+ Year Member

Its been a while since I worked with mysql, but you might break it in to three steps.

$query = "SELECT password,email FROM table WHERE username = '$user' ";

$result= mysql_query($query) or
die ("your error message") ;

$myrow = mysql_fetch_array($result);

If that doesn't work it's possible (not sure) that you need to use variables other then "password" or "table" they could be confusing the system somewhere.


2:59 pm on Mar 4, 2002 (gmt 0)

10+ Year Member

Try it this way UK_matrix


// Set the variable $sql_select with a SQL query
$sql_select = "SELECT password,email FROM table WHERE username = '".$user."'";
// Execute the variable $sql_select and save it in the $result variable
$result = mysql_query ($sql_select);
// Grab results and drop into array
$myrow = mysql_fetch_array($result);


Let me know if this works.


3:10 pm on Mar 4, 2002 (gmt 0)

10+ Year Member

Try writing this Command this way.


$sql = "UPDATE table SET user='".$username."', password='".$password."' WHERE id=".$id;



4:09 pm on Mar 4, 2002 (gmt 0)


sorry... same error appears when I use that select code.


4:25 pm on Mar 4, 2002 (gmt 0)

10+ Year Member

Change the line with the $sql_insert variable to the one below. The bolded area is the changed code.


$sql_select = "SELECT password,email FROM table WHERE username=".$user;


Let me know if it helped.


4:35 pm on Mar 4, 2002 (gmt 0)


no joy... but please keep trying, I really appreciate you taking the time to help me :)

Is there anything I can send you that may help ?


4:58 pm on Mar 4, 2002 (gmt 0)

10+ Year Member

I've tried it both ways and it works fine with me. Check and see your variables. Also are you setting the variable $user to a value already in the DB or not?

Send me code if you can at my email. It's in the profile stuff.

And your welcome. Glad to be of help. ;)


3:28 pm on Mar 6, 2002 (gmt 0)

10+ Year Member

Did resolve the problem?


3:53 pm on Mar 6, 2002 (gmt 0)

Yes thanks.... I've got a few more now !
Every time I try and do more complicated stuff I find myself hitting harder problems :)


4:04 pm on Mar 6, 2002 (gmt 0)

10+ Year Member

It's good to hear you got it working. How did you end up fixing it? Just curious cause most of the stuff I tried would work. Was it a server issue or db problem?

Again, if I can be of help in anything else, all you gotta do is ask.


4:11 pm on Mar 6, 2002 (gmt 0)

$result = mysql_query("select * from table where username = '$username'",$db);

this works, I think I had the field names the wrong way round :)

Thanks for all your help.


Featured Threads

Hot Threads This Week

Hot Threads This Month