채택완료

랜덤으로 정보를 가져오려고 사용했던 코드인데 ...서버 변경 후 안되네요

2017-12-28 (목) 13:50:39 2,277
Copy
<?php
//$banner = array(1, 2);
//if (!defined('_INDEX_')) {
 $banner = array();
 while (count($banner) < 2) {
  $index = mt_rand(1, 2);
  if (!in_array($index, $banner)) {
   $info[] = $index;
  }
 }
//}
?>

                        <!-- info -->
                        <div style=" text-align:center; width:500px; margin-top:5px; margin-left:60px; margin-bottom:10px; z-index:999;"  >
                        <iframe src="/info/top<?php=$info[0]?>.html" width="500" height ="90"  scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe>
                        </div>

                        <div style=" text-align:center; width:728px; margin-top:5px; margin-left:60px; margin-bottom:10px; z-index:999;" >
                        <iframe src="/info/top<?=$info[1]?>.html" width="500" height ="90"  scrolling="no" frameborder="0" marginwidth="0" marginheight="0"></iframe>
                        </div>

                        <!-- info -->

아래와 같이 나오는데...왜 그럴까여?

Not Found

The requested URL /info/top< was not found on this server.

|

답변 3개

채택된 답변
+20 포인트
2017-12-28 (목) 13:57:12

<?php=$info[0]?>.html  ->  <?php echo $info[0]?>.html

변경 후 확인

<?=$info[1]?>.html  부분도  확인

<?=$test;?>

<? echo $test; ?>

<?php echo $test; ?> <- 권장

검색 short_open_tag

php 버젼이 바뀌지는 않으셨나요?

mt_srand() 로 바꿔보시고 그래도 안된다면 php 버젼을 바꿔바야죠 ^^

아 출력에러 같네요.

 <?=$info[0]?>.html

이렇게 바꾸시면 될듯 합니다.

답변을 작성하려면 로그인이 필요합니다.