html - Php working on localhost but not on server -
i've been working on code , tested on localhost, works fine, when opload server doesn't work beyond php tags. no errors showing either. have checked both php versions , on localhost run version 5.4.7 , on server it's version 5.3.21. maybe causing problem? there should in phpinfo()? im missing in code? here code:
<!doctype html> <?php phpinfo(); ?> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <meta charset="utf-8"> <style> body { background:black;} .toggle { display:none; } p { width:570px; text-align:justify; color:#686868; font-family:georgia, serif; } h2 { color:black; } button { background:#686868; border:none; font-family:georgia, serif; width:570px; } </style> </head> <body> <?php include('sql.php'); $i = 0; while($i < count($rows)) { echo " <div> <button class='trigger'> <table width='100%'> <tr> <td width='20%'><img src='http://localhost/app-side/icons/bar_icon.png' /> </td> <td width='80%'><h2>{$rows[$i]['titel']} </h2></td> </tr> </table> </button> <div class='toggle'> <p> {$rows[$i]['info']} </p> </div> </div>"; $i++; }?> </body> <script> $('.trigger').click(function() { $(this).siblings('.toggle').slidetoggle('fast'); }); </script> </html>
when run it, shows black background (as it's suppose to) beyond php starting tag gets cut off. have tried force while loop loop 10 times , removed parts it's getting data database see if mysql related problem. can conclude it's not.
the following line problem:
<img src='http://localhost/app-side/icons/bar_icon.png
the image cannot being loaded localhost
refers local computer of client (where browser runs) not server. such urls in websites considered malicious ;)
a workaround make work on both localhost
, server
use relative path. can relative document or relative document_root
of server. i've used second approach don't know location of php file on server.
solution link relative document_root
:
replace:
<img src='http://localhost/app-side/icons/bar_icon.png
by
<img src='/app-side/icons/bar_icon.png
Comments
Post a Comment