Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2007
    Posts
    1,683
    Tokens
    0

    Latest Awards:

    Default Resource ID #7 (Not 17)

    PHP Code:
    $ham mysql_query("SELECT * from logs");
    echo 
    $ham
    I get resource #7 error, when I do this, the file is already connected to the MySQL Database, I'm trying to show all table records from logs.

    +REP for anyone who can help.

    But I have to goto school in a min.
    Last edited by Independent; 10-06-2008 at 07:01 AM.

  2. #2
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    $ham mysql_query("SELECT * from `logs`");
    while (
    $allrecords mysql_fetch_array($ham)){
    Print 
    "$allrecords[FIELDNAME]";

    It does a loop for each piece of data

    change the FIELDNAME to the fieldname you wish to display obviously

  3. #3
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    I'd change what jack put above:

    PHP Code:
    $mysqlQuery mysql_query'SELECT * from `logs`' );
    while ( 
    $r mysql_fetch_array$mysqlQuery ) )
    {
        echo ( 
    $r'fieldName' ] );

    Hi, names James. I am a web developer.

  4. #4
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Jahmes View Post
    I'd change what jack put above:

    PHP Code:
    $mysqlQuery mysql_query'SELECT * from `logs`' );
    while ( 
    $r mysql_fetch_array$mysqlQuery ) )
    {
        echo ( 
    $r'fieldName' ] );

    And I'd change what you used.
    PHP Code:
    $mysqlQuery mysql_query'SELECT * from `logs`' );
    while ( 
    false !== ( $r mysql_fetch_array$mysqlQuery ) ) )
    {
        echo( 
    $r'fieldName' ] );



    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  5. #5
    Join Date
    Dec 2007
    Posts
    1,683
    Tokens
    0

    Latest Awards:

    Default

    Ah I get it, thanks.. +REPing now.
    Last edited by Independent; 10-06-2008 at 03:09 PM.

  6. #6
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    PHP Code:
    $ham mysql_query("SELECT * from `logs`");
    while (
    $allrecords mysql_fetch_array($ham)){
    Print 
    "$allrecords[FIELDNAME]";

    It does a loop for each piece of data

    change the FIELDNAME to the fieldname you wish to display obviously
    stop using $var[var] it's alot slower unless you've defined FIELDNAME somewhere, use it as a string i.e: $var['var'] it works out something stupid like 5x faster.

    Quote Originally Posted by Minor View Post
    What one works to display every field in the table.
    Nether, you'd need to build some kind of foreach loop to go through, something like this:
    PHP Code:

    foreach( $fetch as $key => $var )
    {
        if(!
    is_numeric($key))
        {
            echo(
    $key ' - ' $var);
        }

    where $fetch is the mysql_fetch_array


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  7. #7
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Also Resource ID #* aren't errors, they're resources.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  8. #8
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jewish Bear View Post
    stop using $var[var] it's alot slower unless you've defined FIELDNAME somewhere, use it as a string i.e: $var['var'] it works out something stupid like 5x faster.
    I never knew that, cheers mate

  9. #9
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    You get them when you echo a mysql_query

Posting Permissions

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