Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Ошибка
Форумы портала PHP.SU » » Если скрипт не работает » Ошибка

Страниц (1): [1]
 

1. zadrot02 - 07 Марта, 2016 - 13:18:33 - перейти к сообщению
Вот такая ошибка: Warning: Invalid argument supplied for foreach() in /home/u985314598/public_html/ind ex.php on line 73

Весь код файла index.php

PHP:
скопировать код в буфер обмена
  1. <?PHP
  2.  
  3. include('mysql.php');
  4. include('functions.php');
  5.  
  6.  
  7. // Get random 2
  8. $query="SELECT * FROM images ORDER BY RAND() LIMIT 0,2";
  9. $result = @mysql_query($query);
  10.  
  11. while($row = mysql_fetch_object($result)) {
  12.         $images[] = (object) $row;
  13. }
  14.  
  15.  
  16. // Get the top10
  17. $result = mysql_query("SELECT *, ROUND(score/(1+(losses/wins))) AS performance FROM images ORDER BY ROUND(score/(1+(losses/wins))) DESC LIMIT 0,10");
  18. while($row = mysql_fetch_object($result)) $top_ratings[] = (object) $row;
  19.  
  20.  
  21. // Close the connection
  22.  
  23.  
  24. ?>
  25. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <html xmlns="http://www.w3.org/1999/xhtml">
  27. <head>
  28. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  29. <title>Facemash</title>
  30. <style type="text/css">
  31.  
  32. body, html {font-family:Arial, Helvetica, sans-serif;width:100%;margin:0;padding:0;text-align:center;}
  33. h1 {background-color:#600;color:#fff;padding:20px 0;margin:0;}
  34. a img {border:0;}
  35. td {font-size:11px;}
  36. .image {background-color:#eee;border:1px solid #ddd;border-bottom:1px solid #bbb;padding:5px;}
  37.  
  38. </style>
  39. </head>
  40.  
  41. <body>
  42.  
  43.  
  44. <h1>FACEMASH</h1>
  45. <h2>Кто красивее и привлекательнее? Выбирай</h2>
  46.  
  47. <center>
  48. <table>
  49.         <tr>
  50.                 <td valign="top" class="image"><a href="rate.php?winner=<?=$images[0]->image_id?>&loser=<?=$images[1]->image_id?>"><img src="http://facemash.hol.es/images/<?=$images[0]->filename?>" style="max-width:250px"/></a></td>
  51.                 <td valign="top" class="image"><a href="rate.php?winner=<?=$images[1]->image_id?>&loser=<?=$images[0]->image_id?>"><img src="http://facemash.hol.es/images/<?=$images[1]->filename?>" style="max-width:250px"/></a></td>
  52.         </tr>
  53.         <tr>
  54.                 <td>Побед: <?=$images[0]->wins?> Поражений: <?=$images[0]->losses?></td>
  55.                 <td>Побед: <?=$images[1]->wins?> Поражений: <?=$images[1]->losses?></td>
  56.         </tr>
  57.         <tr>
  58.                 <td>Счет: <?=$images[0]->score?></td>
  59.                 <td>Счет: <?=$images[1]->score?></td>
  60.         </tr>
  61.         <tr>
  62.                 <td>Expected: <?=round(expected($images[1]->score, $images[0]->score), 4)?></td>
  63.                 <td>Expected: <?=round(expected($images[0]->score, $images[1]->score), 4)?></td>
  64.         </tr>
  65. </table>
  66. </center>
  67.  
  68. <h2>Самые популярные</h2>
  69. <center>
  70. <table>
  71.         <tr>
  72.                 <? foreach($top_ratings as $key => $image) : ?>
  73.   <td valign="top"><img src="http://facemash.hol.es/images/<?=$image->filename?>" width="70" /></td>
  74.   <? endforeach ?>
  75.  </tr>
  76.  <? /* Remove this to see the scoring
  77.  <tr>
  78.   <? foreach($top_ratings as $key => $image) : ?>
  79.   <td valign="top">Score: <?=$image->score?></td>
  80.   <? endforeach ?>
  81.  </tr>
  82.  <tr>
  83.   <? foreach($top_ratings as $key => $image) : ?>
  84.   <td valign="top">Performance: <?=$image->performance?></td>
  85.   <? endforeach ?>
  86.  </tr>
  87.  <tr>
  88.   <? foreach($top_ratings as $key => $image) : ?>
  89.   <td valign="top">Won: <?=$image->wins?></td>
  90.   <? endforeach ?>
  91.  </tr>
  92.  <tr>
  93.   <? foreach($top_ratings as $key => $image) : ?>
  94.   <td valign="top">Lost: <?=$image->losses?></td>
  95.   <? endforeach ?>
  96.  </tr>
  97.  */ ?>
  98. </table>
  99. </center>
  100. </body>
  101. </html>
2. OrmaJever - 07 Марта, 2016 - 13:51:44 - перейти к сообщению
zadrot02 пишет:
Вот такая ошибка: Warning: Invalid argument supplied for foreach() in /home/u985314598/public_html/ind ex.php on line 73

Я вам сочувствую, честно, ошибки это плохо. Попробуйте подождать пару дней возможно код выздоровеет
3. Bio man - 08 Марта, 2016 - 00:19:09 - перейти к сообщению
тут весь код ошибка Однако
в начало файла добавь error_reporting(-1) и появится еще ошибка, а может и несколько.

по теме - переменная либо не определена, либо не является массивом/итератором

 

Powered by ExBB FM 1.0 RC1