+ Reply to Thread
Results 1 to 8 of 8

Thread: Mysql fetch array?

  1. #1
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Mysql fetch array?

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/star/public_html/bunnygame/forums/loggedinas.php on line 7

    I get that in every code of mine that has that function. Does my version of PHP not support it?
    I need to use that function...

  2. #2
    adrenlinerush's Avatar
    adrenlinerush is offline x10 Lieutenant adrenlinerush is an unknown quantity at this point
    Join Date
    Nov 2007
    Location
    Monmouth, IL
    Posts
    379

    Re: Mysql fetch array?

    what version of php do you have?
    Austin Mount
    AAS, A+, Compaq/HP APS
    austin@adrenlinerush.net

  3. #3
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Mysql fetch array?

    PHP 5.2.4 - Intermediate Version

  4. #4
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Mysql fetch array?

    Does that mean ti doesn't support it? or?
    Help?

  5. #5
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Mysql fetch array?

    That means you're either not connected to the database OR you're retrieving an empty query.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  6. #6
    genki is offline x10Hosting Member genki is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    7

    Re: Mysql fetch array?

    It's most likely not a version issue. Most likely:

    1. Your script has not connected to the database in order to run the query
    or
    2. Your script connects to the database but there are no records (no data) that matches the query. In other words, you got an "empty" result set.

    To test #1, run the following code BEFORE any other code in your PHP script. If it's working okay, it should display "resource #14" or something like that.

    # Purpose: Establish a connection to the database
    #
    $dbname = 'your_database_name_here';
    $dbhost = 'localhost';
    $dbusername = 'your_username_here';
    $dbpassword = 'your_password_here';
    #
    $dbconnection = @mysql_connect($dbhost, $dbusername, $dbpassword);
    if ($dbname != '' && !@mysql_select_db($dbname)) {
    echo 'I could NOT connect to the database! Check the username, password, etc.';
    } else {
    echo 'I connected. The connection is: ' . $dbconnection;
    }


    To test #2, enter your query directly into phpMyAdmin and see what it tells you. It will say "0 records returned" or it will give you an error message. 0 records means the query was acceptable but no data matched your search. If you get an error, it means your query is broken and ya gots some fixin' to do!

    Does that help? (If yes, please click my reputation checkmark :-)
    Last edited by genki; 12-08-2007 at 01:17 AM.

  7. #7
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: Mysql fetch array?

    not my thread, but having the same problem, I did the first check and It says it connected. but my script still displays the error

  8. #8
    genki is offline x10Hosting Member genki is an unknown quantity at this point
    Join Date
    Dec 2007
    Posts
    7

    Re: Mysql fetch array?

    If your PHP script connects to the server, the problem is with your query-- either the query is invalid or there is no data that matches what you are asking for.

    To find out if the syntax of your query is okay, You can ask PHP to display errors by doing this:

    # Purpose: Establish a connection to the database
    #
    $dbname = 'your_database_name_here';
    $dbhost = 'localhost';
    $dbusername = 'your_username_here';
    $dbpassword = 'your_password_here';
    #
    $dbconnection = @mysql_connect($dbhost, $dbusername, $dbpassword);
    if ($dbname != '' && !@mysql_select_db($dbname)) {
    echo 'I could NOT connect to the database! Check the username, password, etc.';
    } else {
    echo 'I connected. The connection is: ' . $dbconnection;
    }

    // execute a search
    mysql_query("SELECT * FROM nonexistenttable", $dbconnection);
    // display the error number and error text
    echo mysql_errno($link) . " : " . mysql_error($link);

    BTW, the online PHP manual is here: http://www.php.net/manual/en/
    Last edited by genki; 12-14-2007 at 01:32 PM.

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. in here MySQL version????
    By winUSD in forum Free Hosting
    Replies: 4
    Last Post: 05-09-2006, 08:44 AM
  3. Can some1 tell me if this is the legal IF 2.0?
    By pensoftware in forum Computers & Technology
    Replies: 9
    Last Post: 04-05-2006, 12:33 PM
  4. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM
  5. Really Something Up
    By WeeRowan in forum Free Hosting
    Replies: 28
    Last Post: 12-19-2005, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers