2011-09-09 14 views
0

私は問題がありますが、私は未定義変数を取得しており、何が問題なのかよく分かりません。私は過去3ヶ月間PHPで作業しているだけなので、それが主要な問題であるかもしれません。定義されていない変数 - PHP

これはクラスです:

<?php 

class BannedIPs 
{ 
public $id; 
public $ip; 
public $date; 
public $time; 
public $reason; 

public $Conn; 
public $Error; 

public function __construct(&$Conn) 
{ 
    $this->id = ""; 
    $this->ip = ""; 
$this->date = ""; 
    $this->time = ""; 
    $this->reason = ""; 

    $this->Conn = $Conn; 
    $this->Error = false; 
} 

public function GetByID($strCode) 
{ 
    $strSQL = "SELECT "; 
$strSQL .= "bingoliv_bannedips.* "; 
$strSQL .= "FROM bingoliv_bannedips "; 
$strSQL .= "WHERE (id = '" . mysqli_real_escape_string($this->Conn, $strCode) . "') "; 
$this->GetRecord($strSQL); 
} 

private function GetRecord($strSQL) 
{ 
    $objRS = mysqli_query($this->Conn, $strSQL); 
if (mysqli_num_rows($objRS) == 1) 
{ 
     $arrRS = mysqli_fetch_assoc($objRS); 
     $this->id = $arrRs["ID"]; //error here 
     $this->ip = $arrRS["IP"]; 
     $this->date = $arrRS["Date"]; 
     $this->time = $arrRS["Time"]; 
     $this->reason = $arrRs["Reason"]; //and here 

     $this->Error = false; 
    } 
else 
{ 
     $this->Error = true; 
} 
    mysqli_free_result($objRS); 
} 

public function Insert() //inserts a new banned ip to the database 
{ 
    $strSQL = "INSERT INTO bingoliv_bannedips (ID, IP, Date, Time, Reason) "; 
$strSQL .= "VALUES ("; 
    $strSQL .= "'" . mysqli_real_escape_string($this->Conn, $this->id) . "', "; 
$strSQL .= "'" . mysqli_real_escape_string($this->Conn, $this->ip) . "', "; 
$strSQL .= "'" . mysqli_real_escape_string($this->Conn, $this->date) . "', "; 
    $strSQL .= "'" . mysqli_real_escape_string($this->Conn, $this->time) . "', "; 
    $strSQL .= "'" . mysqli_real_escape_string($this->Conn, $this->reason) . "' "; 
$strSQL .= ") "; 
$resResult = mysqli_query($this->Conn, $strSQL); 
} 

public function Delete() //deletes using id as an identifier 
{ 
    $strSQL = "DELETE FROM bingoliv_bannedips WHERE id ='" . mysqli_real_escape_string($this->Conn, $this->id) . "' "; 
$resResult = mysqli_query($this->Conn, $strSQL); 

    $this->id = ""; 
    $this->ip = ""; 
$this->date = ""; 
    $this->time = ""; 
    $this->reason = ""; 

$this->Error = false; 
} 

} 

?> 

これは、管理者ページです:

enter image description here

そして最後に、これは誤りです:

<?php 
require_once "includes/ssi.page.top.php"; 
require_once "includes/ssi.admincols.start.php"; 

kickIfInsufficientRights($resConn, $objCurrentPage->RightName, $objCurrentUser->ProfileID, 'admin.php'); 

handleResultMessage($strResultType, $strResult); #What is this for?? 

?> 

<h3><a href="admin.php">Administration</a> &raquo; Banned IPs</h3> 
<div class="admin"> 
<table> 

<?php 
$strSQL = "SELECT id FROM bingoliv_bannedips ORDER BY ip ASC "; 
$objRS = new ZpPagingRecordset($resConn, $objCurrentUser->PageSize); 
$objRS->GetData($strSQL, $intCurPage); 
?> 
<tr> 
<th class="right" colspan="5"><?php echo $objRS->Controls('admin.bannedips.php', '')?></th> 
</tr> 
<tr class="strong"> 
<th>ID</th> 
<th>IP</th> 
<th>Date</th> 
<th>Time</th> 
<th>Reason</th> 
<th></th> 
</tr> 
<?php 

if (!$objRS->Error) 
     { 
     $objBannedIPs = new BannedIPs($resConn); 
     foreach ($objRS->Data as $arrRS) 
     { 
       $objBannedIPs->GetByID($arrRS["id"]); 
       ?> 

       <!-- bam --> 
       <tr class="hoverable"> 

        <td><?php echo $objBannedIPs->id?></td> 
        <td><?php echo $objBannedIPs->ip?></td> 
        <td><?php echo $objBannedIPs->date?></td> 
        <td><?php echo $objBannedIPs->time?></td> 
        <td><?php echo $objBannedIPs->reason?></td> 

        <td class="right"> 
         <?php if ($objCurrentUser->AllowedTo('ADMIN_COUNTRIES_UPDATE'))     { ?> 
          <a onclick="return zpSure('Deleting a banned ip is permanent!\n\nAre you sure you want to delete this banned ip?')" href="actions/admin.bannedips.delete.php?intCurPage=<?php echo $intCurPage?>&amp;cnt_id=<?php echo $objBannedIPs->id?>" title="delete"> 
          <img src="zplib/icons/delete.png" alt="Delete" /></a> 
         <?php } ?> 
        </td> 

       </tr> 

       <?php 
     } 
     unset($objBannedIPs); 
     ?> 
     <?php 
     } 
#when no data if found 
else 
{ 
     ?> 
     <tr> 
     <td class="celGridCenterBold" colspan="5"><br />No data found<br />&nbsp;</td> 
     </tr> 
     <?php 
}    
unset($objRS); 
?> 

</table> 
</div><!--/admin--> 


<?php 

    require_once "includes/ssi.admincols.mid.php"; 
    require_once "includes/ssi.panel.sidemenu.php"; 
    require_once "includes/ssi.admincols.end.php"; 
    require_once "includes/ssi.page.bottom.php"; 
?> 

これはテーブルです:

enter image description here

+0

これはおそらくローカライズされすぎて閉じられるはずです。 –

+0

@Alin最もローカライズされていない質問はすでに回答済みです – genesis

+0

@Alin Purcaru - 私も閉じることにしました。私はそれがローカライズされていることに同意します。それはちょうど大文字と小文字を区別する問題以上のものでした。 –

答えて

1

Sは首都であるべき

$this->id = $arrRs["ID"];$this->id = $arrRS["ID"];

$this->id = $arrRS["ID"]; 
    $this->ip = $arrRS["IP"]; 
    $this->date = $arrRS["Date"]; 
    $this->time = $arrRS["Time"]; 
    $this->reason = $arrRS["Reason"]; 
+0

私はこれを見ていないと信じられない、あまりにも疲れていると思います –

+0

あなたは何を知っていますか?寝て、休憩してください。このような場合は、あなたができる最善のことです。 – genesis

+0

ええ、これらのような問題は、通常、翌朝、まずは朝に解決されます。 –

0

MySQLの文でのスペルの間違いがあった場合、このエラーはほとんど発生し、間違ったMySQLの対ステートメント、セミコロンがないか、その他の中かっこが欠けています。

関連する問題