By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,044 Members | 1,248 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,044 IT Pros & Developers. It's quick & easy.

warning error message by using mysql_num in the mysql_fetch_array()

100+
P: 147
Hi,


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect('localhost','root','');
  3. mysql_select_db('test');
  4. $query="select * from phonedirectory";
  5. $result=mysql_query($query);
  6. echo "One Way To Print";
  7. echo "<br>";
  8. while($row=mysql_fetch_array($result,mysql_num))
  9. {
  10.    echo $row[0]." ".$row[1]." ".$row[2]."<br>";
  11. }
  12.  
  13. ?>

Warning Error Message:

One Way To Print

Warning: mysql_fetch_array() expects parameter 2 to be long, string given in F:\xampp installed\xampp\htdocs\mysql_fetch_demo1.php on line 8


thanks in advance.i dont know ,why am i facing this error
Mar 25 '10 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
PHP's constants are case-sensitive.

Expand|Select|Wrap|Line Numbers
  1. mysql_num != MYSQL_NUM
Turn on error reporting to find problems like these.

Expand|Select|Wrap|Line Numbers
  1. error_reporting(-1);
Mar 25 '10 #2

100+
P: 147
Thanks its working.....in php.ini file ,we should on ERROR_REPORTING(-1).Is it.
Mar 26 '10 #3

P: 1
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT Name,Mobile,Website,Rating FROM grand_table order by 4";
  2.  
  3.  
  4. // Passing Variables to execute and check
  5.  
  6. $result = mysql_query($query);
  7.  
  8. while( $data = mysql_fetch_array($result))
  9. {
  10.   echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td></tr>");
  11.  
  12.  }
Hope by this query you can solve up your error...
I was too suffering from that problem but instead of using regular sqlquery of WHERE i had replaced that and using ORDER BY and also its not necessary to use WHERE and ORDER BY query coz thats the query in which we are ordering and selecting a specified field...

Thanks
Jul 21 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.