SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot p2ranger's Avatar
    Join Date
    Jan 2001
    Location
    Colorado, USA
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still learning PHP & MySQL. I tried dabbling with this little thing and got stuck.

    I have 12 cartoon pictures and I want to show one picture at a time. Click on next and previous to go through them. The names of the files are stored in MySQL database. I use PHP to call the name of the file as needed. Pretty simple I know.

    For some reason, the picture isn't loading after the initial page. I have it echoing the variables to see if they are passing correctly, and they are. The picture just isn't showing up.

    Here's the URL:
    http://anvilhead.dns2go.com/jason/cartoon/jake.php


    Here's the code:

    Code:
    <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
    <html>
    <head>
           <title>That's Jake cartoon series</title>
    </head>
    <body>
    
    <?php
    
    
    // connect to the database server
    $dbcnx = @mysql_connect("localhost", "root", "*****");
    if (!$dbcnx)
    {
        echo( "<p>Unable to connect to the database server at this time.</p>");
        exit();
    }
    
    // select the jakecartoon database
    if (! @mysql_select_db("jakecartoon") )
    {
        echo( "<p>Unable to conect to the database at this time</p>");
        exit();
    
    }
    echo(@$number);
    if (@$number > 12)
    {
    
    $number=1;
    }
    if (@$number <1)
    {
        $number=1;
    }
    
    
    
    
    $result = mysql_query("select filename from jake where id=$number");
    if (!$result)
    {
        echo("<p>Error performing querry: " . mysql_error() . "</p>");
        exit();
    }
    
    $row=mysql_fetch_array($result);
    echo("<p><img src='$row[0]'></p>");
    echo("filename=".$row[0]);
    
    $back=$number;
    $next=$number;
    
    $back--;
    echo("<br>back=".$back);
    
    $next++;
    echo("<br>next=".$next."<br>");
    
    //display next and previous for going backward and forrward
    echo("<p><a href='$PHP_SELF?number=$back'>" . "Previous</a></p>");
    echo("<p><a href='$PHP_SELF?number=$next'>" . "Next</a></p>");
    
    
    
    
    include "../../myserver_buttons.htm";
    
    ?>
    
    </body>
    </html>
    Thanks
    Jason
    ><>

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo("<p><img src='$row[0]'></p>");
    should be
    echo("<p><img src=\"$row[0]\"></p>");
    Shouldn't use single quote for IMG tag as well A HREF tag.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look at the URL of the second page:

    http://anvilhead.dns2go.com/php/php....e.php?number=2
    //anvilhead.dns2go.com/php/php.exe/jason/cartoon/jake.php?number=2

    According to the source for this page the image "jake-2.jpg" should be in this directory path:
    http://anvilhead.dns2go.com/php/php.exe/jason/cartoon/
    //anvilhead.dns2go.com/php/php.exe/jason/cartoon/

    But I poked around and found that the image is in fact here:
    http://anvilhead.dns2go.com/jason/cartoon/jake-2.jpg
    //anvilhead.dns2go.com/jason/cartoon/jake-2.jpg

    So sort out your path to the image.

    [edited - vB truncates the urls]
    Last edited by freakysid; Mar 1, 2001 at 20:30.

  4. #4
    SitePoint Zealot p2ranger's Avatar
    Join Date
    Jan 2001
    Location
    Colorado, USA
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool, Thanks to both of you

    Werks now

    Jason
    ><>

  5. #5
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did u upload the changes? Still not working when I go to the page.

  6. #6
    SitePoint Zealot p2ranger's Avatar
    Join Date
    Jan 2001
    Location
    Colorado, USA
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, I made the changes. It works from here anyway.

    THanks

    Jason
    ><>


Bookmarks

Posting Permissions

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