Click to See Complete Forum and Search --> : strange error...


Da Warriah
08-30-2003, 08:27 PM
im trying to get some info from a database to check whether a user has the right name and password...however, for some reason, it doesnt want to work for me...can anyone spot an error in my script? cause ive looked it over about 50 times and cant see anything:(

<?php

require_once "connect.php";

$sql = mysql_query(
"SELECT ID, user FROM users WHERE user='uploads'"
);

while($row = mysql_fetch_array($sql)){
print $row["ID"].$row["user"];
}

mysql_free_result($sql);

?>

i know the error is NOT in connect.php (with all the info to connect to the database)...and i know theres a user in there called "uploads"....but every time i run the script, i get this:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/strictly/public_html/sd/imagehost/dbsetup.php on line 9

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/strictly/public_html/sd/imagehost/dbsetup.php on line 13

can anyone help me with this? im stumped...i cant figure out why the heck it isnt working...:(

Khalid Ali
08-31-2003, 07:35 AM
I think(could be wrong on big scale..:D )



you do not necessarily have to have this statement
mysql_free_result($sql);

I read somewhere that php will garbage collect all the unsed reources regardless,so for now until when you get a reason why u are getting this error,just scrap it..:p

Da Warriah
08-31-2003, 08:09 AM
ok, thanx im still working on learning the mySQL functions in PHP (along with sessions at the same time, lol)...it seems to me that i commented that out tho and i still got the first error...maybe ill try using mysql_fetch_row() instead, tho that shouldnt make any difference, should it?

Khalid Ali
08-31-2003, 10:58 AM
sorry I miss read it ,I fyou are getting error in fetch array then deffinitley there si something wrong with your query.

Here is what I always do before I put a query in php

start mysql from the dos prompt.
and then log into the db u are using and
try your query there if it returns data u r agood to go else..:-)

and as long as you are in development mode you should use

mysql_query($query) or die(mysql_error());
this will give you the error

Da Warriah
08-31-2003, 08:36 PM
hmm...might work if i actually had access to the server, and knew how to do it, lol...

anyways, yeah i kinda made the script in a hurry (its just a very stripped-down version of what im ACTUALLY trying to do...), so ill put in the mysql_error() and see what it brings up...thanx...;)