Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mysql_fetch_array(): argument is not a valid

Status
Not open for further replies.

hotliquer

Programmer
Oct 5, 2005
7
GB
Hello

Can anyone tell me if the below php/mysql statement is wrong? When I run it on my server it gives me the error mysql_fetch_array(): supplied argument is not a valid MySQL result resource.
I have googled this problem to find out that i can put the '@' sign in front of mysql_fetch_array. This blocks the error out but still does not print out the variable I want it to! When I googled it I found so many errors the same. But none help me out!
The sql code works fine in phpmyadmin.
And I have checked the case on the text over and over.
My eyes are hurting from looking at the screen! Had to change my monitor background from blue to black!

Any ideas? I really am stuck with this!


$query = ("SELECT *
FROM cringeitwebsitequote
ORDER BY `__id` DESC
LIMIT 1 ");
while ($row = mysql_fetch_array($query)) {
$hosting = ( $row[hosting]); {
$pages = ( $row[pages]); {
$forms = ( $row[forms]); {
$cart = ( $row[cart]); {
$products = ( $row[products]); {
$logo = ( $row[logo]); {
$flash = ( $row[flash]); {
$dhtml = ( $row[dhtml]); {
$statistics = ( $row[statistics]); {
}}}}}}}}}}

print("$hosting");

This should just print the work 'No'

Thanks

Ben
 
What are all those curly (and round) brackets for? I know little about PHP, but I'd be surprised if they served any useful purpose. It's no wonder your eyes are hurting!
 
Well I cant believe that I wasted 3 maybe 4 hours burning my eyes when all i missed was 'mysql_query' from the sql query!!!

I posted the same question in 2 other forums too!!!

WOW!! how one can miss the most obvious thing!

Ben
 
You havent actually run the query, using the [blue]mysql_query()[/blue] function.

You have to run it before you can use a result. and even then it is not your query string but the result the function returns.

so it would be
$result=mysql_query($query);
and then you can use the mysql_fetch_array($result);

As for the {} curly braces, I have no idea what they are supposed to do, and am suprpised they dont produce erros.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I just took away the curly brackets and it still works!

do you think I can get away with getting rid of any more here??

I dont know where I picked up the habit from???

Why will itr still work with them all there??
 
Well Basically curly braces just wrap things. I'm surpirised it did not spit out syntax errors, but i guess as long as there are an equal number of opening braces as there are closing ones, PHP has no problems with them.

So removing thme all should cause absolutley no harm.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top