Here is out class definition,
public function __construct($icontext, $ititle, $iorgs_id, $icreated_at) {
$this->context = $icontext;
$this->orgs_id = $iorgs_id;
$this->created_at = $icreated_at;
$this->title = $ititle;
}
//put your code here
//crud fonksiyonlari burda basliyor
public function create(){
$createann = mysql_query("INSERT INTO anns(context, title, orgs_id, created_at) VALUES('$this->context', '$this->title', $this->orgs_id, '$this->created_at'");
if($createann) return "Duyuru Başarıyla Eklendi"; else return "Duyuru Eklenemedi";
}
public function read($id){
$readann = mysql_query("SELECT * FROM anns WHERE id = $id");
$context = mysql_result($readann,0, "context");
$title = mysql_result($readann,0, "title");
$orgs_id = mysql_result($readann,0, "orgs_id");
$created_at = mysql_result($readann,0, "created_at");
$ann = new ann($context, $title, $orgs_id, $created_at);
return $ann;
}
public function update($id, $context, $title){
$updateann = mysql_query("UPDATE anns SET context = '$context', title = '$title' WHERE id = $id");
if($updateann) echo "Duyuru başarıyla güncellendi"; else echo "Duyuru güncellenemedi";
}
public function delete($id){
$deleteann = mysql_query("DELETE FROM anns WHERE id = $id");
if($deleteann){
echo "Duyuru başarıyla silindi";}
else{
echo "Duyuru silinemedi";}
}
//crud fonksiyonlari burda bitiyor
}
?>
And here is the function we create an object from it,
<?php
require_once '../include/functions.php';
require_once '../db_classes/ann.php';
$sonuc = login_check();
$iann = new ann(guvenlik($_POST['context']),guvenlik($_POST['title']), $orgs_id, 1231232);
$iann.create();
if($ann) echo "alallaal";
if(!$ann) echo "sadfasfdsdf";
?>
And last, here is the error log we got :D
PHP Fatal error: Call to undefined function create() in /var/www/pe/actions/newann.php on line 7" while reading response header from upstream
We are new to php, so it must be a very simple error we caused, but we coudn't find out what is wrong. Thanks
guvenlikdoes or even means … still,$orgs_idlooks unescaped. (and why has the caller of the function take care of escaping? that should happen inside the function, where you have control over it. having to escape before calling the function just means that you will forget to escape one day) unrelated to all this: you cannot use$this->varin a string and expect php to replace it with the actual values, you'd have to use${this->var}