9 Replies - 4354 Views - Last Post: 25 December 2012 - 11:04 AM Rate Topic: -----

#1 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

Warning: mysql_num_rows()

Posted 25 December 2012 - 10:36 AM

errors:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\E_COMMERCE\MENU_PAGES\zoom.php on line 83




$view_query = mysql_query("SELECT ip_address FROM view WHERE ip_address = $user_ip");
$query_count_row = mysql_num_rows($view_query); //line 83



Is This A Good Question/Topic? 0
  • +

Replies To: Warning: mysql_num_rows()

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9258
  • View blog
  • Posts: 34,735
  • Joined: 12-June 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:38 AM

Where's the connection (mysql_connect) in the typical "mysql_query" call? Also you should be flipping over to PDO.
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,236
  • Joined: 27-December 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:40 AM

We've already answered your question on this same problem.

@modi123_1: We've advised this user to do that a lot. He refuses to adhere to good practices or really bother reading the replies, I feel like.
Was This Post Helpful? 2
  • +
  • -

#4 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:41 AM

i have mysql_connect top of the page. line 1 works fine. but the bottom on doesnt work.

Quote

We've already answered your question on this same problem.

i might be wrong but i didnt find the answer there.

This post has been edited by hwoarang69: 25 December 2012 - 10:45 AM

Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,236
  • Joined: 27-December 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:44 AM

What does the mysql_error() function return after your query? And seriously- please start reading the links provided to you. We provide links because they are relevant and helpful. It saves your time, and it doesn't waste ours debugging by proxy. Put a little bit of effort into helping yourself too.
Was This Post Helpful? 0
  • +
  • -

#6 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:47 AM

Quote

please start reading the links provided to you

i have read it. and did every thing at the link. but wasnt working.


ps if you dont want to help that fine. just ignore the post.

This post has been edited by hwoarang69: 25 December 2012 - 10:48 AM

Was This Post Helpful? -1
  • +
  • -

#7 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10595
  • View blog
  • Posts: 39,236
  • Joined: 27-December 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:48 AM

The question still stands- what does the mysql_error() function return. If you refuse to switch over to PDO or MySQLi, at least check to see if you have errors with your mysql_query() call.

Quote

ps if you dont want to help that fine. just ignore the post.

Just because you don't like the advise doesn't make it relevant.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9258
  • View blog
  • Posts: 34,735
  • Joined: 12-June 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 10:49 AM

Quote

i have mysql_connect top of the page. line 1 works fine. but the bottom on doesnt work.

Ah.. typically good information to know versus a single two lines of out of context code.

As it is.. column datatypes (ip_address)... what are they? Is it a varchar? A number? Since you are not using parametrized queries (which, as it is, you should be) you need to be aware of things like needing to put tick marks around strings when comparing them against columns.

SELECT ip_address FROM view WHERE ip_address = $user_ip

Was This Post Helpful? 2
  • +
  • -

#9 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 11:01 AM

ip_address is varchar. i think that is the problem bc $user_ip is int.

i was getting user_ip by
 $user_ip = $_SERVER['REMOTE_ADDR']; 

Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9258
  • View blog
  • Posts: 34,735
  • Joined: 12-June 08

Re: Warning: mysql_num_rows()

Posted 25 December 2012 - 11:04 AM

You think? Hmmmm.. sounds like someone needs to investigate, apply some debugging skills, and *MAKE SURE* what your datatypes are. Lord knows that's always a tangled mess when new kids (on the block) wave their hands and assume. ;)
Was This Post Helpful? 4
  • +
  • -

Page 1 of 1