Results 1 to 11 of 11

Thread: Need help, php masters!

  1. #1
    HEXUS.social member Allen's Avatar
    Join Date
    Nov 2003
    Location
    Brighton
    Posts
    8,536
    Thanks
    363
    Thanked
    262 times in 168 posts
    • Allen's system
      • Motherboard:
      • ASUS Maximus VIII Gene
      • CPU:
      • Intel Core i5 6600K
      • Memory:
      • 2 x 8GB Kingston HyperX Predator DDR4-3000
      • Storage:
      • 256GB Samsung 950 PRO NVMe M.2 (OS) + 2 x 512GB Samsung 960 EVO in RAID 0 (Games)
      • Graphics card(s):
      • ASUS ROG Strix GeForce GTX 1080 Ti OC
      • PSU:
      • XFX P1-650X-NLG9 XXX 650W Modular
      • Case:
      • Fractal Design Node 804
      • Operating System:
      • Windows 10 Home 64-bit
      • Monitor(s):
      • 27" BenQ XL2730Z + 23" Dell U2311H
      • Internet:
      • Virgin Media 200Mbps

    Need help, php masters!

    Hello. I've got my site up and running now (what do you think?) and have a little problem with php coding. Now, I don't know jack s**t about it but have manage to find out a little bit so far.

    I have a screenshots page which has a few thuumbnails on it, and clicking on them opens up a new php page which displays the full picture. Now, I'm trying to add next and previous links above the image to move through the pics. The code I have at the moment to do this which obviously isn't working is:

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>FarCry Home :: Screenshots</title>
    <link rel="stylesheet" type="text/css" href="farcry.css" />
    </head>
    <body>
    <table width="760" align="center">
    <tr>
    <td>
    <p align="center"><img src="images/logo-FarCry.jpg" alt="FarCry"></p>
    <p align="center"><a href="index.html">Home</a> | 
    <a href="about.html">About FarCry</a> | Screenshots | 
    <a href="downloads.html">Downloads</a> | 
    <a href="modsmaps.html">Mods & Maps</a> | 
    <a href="forum.html">Forum</a> | <a href="comments.html">Comments</a></p>
    <p><img src="images/bar.jpg" /></p>
    <h1>Screenshots</h1>
    <p><img src="images/bar.jpg" /></p>
    <p align="center"><a href="screenshots.html">Back to thumbnails</a></p>
    <p align="center">

    <?php
    if(file_exists($img_dir.$iPrev.".jpg")) {
    print 
    '<a href="$PHP_SELF?im=$iPrev">Previous</a>';
    }
    ?>

    <?php
    if(file_exists($img_dir.$iPrev."jpg")) {
    print 
    '<a href="$PHP_SELF?im=$iNext">Next</a>';
    }
    ?>

    <?php
    $iCurr 
    $_GET["im"];
    $iPrev $iCurr 1;
    $iNext $iCurr 1;
    $img_dir './images/';
    ?>

    <?php 
    /* define IMG directory */
    $img_dir './screenshots/';

    echo 
    "<div><img src=\"".$img_dir.$_GET["im"].".jpg\" /></div>"
    ?>

    </p>

    </td>
    </tr>
    </table>
    </body>
    </html>
    As you can see, I'm a bit of a programming novice and the site is still very basic but I'd be appreciative of your help.

    Thanks in advance.



    :edit: What do you think of the way the forum integrates into the site? Does it look ok? How does it cope on other browsers?
    Last edited by Allen; 18-06-2004 at 08:26 PM. Reason: Width was stupid!

  2. #2
    Drop it like it's hot Howard's Avatar
    Join Date
    Jul 2003
    Location
    Surrey, South East
    Posts
    11,731
    Thanks
    14
    Thanked
    42 times in 39 posts
    • Howard's system
      • Motherboard:
      • Asus P5B
      • CPU:
      • Core2Duo E6420 2.13GHz
      • Memory:
      • 2x1gb OCZ DDR2 6400
      • Storage:
      • 250GB & 500GB Seagate
      • Graphics card(s):
      • Inno3d iChill 7900GS
      • PSU:
      • Antec SmartPower 500W
      • Case:
      • Coolermaster Elite 330
      • Monitor(s):
      • 2x AG Neovo F419
      • Internet:
      • Virgin Media 20mbit
    Dunno if it's any use but you could have the code for the screenshots on my site if you like Al?
    Home cinema: Toshiba 42XV555DB Full HD LCD | Onkyo TX-SR705 | NAD C352 | Monitor Audio Bronze B2 | Monitor Audio Bronze C | Monitor Audio Bronze BFX | Yamaha NSC120 | BK Monolith sub | Toshiba HD-EP35 HD-DVD | Samsung BD-P1400 BluRay Player | Pioneer DV-575 | Squeezebox3 | Virgin Media V+ Box
    PC: Asus P5B | Core2duo 2.13GHz | 2GB DDR2 PC6400 | Inno3d iChill 7900GS | Auzentech X-Plosion 7.1 | 250GB | 500GB | NEC DVDRW | Dual AG Neovo 19"
    HTPC: | Core2Duo E6420 2.13GHz | 2GB DDR2 | 250GBx2 | Radeon X1300 | Terratec Aureon 7.1 | Windows MCE 2005
    Laptop: 1.5GHz Centrino | 512MB | 60GB | 15" Wide TFT | Wifi | DVDRW


  3. #3
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    you're trying to print the next and previous links before you've defined the variables $iPrev and $iNext. In addition your next link is using $iPrev so it would never go to the next image anyway

  4. #4
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts
    The way I would do it is pass the image variable over the adrees, eg file.php?i=5 for the fifth image.

    Use that value as part of the string for the image that will be loaded. Then if image i + 1 (however you're naming them...) exists, show the next link, linking to file.php?i=6 and the opposite for the back link.

    Been a while since I did any serious PHP - and even then it was seriously comical.
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  5. #5
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    That's what he is doing Kez

  6. #6
    HEXUS webmaster Steve's Avatar
    Join Date
    Nov 2003
    Posts
    14,283
    Thanks
    293
    Thanked
    841 times in 476 posts
    Quote Originally Posted by Az
    That's what he is doing Kez
    Just testing...






    Actually, looking at it again, yeah, of course he is! Perhaps the structure is what threw me off. And where's the indentation? (My programming teacher says that all the time.)
    PHP Code:
    $s = new signature();
    $s->sarcasm()->intellect()->font('Courier New')->display(); 

  7. #7
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    in fairness to your teacher. White space is free and fantastically useful !

  8. #8
    HEXUS.social member Allen's Avatar
    Join Date
    Nov 2003
    Location
    Brighton
    Posts
    8,536
    Thanks
    363
    Thanked
    262 times in 168 posts
    • Allen's system
      • Motherboard:
      • ASUS Maximus VIII Gene
      • CPU:
      • Intel Core i5 6600K
      • Memory:
      • 2 x 8GB Kingston HyperX Predator DDR4-3000
      • Storage:
      • 256GB Samsung 950 PRO NVMe M.2 (OS) + 2 x 512GB Samsung 960 EVO in RAID 0 (Games)
      • Graphics card(s):
      • ASUS ROG Strix GeForce GTX 1080 Ti OC
      • PSU:
      • XFX P1-650X-NLG9 XXX 650W Modular
      • Case:
      • Fractal Design Node 804
      • Operating System:
      • Windows 10 Home 64-bit
      • Monitor(s):
      • 27" BenQ XL2730Z + 23" Dell U2311H
      • Internet:
      • Virgin Media 200Mbps
    Yeah, I got a lot to learn on php. To be honest, I haven't a clue what the above does, I was give the code by a friend.

    I've just bought PHP for Dummies!

  9. #9
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    good stuff !

    Having just made my blog completely in php (was raw html before) I think I have a decent handle on the standard web access to a db. The git is making it do fancy things like displaying 3 posts per page, and calculating the number of these pages for previous and next buttons.

    That and then trying to handle logged in session access to the update, edit and delete scripts. Managed both of these so far !

    NOW.. it is a case of trying to guard against attacks to the script ! So the site isn't going live til I am comfortable.

    Take it easy. And oh. I am stealerising the mouseover thingy on tables in your forum. For some reason when I googled for this.. I couldn't find it. Then I ALSO couldn't find a webpage that used this effect.

    Cheers !

  10. #10
    Member
    Join Date
    Jul 2003
    Posts
    77
    Thanks
    0
    Thanked
    0 times in 0 posts
    Quote Originally Posted by killgORE

    NOW.. it is a case of trying to guard against attacks to the script ! So the site isn't going live til I am comfortable.
    A couple of tips for you that I learnt the hard way:

    Make sure every script to do with adding/editing/deleting checks that the user is logged in.

    *Never* trust any form of input without validating it. If your expecting a number, then check that it is in fact a number your getting. If your using includes, then strip them of all dodgy characters to prevent people getting to places on your server they shouldn't via an include.

    And lastly if you're using a database for your authentication, look into SQL injection, as that's another great way for people to cause mischief.

    There's some excellent PHP security tutorials on the net, but also some equally bad ones, the best thing is to read as many as you can

  11. #11
    Commander Keen
    Join Date
    Nov 2003
    Location
    217.27.240.214
    Posts
    624
    Thanks
    0
    Thanked
    0 times in 0 posts
    Cheers. I have read so many of these darn tutorials now that the code was getting quite clunky. I think I might make some generic html.. sql etc 'cleaning' functions and then make them a standard include. calling each of them in turn on all vars. This should not be an include security risk.

    Well. so far I really went overboard on the sql injects. Was gutted then that some simple html tags in the message content could totally mess up the viewing page. So far I have not had time to cope with all the issues as I am preparing to graduate <- read I have been drunk as a drunk skunk.

    And this means that I also lose the web hosting in about 2 days... I think a mate of mine will host it temporarily. This gives me the mysql account that has stopped me going live with the scripts.

    But since this is just a stoopid personal website there is no deadlines to work for or anything so I can go live when I feel happy.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help With PHP Code
    By grand_witch in forum Software
    Replies: 5
    Last Post: 17-06-2004, 01:10 PM
  2. Learning PHP
    By Craig in forum Software
    Replies: 11
    Last Post: 22-03-2004, 03:10 AM
  3. adding php to w2k iis5?
    By joshwa in forum Software
    Replies: 13
    Last Post: 29-11-2003, 02:08 PM
  4. PHP and MySQL
    By Kezzer in forum Software
    Replies: 4
    Last Post: 28-10-2003, 02:59 PM
  5. Syntax Highlighting PHP Editor
    By Jonny M in forum Software
    Replies: 7
    Last Post: 11-09-2003, 10:43 AM

Posting Permissions

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