About PHP::: Error/Problem PHP Warning: mysql_fetch_array():

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pratchaya

    About PHP::: Error/Problem PHP Warning: mysql_fetch_array():

    Hi Everyone

    =============== =============== =============== =============== ==
    About PHP::: Error/Problem PHP Warning: mysql_fetch_arr ay():
    =============== =============== =============== =============== ==

    In the past i use my code/script work fine with
    Mandrake 9.1 - 10.1 ( + apache ,mysql )

    Now i move to redhat EL4 with the same code/script

    I got error can't login to my code.
    and found error on /var/log/httpd/error_log like this

    PHP Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
    result resource in /var/www/html/website_in_serv er/showdata.php

    or

    PHP Warning: mysql_fetch_arr ay(): supplied argument is not a valid
    MySQL result resource in /var/www/html/website_in_serv er/showdata.php


    I think problem source from php.ini or httpd.conf .

    Anyone can help me sir.. ?

    thank you for advance

  • Andy Hassall

    #2
    Re: About PHP::: Error/Problem PHP Warning: mysql_fetch_arr ay():

    On 25 Jul 2005 12:11:19 -0700, "Pratchaya" <pratchaya@bana na.co.th> wrote:
    [color=blue]
    >============== =============== =============== =============== ===
    >About PHP::: Error/Problem PHP Warning: mysql_fetch_arr ay():
    >============== =============== =============== =============== ===
    >
    >In the past i use my code/script work fine with
    >Mandrake 9.1 - 10.1 ( + apache ,mysql )
    >
    >Now i move to redhat EL4 with the same code/script
    >
    >I got error can't login to my code.
    >and found error on /var/log/httpd/error_log like this
    >
    >PHP Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
    >result resource in /var/www/html/website_in_serv er/showdata.php[/color]

    This means you did not check whether a previous mysql_* call (probably
    mysql_query) was successful, and you continued anyway despite receiving "false"
    as the return value.
    [color=blue]
    >I think problem source from php.ini or httpd.conf .[/color]

    No, it's missing error handling in your showdata.php file.

    Check for whether the mysql_query call returned false - if it did, use
    mysql_error() to display the error.

    A simple way of doing this is:

    $result = mysql_query($sq l)
    or die(mysql_error ());

    This is not very user friendly, but it does stop the script going any further
    past an error, and tells you what the error is.

    Once you've got that sorted you would be better off changing it to present a
    more user friendly message rather than the raw underlying error.

    If you don't understand the error that the mysql_error() function produces
    here, then post that error back again, with a _short_ extract of the code
    around the error, and someone here may be able to help you with the actual
    problem.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • Michael Phipps

      #3
      Re: About PHP::: Error/Problem PHP Warning: mysql_fetch_arr ay():

      > I got error can't login to my code.[color=blue]
      > and found error on /var/log/httpd/error_log like this[/color]

      Have your database login details changed?


      Comment

      • Pratchaya

        #4
        Re: About PHP::: Error/Problem PHP Warning: mysql_fetch_arr ay():

        No. sir

        it same both code and database sir.

        Comment

        Working...