Any help please?

Discussion in 'PHP' started by ollyno1uk, Nov 25, 2007.

  1. #1
    Hi

    I am trying to learn PHP. I've got a problem I cannot get my head around.

    I'm trying to copy over a script from one of my sites to another to function in exactly the same way. I have created the database etc and all is working ok apart from one aspect:

    This script inputs an image on a page based on a form.

    $target_path = "../ads_pic/"; 
    Code (markup):
    in the databse of the old site it inputs this as "ads_pic/imagename.jpg"

    In the new database it adds this as "../ads_pic/imagename.jpg"

    This means the actual image will not show as I get a url like this

    http://www.mydomain.com/..ads_pic/imagename.jpg

    Where am I going wrong?

    Thanks a lot and hope this makes sense
     
    ollyno1uk, Nov 25, 2007 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    hi

    you want it work with new one

    then store the script at the same level of images folder

    otherwise you have to make changes to db

    .. means parent directory ,if the script is in root or not at same level of images folder then it wont show

    obviously
    Regards

    Alex
     
    kmap, Nov 25, 2007 IP
  3. ollyno1uk

    ollyno1uk Active Member

    Messages:
    946
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #3
    thanks for coming back to me.

    Yes the image directory is the same. The form uploads the images to the correct directory no problem. It just seems to add the .. to the url whereas the old site did not add the .. to the actual url?
     
    ollyno1uk, Nov 25, 2007 IP
  4. SolarCat

    SolarCat Active Member

    Messages:
    100
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    88
    #4
    You're getting that bogus URL with the embedded ".." because somewhere in your script the site's root URL is being concatenated with the contents of the $target_path variable. Apparently on your original site the variable for the root URL contained an empty string, so you got a proper relative URL as a result. On your new site, the variable for the root contains "http://www.mysite.com/" (from your example), so you're getting that bogus result.

    Look for code that concatenates some variable with $target_path. In other words, $some_variable . $target_path, and you'll have the culprit. To preserve the relative URL, you'll want to eliminate the first part of that.

    I hope this helps.

    Steve
     
    SolarCat, Nov 25, 2007 IP
    ollyno1uk likes this.
  5. ollyno1uk

    ollyno1uk Active Member

    Messages:
    946
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    70
    #5
    Steve

    that is very kind and your explanation was easy to understand for even a complete newbie

    Thanks - rep added
     
    ollyno1uk, Nov 26, 2007 IP
  6. SolarCat

    SolarCat Active Member

    Messages:
    100
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    88
    #6
    You're welcome. Glad I could help.
     
    SolarCat, Nov 26, 2007 IP