mysql_result(): supplied argument is not a valid.....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bettina@coaster.ch

    mysql_result(): supplied argument is not a valid.....

    The program works local ok. The data were found in the datenbank and
    display by the program.
    When I wanted to test my program online, I get the following message:
    mysql_result(): supplied argument is not a valid MySQL result resource
    in ....

    this message several times for all the mysql_result... .

    The connection to the Datenbank seems to work because I didn't receive
    an error message..... that's the script for the connection:
    $db = @MYSQL_PCONNECT ($db_server,$db _user,$db_passw ort)
    or die ("Connection failed");
    $db_select = @MYSQL_SELECT_D B($db_name);


    Could it be that however the datenbank was not really connected?
    Because I cannot see it on my Provider Control Panel. Where should I
    put the Datenbank really? Under mysql/data... just like I have it local
    and it works fine?

    Any help will be welcomed.

  • kalenj@gmail.com

    #2
    Re: mysql_result(): supplied argument is not a valid.....

    might want to check to see what access priviledges your mysql user has
    on the database you're accessing. i know that access can be determined
    by the host. maybe your local computer has access but the live server
    you're working with doesn't. long shot but maybe.

    Comment

    • Tony

      #3
      Re: mysql_result(): supplied argument is not a valid.....

      bettina@coaster .ch wrote:[color=blue]
      > The program works local ok. The data were found in the datenbank and
      > display by the program.
      > When I wanted to test my program online, I get the following message:
      > mysql_result(): supplied argument is not a valid MySQL result resource
      > in ....
      >
      > this message several times for all the mysql_result... .
      >
      > The connection to the Datenbank seems to work because I didn't receive
      > an error message..... that's the script for the connection:
      > $db = @MYSQL_PCONNECT ($db_server,$db _user,$db_passw ort)
      > or die ("Connection failed");
      > $db_select = @MYSQL_SELECT_D B($db_name);[/color]

      That's the connection code, now what about the query code? That's where the
      error probably is.

      The error you're getting means that you're trying to access a query result
      that hasn't been set. Be sure you're assigning the result of mysql_query()
      to a variable, and double-check the variable spelling. My guess is that
      you're repeating the exact same error each time.

      --
      Tony Garcia
      Web Right! Development
      Riverside, CA



      Comment

      • bettina@coaster.ch

        #4
        Re: mysql_result(): supplied argument is not a valid.....

        here is my code:
        line 39 $total_1 = mysql_query("SE LECT COUNT(*) FROM COASTERS");
        line 40 $total_coasters = mysql_result($t otal_1,0,0);
        line 41 $total_2 = mysql_query("SE LECT COUNT(*) FROM COUNTRIES");
        line 42 $total_countrie s = mysql_result($t otal_2,0,0);
        line 43 $GET_DATE = mysql_query("SE LECT DATE_FORMAT(DAT E,'%d.%m.%Y')
        FROM COASTERS ORDER BY DATE DESC LIMIT 1");
        line 44 $update = mysql_result($G ET_DATE,0,0);

        I get errors on line 40, 42 and 44 and I'm only counting the records
        and getting the latest date,,, And what's strange is that it works
        local!!!!

        Comment

        • Andy Hassall

          #5
          Re: mysql_result(): supplied argument is not a valid.....

          On 12 Jul 2005 11:45:33 -0700, bettina@coaster .ch wrote:
          [color=blue]
          >When I wanted to test my program online, I get the following message:
          >mysql_result() : supplied argument is not a valid MySQL result resource
          >in ....[/color]

          This always means you didn't check a previous call for errors.

          Check every mysql_* call's return value.

          If false, use mysql_error() to print out an informative error, and stop.

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

          Comment

          • Jerry Stuckle

            #6
            Re: mysql_result(): supplied argument is not a valid.....

            bettina@coaster .ch wrote:[color=blue]
            > here is my code:
            > line 39 $total_1 = mysql_query("SE LECT COUNT(*) FROM COASTERS");
            > line 40 $total_coasters = mysql_result($t otal_1,0,0);
            > line 41 $total_2 = mysql_query("SE LECT COUNT(*) FROM COUNTRIES");
            > line 42 $total_countrie s = mysql_result($t otal_2,0,0);
            > line 43 $GET_DATE = mysql_query("SE LECT DATE_FORMAT(DAT E,'%d.%m.%Y')
            > FROM COASTERS ORDER BY DATE DESC LIMIT 1");
            > line 44 $update = mysql_result($G ET_DATE,0,0);
            >
            > I get errors on line 40, 42 and 44 and I'm only counting the records
            > and getting the latest date,,, And what's strange is that it works
            > local!!!!
            >[/color]

            When a query fails, mysql_query returns false. At that time you need to check
            the contents of mysql_error();

            Note you cannot just place the MySQL database files in a directory. That won't
            add it to MySQL's catalogs. You need to create the database and tables, then
            insert your data.

            phpMyAdMin will help you a lot with this process. It allows you to easily
            export your local database then import it to the one on the server.

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

            Comment

            • Tony

              #7
              Re: mysql_result(): supplied argument is not a valid.....

              bettina@coaster .ch wrote:[color=blue]
              > here is my code:
              > line 39 $total_1 = mysql_query("SE LECT COUNT(*) FROM COASTERS");
              > line 40 $total_coasters = mysql_result($t otal_1,0,0);
              > line 41 $total_2 = mysql_query("SE LECT COUNT(*) FROM COUNTRIES");
              > line 42 $total_countrie s = mysql_result($t otal_2,0,0);
              > line 43 $GET_DATE = mysql_query("SE LECT DATE_FORMAT(DAT E,'%d.%m.%Y')
              > FROM COASTERS ORDER BY DATE DESC LIMIT 1");
              > line 44 $update = mysql_result($G ET_DATE,0,0);
              >
              > I get errors on line 40, 42 and 44 and I'm only counting the records
              > and getting the latest date,,, And what's strange is that it works
              > local!!!![/color]

              As others have pointed out, you should be having some error checking:

              if (!$total_1) { print mysql_error(); }

              after line 39 (and one for $total_2 after line 41)- that would tell you why
              you're not getting a proper result back. Otherwise, it doesn't seem to be a
              code problem. Add the error checking & come back with the exact error
              message you get.

              --
              Tony Garcia
              Web Right! Development
              Riverside, CA



              Comment

              Working...