Results 1 to 8 of 8

Thread: php problem

  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default php problem

    I use this code all the time, but now its not working.
    There are 12 entries in the database, but for some reason its only selecting one.
    My code:
    PHP Code:
    <?php
        
    include("includes/config.php");
        
    $sql mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
        
    $fetch mysql_fetch_array($sql);
        
    $url $fetch["url"];
        
    $id $fetch["id"];
    echo(
    "<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
    ?>

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

    Latest Awards:

    Default

    Quote Originally Posted by Jack120 View Post
    I use this code all the time, but now its not working.
    There are 12 entries in the database, but for some reason its only selecting one.
    My code:
    PHP Code:
    <?php
        
    include("includes/config.php");
        
    $sql mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
        
    $fetch mysql_fetch_array($sql);
        
    $url $fetch["url"];
        
    $id $fetch["id"];
    echo(
    "<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
    ?>
    Try flush the database, then add them again.

  3. #3
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Close View Post
    Try flush the database, then add them again.
    Tried that, I also tried it on a different server.

  4. #4
    Join Date
    Jul 2007
    Location
    UK
    Posts
    2,470
    Tokens
    2,975

    Latest Awards:

    Default

    mabey if its suddely stopped working put the code in 12 times lol joke ..try a diffrent code is all i can say

  5. #5
    Join Date
    Jun 2005
    Posts
    2,688
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
        $sql mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
    while(
    $fetch=mysql_fetch_array($sql)){

    echo(
    "<a href=\"?page=view&id=$fetch[id]\"><img class=\"home\" src=\"images/uploads/$fetch[url]\" border=\"0\" width=\"170\" height=\"170\"></a>");

    Maybe what you're looking for if you are wanting to return more than 1 row

  6. #6
    Join Date
    May 2008
    Location
    Cheshire
    Posts
    133
    Tokens
    0

    Default

    Quote Originally Posted by 2fast2kwl View Post
    mabey if its suddely stopped working put the code in 12 times lol joke ..try a diffrent code is all i can say
    maybe if you suddenly replied you could CLICK HERE OR HERE OR HERE

    Edited by SyrupyMonkey (Forum Super Moderator): Please do not post rudely/act as a troll, thanks.
    Last edited by myke; 24-06-2008 at 08:27 PM.

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

    Latest Awards:

    Default

    Doms comment made me laugh lul - I think bavings ones near correct enough for you.

    Quote Originally Posted by Jack120 View Post
    I use this code all the time, but now its not working.
    There are 12 entries in the database, but for some reason its only selecting one.
    My code:
    PHP Code:
    <?php
        
    include("includes/config.php");
        
    $sql mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
        
    $fetch mysql_fetch_array($sql);
        
    $url $fetch["url"];
        
    $id $fetch["id"];
    echo(
    "<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
    ?>
    Hi, names James. I am a web developer.

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

    Latest Awards:

    Default

    Quote Originally Posted by Jack120 View Post
    I use this code all the time, but now its not working.
    There are 12 entries in the database, but for some reason its only selecting one.
    My code:
    PHP Code:
    <?php
        
    include("includes/config.php");
        
    $sql mysql_query("SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC");
        
    $fetch mysql_fetch_array($sql);
        
    $url $fetch["url"];
        
    $id $fetch["id"];
    echo(
    "<a href=\"?page=view&id=$id\"><img class=\"home\" src=\"images/uploads/$url\" border=\"0\" width=\"170\" height=\"170\"></a>");
    ?>
    PHP Code:
    <?php
    include( 'includes/config.php' );
    $sql mysql_query"SELECT * FROM `objects` WHERE `type` = 'image' ORDER BY `id` DESC" );
    while( 
    false !== ( $fetch mysql_fetch_array$sql ) ) )
    {
        echo( 
    '<a href="?page=view&id=' $id '"><img class="home" src="images/uploads/' $url '" border="0" width="170" height="170"></a>' );
    }
    ?>
    that would be the best way to go about it.


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

Posting Permissions

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