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

Posted by Jerry Stuckle on 12/17/93 11:55

Petr Vileta wrote:
> 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 ;-)
>

The code you showed should not display this error. Unfortunately, you
left out what's probably the most important piece - the line number of
the failing code.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

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

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