Page 1 of 1
not a valid MySQL result... What's wrong with my code?
Posted: Mon Aug 21, 2006 8:11 am
by SteveMellor
This should be simple stuff and I'm probably missing something obvious (can't see the wood for the trees sort of thing) but all help is appreciated. I have a block of code that I am using for connection:
Code: Select all
mysql_select_db($database_dggb, $dggb);
$query_member = "SELECT * FROM `membersBenefits` WHERE `active` = '1' ORDER BY `order` Asc";
$member = mysql_query($query_member, $dggb);
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);
There is definately a table called 'membersBenefits'. It definately has a field called 'active'. This connection works perfectly fine on my local server. I have just uploaded it and found the following error.
Code: Select all
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in join.php on line 28
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in join.php on line 29
My question of course is... what have I done wrong?
Posted: Mon Aug 21, 2006 8:34 am
by Benjamin
See what this gives you..
Code: Select all
mysql_select_db($database_dggb, $dggb);
$query_member = "SELECT * FROM `membersBenefits` WHERE `active` = '1' ORDER BY `order` Asc";
$member = mysql_query($query_member, $dggb);
echo "The error is " . mysql_error();
$row_member = mysql_fetch_assoc($member);
$totalRows_member = mysql_num_rows($member);
Posted: Mon Aug 21, 2006 9:03 am
by SteveMellor
I am getting
The error is
nothing else.
Posted: Mon Aug 21, 2006 9:14 am
by Benjamin
mysql_error() returns an empty string when there isn't an error, so this makes it a little confusing. Did you post your actual code?
Posted: Mon Aug 21, 2006 9:24 am
by jayshields
Have you got any rows in the table?
Posted: Mon Aug 21, 2006 9:24 am
by SteveMellor
yep, that's it, and you can see it happening on the page
http://ns7.sovdns.com/~dggborg/test/join.php.
The fact that there was no SQL error was what through me in the first instance. I thought it was a problem with the database but I can log into my PHPMyAdmin panel and see the table it's looking for. If you have a look through the rest of the site, (even though there's no data there at the moment) the same block of text has been used to connect the other pages and they work perfectly well.
The other thing that is so confusing is that it's running perfectly fine on my localhost.
Posted: Mon Aug 21, 2006 9:26 am
by SteveMellor
jayshields wrote:Have you got any rows in the table?
Yep, there are 9 records in there.
Posted: Mon Aug 21, 2006 9:29 am
by Benjamin
Try this to see if it's the query..
Code: Select all
$query_member = "SELECT * FROM `membersBenefits`";
Posted: Mon Aug 21, 2006 9:39 am
by SteveMellor
astions wrote:Try this to see if it's the query..
Code: Select all
$query_member = "SELECT * FROM `membersBenefits`";
Still getting it so I assume there is a problem with the table. I'm going to try droping it and puting the data in again.
Posted: Mon Aug 21, 2006 9:41 am
by SteveMellor
Still no luck I'm afraid.
Posted: Mon Aug 21, 2006 9:43 am
by Benjamin
Is the name of your database membersBenefits by chance?
Posted: Mon Aug 21, 2006 9:49 am
by SteveMellor
astions wrote:Is the name of your database membersBenefits by chance?
Nope.
Posted: Mon Aug 21, 2006 10:06 am
by SteveMellor
I have solved it. Well, solved is not technically right. I have found a way around the problem by creating a new table (called 'memben') and dumping the data in that.
I have no idea why this happened and no idea what fixed it, but thanks to everyone (especially astions) who took an interest and at least tried to help
