script blocks on $news=mysql_fetch_array($result);

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. Do BEGIN blocks and END blocks have priority?
      If I create code with: BEGIN { # something BEGIN { # something else } }
    4. 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...
    5. #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...
  3. #2

    Default Re: script blocks on $news=mysql_fetch_array($result);

    *** 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. 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

  4. #3

    Default 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.. .
    > *** 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.
    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
    > --

    Georges.Kuntz Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139