Kod çalıştıran kullanıcı bir yönetici ise onlar o zaman bir oturum değişkeni alacak eğer ben içine bir mysql sorgusu geçmek ve geri veya bir hata sonucu alabilirsiniz bir işlev yapmaya çalışıyorum, o da, görmek için kontrol etmelisiniz ki mysql sorguları bir dizi sayısı kullanıcı bir yönetici ise herhangi bir hata mesajı gösterir de, sayfasında koştu ve daha sonra 1 numaraya bunu artırmak ve daha sonra tekrar bir oturum olarak ayarlayın tutar.
Ben iyi kod değil biliyorum ama çalışması gerekir gibi görünüyor? Çok geliştirmek için herhangi bir ipucu lütfen.
Ben bir oturum, değer variabls ben sonra geçerli yöntemi bir değişkene set alır başka bir yöntem kullanıyorum olduğunu görebilirsiniz, o zaman 1 sayısına göre bu değer artırmak ve daha sonra tekrar bir oturum kaydetmek için setter yöntemini çalıştırmak. Bunu yapmanın doğru yolu ise gerçekten emin değilim? Gerçekten bütün bu yöntemleri çalıştırmak ve ben gibi bir yerel değişkene hepsini kaydetmek gerekir MUSUNUZ?
Also I am getting this error
Fatal error: Using $this when not in object context in C:\webserver\htdocs\project2\includes\classes\Database.class.php on line 37
Hat 37 bu
$this->user_role = $session->get('user_role');
yöntem ...
public static function query($sql)
{
global $session; // the $session Object
//get the session value to see if user is an admin
$this->user_role = $session->get('user_role');
//if user is admin, get query counter session value and +1 to it and reset it to a session variable.
if ($this->user_role >= 9){
$this->querie_counter = $session->get('querie_counter');
$this->querie_counter++; // add +1 to the number
$session->set('querie_counter',$this->querie_counter)
}
//run mysql query
$result = mysql_query($sql);
if (!$result) {
// If admin is viewing then we show the sql code and the error returned
if($this->user_role >= 9){
$error = '<BR><center><font size="+1" face="arial" color="red">An Internal Error has Occured.<BR> The error has been recorded for review</font></center><br>';
$sql_formatted = highlight_string(stripslashes($sql), true);
$error .= '<b>The MySQL Syntax Used</b><br>' . $sql_formatted .
'<br><br><b>The MySQL Error Returned</b><br>' . mysql_error();
}
die($error);
}
return $result;
}