You are here: Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource « PHP Programming Language « IT news, forums, messages
Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource

Posted by Petr Vileta on 10/18/92 11:55

Hi, I'm new here and excuse me if this question was be here earlier.

I have a simple code

<html><body>
<?php
<?php
$link = mysql_connect("localhost", "user", "password")
or die("Grr: " . mysql_error());
mysql_select_db("my_dbf") or die("Grr");
$query = "select id from my_table where id < 4 order by id";
$result = mysql_query($query) or die("Grr: " . mysql_error());
$rows = mysql_num_rows($result);
echo "Rows=", $rows, "<br>" ;
list_it($result);

function list_it($result)
{
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo $row["id"], "<br>";
}
}
?>
</body></html>

This code produce this output:

Rows=3
1
2
3
Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource in
F:\webpub\php\test.php on line ...

Why warning?
This is a simple example. In my real code I must use a few different
functions for displaing mysql_fetch_array() result and $query variable I
must create before any html output because I use sessions.
How to pass resource type variable into function as parameter?
Oh, my PHP version is 4.3.7 on Windoze ;-)

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация