Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    Retrive Link from the Mysql with ID

    Hello

    If i have a URL Saved in my Mysql table , lets Say like

    http://locahost

    and i need to Put a small Image with href when User Clicks it , Take Him to the URL but instaed Print Out the Actual link i need to mask it with the ID of the Link .. like

    http://localhost/getfile.php?=1

    where 1 = http://locahost

    This Example i need to Fix
    PHP Code:
    mysql_connect("localhost""root""12") or die(mysql_error()) ;
    mysql_select_db("test") or die(mysql_error()) ;

    $data mysql_query("SELECT * FROM links WHERE id='$id'") or die(mysql_error());
    while(
    $info mysql_fetch_array$data ))
    {
    Echo 
    "<b>Download Link </b> <a href='getfile.php?id=$id'><img src='download.jpg' width='22' height='16'></a> ".$info['link'] . "<br> ";

    Last edited by ajloun; 02-24-2010 at 05:49 AM.

  • #2
    Regular Coder
    Join Date
    Jan 2010
    Posts
    101
    Thanks
    17
    Thanked 5 Times in 5 Posts
    PHP Code:
    mysql_connect("localhost""root""12") or die(mysql_error());
    mysql_select_db("test") or die(mysql_error());
    $id mysql_real_escape_string($_GET['id']);
    $data mysql_query("SELECT * FROM links WHERE id = '$id'") or die(mysql_error());
    while(
    $info mysql_fetch_array($data)){
    echo(
    "<b>Download Link</b> <a href='getfile.php?id=$id'><img src='download.jpg' width='22' height='16'></a> ".$info['link'] . "<br> ");

    That should work - you almost had it right, but forgot to retrieve the ID from the URI, and remember that you should secure the input.

    Get the link like this: http://localhost/getfile.php?id=1

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thank you ..


  •  

    Posting Permissions

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