homepage Welcome to WebmasterWorld Guest from 54.227.56.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Two errors that are driving me mad ..please help
I'm afraid I'm losing it :)
UK_matrix




msg:1307781
 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.

 

sugarkane




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

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...

UK_matrix




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

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

David




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

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.

circuitjump




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

Try it this way UK_matrix

CODE
------------------------

// 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);

-----------------------
End CODE

Let me know if this works.

circuitjump




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

Try writing this Command this way.

CODE
-----------------------

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

------------------------
End CODE

UK_matrix




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

circuitjump,

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

circuitjump




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

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.

UK_matrix




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

circuitman,

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 ?

circuitjump




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

UK_Matrix,
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. ;)

circuitjump




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

UK_matrix,
Did resolve the problem?

UK_matrix




msg:1307792
 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 :)

circuitjump




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

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?

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

UK_matrix




msg:1307794
 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved