1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Diffrences between localhost and a real server ??

Discussion in 'PHP' started by ypspiky, Jul 17, 2010.

  1. #1
    hi. i'm using xamppp for localhost. i have the page: ed.php . it contains a variable $val(this contains a simple html code). i want to echo this as a text and down as a preview for the code. ex: if $val='<b>this is a bold text</b>'; then up to echo this text and down to display the text but bolded
    -> for simple codes everything it's oke in localhost and on a real server (ex:size,align,color of a text)
    ->but ehne i want do dispaly an image : <img src=" .... on localhost works ,but on a real server DOESN'T ! i dont know why :( im sure that the image is corectly uploaded to server, because if a make a html page with only the code i put in $val, the browser displays the image. also from a link an image still doesn't displays
    -> The problem is why in localhost everything works oke but on server Doesn't ???
     
    ypspiky, Jul 17, 2010 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    localhost is your local machine... what do you mean real server? I have never seen a "fake" server before.
     
    Kaizoku, Jul 17, 2010 IP
  3. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i know is my local machine(then a virtual server,not "fake") i mean real server as 000php.com u register, make a subdomain, upload your files using,f.e., filezilla and then anyone from the world can acces the files(html and php pages) :)
     
    ypspiky, Jul 17, 2010 IP
  4. strgraphics

    strgraphics Active Member

    Messages:
    710
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    localhost is just like our computer drive.., we can use with in our system, and real server means we can access through out the globe..!!
     
    strgraphics, Jul 17, 2010 IP
  5. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes i know this ! the problem is why in xampp my page works fine and on a real server doesn't. i wrote up what's the problem ... Maybe i didnt wrote the right title(my mistake sorry..) I meant to say whats the diffrences when a php code runs on localhost and on a server(i thought it's the same, but then why i get a diffrent result on a server ? )
     
    ypspiky, Jul 17, 2010 IP
  6. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #6
    Perhaps show us your code? FYI, image source can be relative and absolute. Maybe your image source is beyond the scope of your virtual directory, that's why remotely it cannot access it, but locally it can.
     
    Kaizoku, Jul 17, 2010 IP
  7. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #7
    There shouldn't have any difference when you run a PHP code on localhost or the "real server" - if any, there could be a number of reasons such as the version your PHP is running, programs or settings of your server that may affect its performance, wrong or different configuration, etc, etc. But the bottom line is, they are totally the same and they should run the same.
     
    Rainulf, Jul 17, 2010 IP
  8. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If i wouldn't have uploaded the image or it must or i dindt wrote the right extension ,then why if i make a new html page which contains the same html code as $val contains it displays the image ??? :(( sorry for bad english
     
    ypspiky, Jul 17, 2010 IP
  9. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i don't know what to say.....I just dont understand how such a simple php code doesn't works
     
    ypspiky, Jul 17, 2010 IP
  10. adamsinfo

    adamsinfo Greenhorn

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #10
    I don't fully understand what you're asking, but I think you're suggesting that images and links that work on your local PC don't work when you upload your site. Is this correct? If so, you need to check the PATH of your images. Chances are, they are either 'relative', i.e. images\myimage.jpg or full paths, i.e. c:\windows\desktop\images\.. What you actually want is an absolute path to your image relative to the base path. If your site is http://www.domain.com/mysite/myimages/image.jpg I would suggest you use /mysite/myimages/image.jpg as the image path.
     
    adamsinfo, Jul 17, 2010 IP
  11. tommykent1210

    tommykent1210 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Show us your code and we can probably help better.


    For example if your script is stored in a folder called "public_html", and in that folder you have another folder named "images" with the "image1.jpg" (or whatever) in. Then on XAMMP it would be:

    $image="C:\xammp\www\images\image1.jpg" however, when you upload that to your "real" server, it will most probably be running linux. Thus it will look for the image in a folder tree named: C:\xammp\www\images\image1.jpg, however this wont exist.

    So like the other posts said, you should make $image = "/images/image1.jpg" This means nomatter what the folder tree is like (linux or windows) it will look i the subfolder "images" for the "imag1.jpg". :) Hope this helps
     
    tommykent1210, Jul 17, 2010 IP
  12. caciocode

    caciocode Peon

    Messages:
    65
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    The configuration difference, maybe. If both PHP versions are similar then they should work fine.

    Change the image base directory to the domain name of your server, youcould be using http://localhost/image.png while on your web host it's http://example.com/image.png.
     
    caciocode, Jul 17, 2010 IP
  13. tommykent1210

    tommykent1210 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    The best thing to do, as i and another said, would be to refer to images as "/image.png" or "/images/image.png", removing the need to predefine the URL :)
     
    tommykent1210, Jul 17, 2010 IP
  14. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Fist:thanxs guys for helping me.
    i uploaded the files ed.php , danger.gif, test.html on the 000.php server.
    In ed.php is a variable : $var='<html>
    <body><h2>Norwegian</h2>
    <img border="0" src="danger.gif" alt="Pulpit rock" width="304" height="228" />
    </body> </html>';
    i first want to display my text as it is. it works on localhost and server(its a textarea which receive the value of $val ). i think until here its clear
    then down i have the code: echo $val; (to make a preview in the page of the code) It works fine with text tags(size font ..) lists..
    - the problem is with that image (danger.gif). When i open the ed.php page everything it's oke with other tags(for example :it displays corectly the text "norwegian" with the size specific of the h2 html tag), but the image doesn't. the internet explorer or chrome show instead the image a small icon which indicates that hadn't found the image ...
    - maybe i didnt upload the image well, but why the test.html which contains exactly the value of the $val it displays corectly the image in my browser ?
    i mention that ed.php, dager.gif , test.html are in the same folder. i think now its clear what's my problem. again sorry for bad english
     
    ypspiky, Jul 17, 2010 IP
  15. tommykent1210

    tommykent1210 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Change:
    $var='<html>
    <body><h2>Norwegian</h2>
    <img border="0" src="danger.gif" alt="Pulpit rock" width="304" height="228" />
    </body> </html>';
    PHP:
    to:
    
    $var='<html>
    <body><h2>Norwegian</h2>
    <img border=\"0\" src=\"/danger.gif\" alt=\"Pulpit rock\" width=\"304\" height=\"228\" />
    </body> </html>';
    PHP:
     
    tommykent1210, Jul 17, 2010 IP
  16. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    oke now it displays something but not the image -> a small rectangle :mad: only the border black line
     
    ypspiky, Jul 17, 2010 IP
  17. tommykent1210

    tommykent1210 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    hmmm, where is the image located? in relation to public_html?

    is it at: yoursite.com/danger.gif
    or: yoursite.com/images/danger.gif

    ?
     
    tommykent1210, Jul 17, 2010 IP
  18. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    i dont understand what youy mean with "public_html". is located: mysite.com/danger.gif . thankx
     
    ypspiky, Jul 17, 2010 IP
  19. tommykent1210

    tommykent1210 Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Well, when you FTP into your site, there should be a folder called "public_html" OR "www" on the screen. That is your root folder.
     
    tommykent1210, Jul 17, 2010 IP
  20. ypspiky

    ypspiky Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    pfff Finally works... thanks to all for posting to help me ! I reinstalled xampp and now works :D
     
    ypspiky, Jul 18, 2010 IP