Submit Your Article Forum Rules

Results 1 to 4 of 4

Thread: URL stored in database keeps directing back to homepage

  1. #1
    Junior Member
    Join Date
    May 2011
    Location
    Aberdeen
    Posts
    4

    URL stored in database keeps directing back to homepage

    Hi There, Been stuck on this for a few days now and hoping someone can help me with this, I have links stored in a database which go to a PDF file, i.e.

    upun.co.uk/pdf/Industrial[/url] Terminal/Frame Screw Terminal/UFJ Series/PRODUCT1.pdf

    the site page the products are on is:
    upun.co.uk/UFJST.php[/url]

    the full link stored in the database: (this works if manullay entered into the address bar)
    upun.co.uk/pdf/Industrial[/url] Terminal/Frame Screw Terminal/UFJ Series/PRODUCT1.pdf


    once the PDF is loaded it displays this:

    upun.co.uk/pdf/Industrial%20T...s/PRODUCT1.pdf[/url]



    This is the PHP code i have to display the paginated data:

    // display data in table
    echo "<table border='0' cellpadding='5'>";
    echo "<tr><th>Product Image</th><th>Model No</th><th>Product PDF</th></tr>";

    // loop through results of database query, displaying them in the table
    for ($i = $start; $i < $end; $i++)
    {
    // make sure that PHP doesn't try to show results that don't exist
    if ($i == $total_results) { break; }

    // echo out the contents of each row into a table
    echo "<tr>";
    echo '<td><img src="' . mysql_result($result, $i, 'product_image') . '"/></td>';
    echo '<td>' . mysql_result($result, $i, 'model_no') . '</td>';
    echo "<td><a href='" . $row['product_pdf'] . "'>Product PDF Download</a></td>";
    echo "</tr>";
    }
    // close table>
    echo "</table>";


    hope this make sense!

  2. #2
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,780
    This could be wrong, but I suspect you may need to hard encode the spaces in the file name when you create it (or don't allow spaces, using dashes prevents issues of this type, if this is indeed the cause).

    "something%20like%20this.pdf"

  3. #3
    Junior Member
    Join Date
    May 2011
    Location
    Aberdeen
    Posts
    4
    Hi Everyone,

    just wanted to post the final solution for it working up:

    PHP Code:
    echo '<td><img src="' mysql_result($result$i'product_image') . '"/></td>';
    echo 
    '<td>' mysql_result($result$i'model_no') . '</td>';
    echo 
    "<td><a href='" .urlencode(mysql_result($result$i'product_pdf')) . "'>Product PDF Download</a></td>"
    thanks for the help!

  4. #4
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,780
    So it was the URL encoding, then, was it? Glad to see you have it worked out.

Posting Permissions

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