Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Object of class User could not be converted to int - POMOCY
Forum PHP.pl > Forum > PHP
ziox
Witam mam problem, otóż wyskakuje błąd:
Notice: Object of class User could not be converted to int i nie wiem jak go poprawić. pozniżej daje kody gdzie występuje ten sam problem

1. Notice: Object of class User could not be converted to int in /home/xxx/public_html/loginpanel.php on line 13
  1. <?php
  2. /*********************************************************
  3.  * Author: John Astill (c)
  4.  * Date : 10th December
  5.  * File : loginpanel.php
  6.  * Desc : Display the login panel if an user is not
  7.  * : logged in.
  8.  ********************************************************/
  9.  
  10. require_once "lang/lang.polish.php";
  11. require_once ("lang/".GetLangFile());
  12.  
  13. if ($User == 0 || $User->loggedIn == FALSE) {
  14. ?>
  15. <!-- Login panel -->
  16. <form method="POST" action="index.php?cmd=login">
  17. <table class="LOGINTB">
  18. <tr>
  19. <td align="center" colspan="2" class="LOGINHD">
  20. <font class="LOGINHD">
  21. <?php echo $Login_txt."\n"; ?>
  22. </font>
  23. </td>
  24. </tr>
  25. <tr>
  26. <td colspan="1" class="LOGINRW">
  27. <font class="LOGINRW">
  28. <small>
  29. <?php echo $Username_txt."\n"; ?>
  30. </small>
  31. </font>
  32. </td>
  33. <td colspan="1" class="LOGINRW">
  34. <font class="LOGINRW">
  35. <input type="text" size="8" name="LOGIN">
  36. </font>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td colspan="1" class="LOGINRW">
  41. <font class="LOGINRW">
  42. <small>
  43. <?php echo $Password_txt."\n"; ?>
  44. </small>
  45. </font>
  46. </td>
  47. <td colspan="1" class="LOGINRW">
  48. <font class="LOGINRW">
  49. <input type="password" size="8" name="PWD">
  50. </font>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td align="center" colspan="2" class="LOGINRW">
  55. <font class="LOGINRW">
  56. <input type="submit" name="logon" value="<?php echo $Logon; ?>">
  57. </font>
  58. </td>
  59. </tr>
  60. <?php
  61. // Only display this if the game is not locked.
  62. if ($LockedGame != "TRUE") {
  63. ?>
  64. <tr>
  65. <td colspan="2" class="LOGINRW">
  66. <font class="LOGINRW">
  67. <a href="index.php?sid=&cmd=createnewuser"><?php echo $New_User; ?></a>
  68. </font>
  69. </td>
  70. </tr>
  71. <?php
  72. }
  73. ?>
  74. <tr>
  75. <td colspan="2" class="LOGINRW">
  76. <font class="LOGINRW">
  77. <a href="index.php?sid=<?php echo $SID?>&cmd=forgotpassword"><?php echo $Forgot_password; ?></a><br>
  78. </font>
  79. </td>
  80. </tr>
  81. </table>
  82. </form>
  83. <?php
  84. }
  85. ?>



