Ask a Question related to PHP Development, Design and Development.
-
Georges.Kuntz #1
script blocks on $news=mysql_fetch_array($result);
Hi,
Why my script blocks on : $news=mysql_fetch_array($result); ?
It seems to work properly in other sites (emplacements), The table
(lagreze_frontpage) existst and also in the right base...
************************************************** ********
<?
$query2="SELECT * FROM lagreze_frontpage WHERE id=$n";
$result=mysql_query($query2, $connect);
$news=mysql_fetch_array($result);
if ($lFormatDate=="fr")
{
list($y,$m,$d) = explode("-",$news['date']);
$sep= "-";
$news['date'] = $d.$sep.$m.$sep.$y;
}
?>
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in c:\program files\easyphp\www\lagreze\site\index.php on line 52
Georges.kuntz
Georges.Kuntz Guest
-
webservice result cause script timeout
Hi all. I use a webservice component to connect to our webservice. The data i get is passed to a dataholder and then i update my variables! In... -
Output from the result of a .sh-script
Hi, I'm all new to this (actually to this whole "scripting thing"). I am familiar to programming in general (Turbo Pascal (those were the days... -
Do BEGIN blocks and END blocks have priority?
If I create code with: BEGIN { # something BEGIN { # something else } } -
simple news script help
hi, i hope someone can help. Im pretty new to this php stuff and i have a slight problem. I have this script (shown below) which writes data to a... -
#24615 [Opn->Bgs]: mysql_fetch_array error The result type should be either MYSQL_NUM, MYSQL_ASSO
ID: 24615 Updated by: philip@php.net Reported By: prohm at cypos dot de -Status: Open +Status: Bogus... -
Alvaro G Vicario #2
Re: script blocks on $news=mysql_fetch_array($result);
*** Georges.Kuntz wrote/escribió (Fri, 8 Oct 2004 11:49:02 +0200):
You take it for granted that mysql_query() always returns a valid result.> $result=mysql_query($query2, $connect);
> $news=mysql_fetch_array($result);
This is what man says:
"Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query() returns
a resource identifier or FALSE if the query was not executed correctly. For
other type of SQL statements, mysql_query() returns TRUE on success and
FALSE on error. A non-FALSE return value means that the query was legal and
could be executed by the server."
What if your query fails? $result will be FALSE and then:
"Usage: array mysql_fetch_array ( resource result [, int result_type ] )"
The first argument for mysql_fetch_array() must a resource result, not a
boolean value. Thus the error.
To sum up: do error checking.
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Alvaro G Vicario Guest
-
Georges.Kuntz #3
Re: script blocks on $news=mysql_fetch_array($result);
I think I have understood.
Thanks for the answer.
Georges
"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> a écrit
dans le message de news:1geaevevux0zb$.z5o19kyavswt$.dlg@40tude.net.. .For> *** Georges.Kuntz wrote/escribió (Fri, 8 Oct 2004 11:49:02 +0200):>> > $result=mysql_query($query2, $connect);
> > $news=mysql_fetch_array($result);
> You take it for granted that mysql_query() always returns a valid result.
> This is what man says:
>
> "Only for SELECT,SHOW,EXPLAIN or DESCRIBE statements mysql_query() returns
> a resource identifier or FALSE if the query was not executed correctly.and> other type of SQL statements, mysql_query() returns TRUE on success and
> FALSE on error. A non-FALSE return value means that the query was legal> could be executed by the server."
>
> What if your query fails? $result will be FALSE and then:
>
> "Usage: array mysql_fetch_array ( resource result [, int result_type ] )"
>
> The first argument for mysql_fetch_array() must a resource result, not a
> boolean value. Thus the error.
>
>
> To sum up: do error checking.
>
>
> --
> -- Álvaro G. Vicario - Burgos, Spain
> -- Thank you for not e-mailing me your questions
> --
Georges.Kuntz Guest



Reply With Quote

