Author Topic: New server - suddenly argument is not a valid MySQL result  (Read 378 times)

Jon Norris

  • Guest
New server - suddenly argument is not a valid MySQL result
« on: September 02, 2010, 12:15:08 PM »
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 >>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<<
[/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)); <<
[/color]The >>SELECT * FROM....etc<< works fine as a query on its own in phpMyAdmin so it seems to be the num_rows function.
[/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.
[/color]Both servers are pretty identical - one runs MySQL Server version: 5.0.90-community and the new one runs 5.91
[/size]I believe they are both running PHP5 though not sure through cpanel where to find this out.
[/size]
[/size]Help, please!
[/color]

phphelp

  • Administrator
  • Senior Member
  • *****
  • Posts: 780
  • Karma: +3/-0
    • View Profile
    • PHP Help forum
Re: New server - suddenly argument is not a valid MySQL result
« Reply #1 on: September 02, 2010, 01:30:41 PM »
Try to debug to see MySQL error message. Do this:

PHP Code: [Select]
mysql_query("SELECT * FROM books  WHERE keywords LIKE '%ancient%' AND keywords LIKE '%history%' AND status <> 'sold' ORDER BY author "$eg_objConn1);
echo 
mysql_error();

Are you experienced in PHP programming and willing to share your knowledge?
Join us at php help forum!

jnorris235

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: New server - suddenly argument is not a valid MySQL result
« Reply #2 on: September 03, 2010, 04:29:20 AM »
Read books and all - didn't know that statement!
Thank you - it gave the response:
No database selected
[/color]
[/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]