/    Sign up×
Community /Pin to ProfileBookmark

strange error…

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?

[code=php]<?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);

?>[/code]

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:

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

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

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 31.2003 — I think(could be wrong on big scale..? )



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
Copy linkTweet thisAlerts:
@Da_WarriahauthorAug 31.2003 — 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?
Copy linkTweet thisAlerts:
@Khalid_AliAug 31.2003 — 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
Copy linkTweet thisAlerts:
@Da_WarriahauthorSep 01.2003 — 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...?
×

Success!

Help @Da_Warriah spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...