2.Notice: Object of class User could not be converted to int in /home/xxx/public_html/menus.php on line 94
  1. <?php
  2. /*********************************************************
  3.  * Author: John Astill
  4.  * Date : 9th December
  5.  * File : menus.php
  6.  ********************************************************/
  7. /*******************************************************
  8.   * Check the user id and password from the cookie.
  9.   *******************************************************/
  10. $isAdmin = CheckAdmin($User->usertype);
  11.  
  12. require "msgfunctions.php";
  13. require ("lang/".GetLangFile());
  14.  
  15. ?>
  16. <script>
  17. <!--
  18. function setGameDate(date, serveroffset){
  19. var old = document.getElementById("SERVERTIME");
  20. var bodyRef = document.getElementById("SERVER");
  21. var newInput = document.createElement("div");
  22. var bold = document.createElement("b");
  23. var newText = document.createTextNode(date);
  24. //var newText = document.createTextNode("Server Side Time "+date);
  25. newInput.setAttribute("id","SERVERTIME");
  26. bold.appendChild(newText);
  27. newInput.appendChild(bold);
  28. bodyRef.replaceChild(newInput,old);
  29.  
  30. // Wait one minute
  31. setTimeout("document.frames[0].location.reload()",60000);
  32. return false;
  33. }
  34. //-->
  35. </script>
  36. <!-- Menu -->
  37. <table class="MENUTB">
  38. <!-- Show the game time. -->
  39. <tr>
  40. <td align="center" class="LOGINHD">
  41. <font class="LOGINHD">
  42. <?php echo $Game_Time."\n";?>
  43. </font>
  44. </td>
  45. </tr>
  46. <tr>
  47. <td align="center" class="TBLROW">
  48. <font class="TBLROW">
  49. <iframe id="SERVERFRAME" name="SERVERFRAME" style="width:0px; height:0px;border:0px" src="getgametime.php"></iframe>
  50.  
  51. <div id="SERVER" name="SERVER">
  52. <div id="SERVERTIME" name="SERVERTIME">
  53. XX:XX
  54. </div>
  55. </div>
  56.  
  57. </font>
  58. </td>
  59. </tr>
  60.  
  61. <?php
  62. if (($homePage != "" and $homePageTitle != "") or $chatRoomURL != "") {
  63. ?>
  64. <tr>
  65. <td align="center" class="LOGINHD">
  66. <font class="LOGINHD">
  67. <?php echo $Txt_Home_Page."\n";?>
  68. </font>
  69. </td>
  70. </tr>
  71. <?php
  72. }
  73. ?>
  74. <tr>
  75. <td class="TBLROW">
  76. <!-- Home Page -->
  77. <?php
  78. if ($homePage != "" and $homePageTitle != "") {
  79. echo "<a href=\"$homePage\">$homePageTitle</a><br>";
  80. }
  81. ?>
  82. <?php
  83. if ($chatRoomURL != "") {
  84. ?>
  85. <a href="<?php echo $chatRoomURL ?>" target="_NewChatEnglFC">Chat Room</a><br>
  86. <?php
  87. }
  88. ?>
  89. </td>
  90. </tr>
  91. </table>
  92.  
  93. <?php
  94. if ($User != 0 && $User->loggedIn == TRUE) {
  95. ?>
  96. <table class="MENUTB">
  97. <tr>
  98. <td align="center" class="LOGINHD">
  99. <font class="LOGINHD">
  100. [<?php echo " $User->username ]"; ?>
  101. </font>
  102. </td>
  103. </tr>
  104. <?php
  105. $uid = $User->getUserId();
  106. $query = "SELECT * FROM $dbaseStandings WHERE lid='$leagueID' and userid='$uid' ORDER BY week DESC";
  107. $res = $dbase->query($query);
  108. ?>
  109. <tr>
  110. <td align="left" class="TBLROW">
  111. <font class="TBLROW">
  112. <?php
  113. if ($dbase->getNumberOfRows() > 0) {
  114. $line = mysql_fetch_array($res);
  115. $position = $line["position"];
  116. $points = $line["points"];
  117. } else {
  118. $position = "-";
  119. $points = "-";
  120. }
  121. echo "$Txt_Position $position ";
  122. echo "$Txt_Points $points";
  123. ?>
  124. </font>
  125. </td>
  126. </tr>
  127. <tr>
  128. <td align="center" valign="middle" class="TBLROW">
  129. <a href="index.php?sid=<?php echo $SID?>&cmd=icon">
  130. <img border="0" alt="<?php echo $Txt_Change_Icon; ?>" src="<?php echo $User->icon?>">
  131. </a>
  132. </td>
  133. </tr>
  134. </table>
  135. <?php
  136. }
  137. ?>
  138.  
  139. <table class="MENUTB">
  140. <tr>
  141. <td align="center" class="LOGINHD">
  142. <font class="LOGINHD">
  143. <?php echo $Menu."\n";?>
  144. </font>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td class="TBLROW">
  149. <a href="index.php<?php echo "?sid=$SID&cmd=table"?>"><?php echo $Prediction_Table;?></a><br>
  150. <!--
  151. <a href="index.php<?php echo "?sid=$SID&cmd=tournament"?>"><?php echo $Txt_Tournament_Standings;?></a><br>
  152. -->
  153. <a href="index.php<?php echo "?cmd=matchres&sid=$SID"?>"><?php echo $Fixtures_Results;?></a><br>
  154. <a href="index.php<?php echo "?sid=$SID&cmd=stats"?>"><?php echo $League_Statistics;?></a><br>
  155.  
  156. <?php
  157. // Only show these if the user is loged on
  158. if ($User->loggedIn == TRUE) {
  159. ?>
  160. <a href="index.php<?php echo "?sid=$SID&cmd=missingpreds"?>"><?php echo $My_Missing_Predictions;?></a><br>
  161. <a href="index.php<?php echo "?sid=$SID&cmd=mypreds"?>"><?php echo $My_Predictions;?></a><br>
  162. <a href="index.php<?php echo "?sid=$SID&cmd=profile"?>"><?php echo $My_Profile;?></a><br>
  163. <a href="index.php<?php echo "?sid=$SID&cmd=logout"?>"><?php echo $Logout;?></a>
  164. </td>
  165. </tr>
  166.  
  167. <?php
  168. // Only show this if messaging enabled
  169. if ($useMessaging == "TRUE") {
  170. ?>
  171. <tr>
  172. <td class="TBLROW">
  173. <a href="index.php<?php echo "?sid=$SID&cmd=msgs"?>"><?php echo $My_Messages.NewMail($User->userid);?></a>
  174. <br><a href="index.php<?php echo "?sid=$SID&cmd=msgusers"?>"><?php echo $Txt_Message_User;?></a>
  175. </td>
  176. </tr>
  177.  
  178. <?php
  179. }
  180. }
  181. ?>
  182. <tr>
  183. <td class="TBLROW">
  184. <a href="index.php<?php echo "?sid=$SID&cmd=help"?>"><?php echo $Help;?></a><br>
  185. <a href="mailto:<?php echo $adminEmailAddr?>?subject=PredictionLeague"><?php echo $Email_Us;?></a>
  186.  
  187. </td>
  188. </tr>
  189. </table>
  190.  
  191. <?php
  192. // If the user is an administrator, show the admin index.
  193. if($isAdmin) {
  194. require "adminmenus.php";
  195. }
  196. ?>
  197. <!-- End Menu -->



Proszę o szybką odpowiedz jesli to możliwe. Z góry dziękuje Wam za pomoc.
nospor
$User jest obiektem a ty porównujesz go z liczbą. Czego nie rozumiesz w tym komunikacie?

to:
if ($User == 0 || $User->loggedIn == FALSE) {
zamien na:
if (!$User || $User->loggedIn == FALSE) {

zaś to:
if ($User != 0 && $User->loggedIn == TRUE) {
na:
if ($User && $User->loggedIn == TRUE) {
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.