简体   繁体   English

php本地主机当前无法访问此请求

[英]php Local host is currently unable to access this request

 <?php $handle = fopen("pictures_list.txt", "r"); if ($handle) { $linea = fgets($handle); $lineb = fgets($handle); $linec = fgets($handle); } fclose($handle); else { echo "can't find file"; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Pictures</title> <link rel="stylesheet" type="text/css" href="cssstyles.css" /> </head> <body> <center> <h1>Bridge Pictures</h1> <br /> <p class="ex" align="justify">This site or call.</p> <br/> <h3> Click on image to zoom in. Place mouse on image for Time Stamp</h3> <div id="container"> <ul> <li> <a href="<?php echo $linea; ?>"> <figure> <img src="<?php echo $linea; ?>" width="400"/> <figcaption> <?php echo $linea; ?> </figcaption> </figure> </a> </li> <li> <a href="<?php echo $lineb; ?>"> <figure> <img src="<?php echo $lineb; ?>" width="400"/> <figcaption><?php echo $lineb; ?></figcaption> </figure> </a> </li> <li> <a href="<?php echo $linec; ?>"> <figure> <img src="<?php echo $linec; ?>" width="400"/> <figcaption> <?php echo $linec; ?> </figcaption> </figure> </a> </li> </ul> <span class="button prevButton"></span> <span class="button nextButton"></span> <br /> <h2><a href=" http://www.xyz/"> Click here for a list of all images </a></h2> </ul> </center> </div> <script src="jquery-1.4.2.min.js"></script> <script> $(window).load(function(){ var pages = $('#container li'), current=0; var currentPage,nextPage; var timeoutID; var buttonClicked=0; var handler1=function(){ buttonClicked=1; $('#container .button').unbind('click'); currentPage= pages.eq(current); if($(this).hasClass('prevButton')) { if (current <= 0) current=pages.length-1; else current=current-1; nextPage = pages.eq(current); nextPage.css("marginLeft",-604); nextPage.show(); nextPage.animate({ marginLeft: 0 }, 800,function(){ currentPage.hide(); }); currentPage.animate({ marginLeft: 604 }, 800,function(){ $('#container .button').bind('click',handler1); }); } else { if (current >= pages.length-1) current=0; else current=current+1; nextPage = pages.eq(current); nextPage.css("marginLeft",604); nextPage.show(); nextPage.animate({ marginLeft: 0 }, 800,function(){ }); currentPage.animate({ marginLeft: -604 }, 800,function(){ currentPage.hide(); $('#container .button').bind('click',handler1); }); } } var handler2=function(){ if (buttonClicked==0) { $('#container .button').unbind('click'); currentPage= pages.eq(current); if (current >= pages.length-1) current=0; else current=current+1; nextPage = pages.eq(current); nextPage.css("marginLeft",604); nextPage.show(); nextPage.animate({ marginLeft: 0 }, 800,function(){ }); currentPage.animate({ marginLeft: -604 }, 800,function(){ currentPage.hide(); $('#container .button').bind('click',handler1); }); timeoutID=setTimeout(function(){ handler2(); }, 4000); } } $('#container .button').click(function(){ clearTimeout(timeoutID); handler1(); }); timeoutID=setTimeout(function(){ handler2(); }, 4000); }); </script> </body> </html> 

My html and javascript seemed to work just fine previously with hardcoded image names. 我的html和javascript以前似乎可以与硬编码的图像名称一起正常工作。 I am now using php to input images from a text file but now it doesn't seem to work. 我现在正在使用php从文本文件中输入图像,但现在似乎不起作用。 I get that the local host is currently unable to handle this request error. 我得到本地主机当前无法处理此请求错误。

I tried to write a simple php program such as this and this seems to work just fine. 我试图编写一个像这样的简单php程序,这似乎很好用。 I'm sure I'm missing something very silly but can't seem to figure it out. 我确信我错过了一些非常愚蠢的东西,但似乎无法弄清楚。 Please help 请帮忙

 <?php $handle = fopen("pictures_list.txt", "r"); if ($handle) { $linea = fgets($handle); $lineb = fgets($handle); $linec = fgets($handle); fclose($handle); } else { echo "can't find file"; } ?> <html> <head> </head> <body> <ul> <li> <a href="<?php echo $linea; ?>"> <figure> <img src="<?php echo $linea; ?>" width="400"/> <figcaption> <?php echo $linea; ?> </figcaption> </figure> </a> </li> <li> <a href="<?php echo $lineb; ?>"> <figure> <img src="<?php echo $lineb; ?>" width="400"/> <figcaption><?php echo $lineb; ?></figcaption> </figure> </a> </li> </ul> </body> </html> 

You shouldn't get anything: 您不应该得到任何东西:

if (...) {
    ...
}
fclose($handle);   
else {           // syntax error: "unexpected else (T_ELSE)"

You cannot have any code "between" the } and else . 您不能在}else之间存在任何代码。 They MUST be next to each other: 它们必须彼此相邻:

 if (...) {
      ...
 } else { 
    ...
 }

Since that's a fatal syntax error, the script dies, and probably causes a 500 error in your server. 由于这是一个致命的语法错误,因此脚本死亡,并且可能在服务器中导致500错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM