0

I have a mysql table with Arabic data. The data looked like

شقة تمليك بموقع متميز

in the database.

When I make a query as:

select * 
from table 
where tit = "arabic letters"

It's give me the following error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\LocalHost\Websites\Megadiv_Clients\immes_Realestate\website\admin\tours.php on line 1437

Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164
Bassem Aiad
  • 149
  • 1
  • 1
  • 9

2 Answers2

0

Mysql_num_rows requires a mysql resource (i.e. a query result).

Are you passing it a resource, or just a string?

It should be: mysql_num_rows(mysql_query("SELECT ... "));

Note: use of the mysql extension is discouraged, in favor of mysqli.

Benno
  • 3,008
  • 3
  • 26
  • 41
  • mysql_num_rows is not my problem, my problem is that i want to write the following query $x=mysql_query("select * from table where title='كلام نموذج'"); $y=mysql_num_rows($x); – Bassem Aiad Sep 30 '12 at 15:31
  • 1
    Hmmm, are you able to run that query in phpmyadmin or something? It could be a charset issue between your webserver/files and db causing issues making the query not get executed correctly maybe? – Benno Sep 30 '12 at 15:35
  • Hmm, then would it be something perhaps in php.ini to do with the charset? Is your charset correct? PhpMyAdmin may have a different charset, enabling you to do the search (i.e. where your site might scramble the arabic). Would you need UTF8 or unicode? or is unicode utf8? I'm not sure on the specifics! You can check your default_charset value in php.ini or `` i think – Benno Oct 03 '12 at 08:04
0

If mysql_query fails for some reason it returns FALSE instead of a resultset, and you can't use num_rows. You can call mysql_error() to find out what the error was. For example:

$x=mysql_query("select * from table where title='كلام نموذج'");
if (!$x) {
    die("Error from MySQL: ".mysql_error());
}
$y=mysql_num_rows($x);
Joni
  • 108,737
  • 14
  • 143
  • 193