New server - suddenly argument is not a valid MySQL result

Hi and thanks for even reading this far!
My database driven book store works fine on my hosts server. I have just moved it to a new but very similar server and am getting >>[font=Times]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/anita/public_html/cat-ancient-history.php on line 7<<[/font]
[font=Times][/color]Line 7 says >>$eg_count = mysql_num_rows(mysql_query("SELECT * FROM books WHERE keywords LIKE ‘%ancient%’ AND keywords LIKE ‘%history%’ AND status <> ‘sold’ ORDER BY author ", $eg_objConn1)); <<[/font]
[font=Times][/color]The >>SELECT * FROM…etc<< works fine as a query on its own in phpMyAdmin so it seems to be the num_rows function.[/font]
[font=Times][/color]I split the statement into a query and then asked num_count to operate on that result rather than all in one line - but no luck.[/font]
[font=Times][/color]Both servers are pretty identical - one runs MySQL [/font][font=sans-serif][size=13px]Server version: 5.0.90-community and the new one runs 5.91[/size][/font]
[font=sans-serif][/size][size=13px]I believe they are both running PHP5 though not sure through cpanel where to find this out.[/size][size=13px][/font]
[font=sans-serif][/size][size=13px][/font]
[font=sans-serif][/size][size=13px]Help, please![/size][size=13px][/font]
[font=Times][/color][/font]

Try to debug to see MySQL error message. Do this:

[php]mysql_query("SELECT * FROM books WHERE keywords LIKE ‘%ancient%’ AND keywords LIKE ‘%history%’ AND status <> ‘sold’ ORDER BY author ", $eg_objConn1);
echo mysql_error();[/php]

Read books and all - didn’t know that statement!
Thank you - it gave the response:
[font=Times]No database selected[/font]
[font=Times][/color][/font]
[/color][font=times, ‘times new roman’, georgia, verdana, serif]Which prompted me to check everything. The second time I added the user I forgot to ADD to database in the rush.[/font][font=times, ‘times new roman’, georgia, verdana, serif]I feel very shamed and sorry I wasted peoples time. Your help did it though - so thanks![/font][color=rgb(85, 85, 85)]

Sponsor our Newsletter | Privacy Policy | Terms of Service