Reputation: 2367
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
Upvotes: 0
Views: 120
Reputation: 212522
$iann->create();
not
$iann.create();
. is the concatenation operator
Upvotes: 4
Reputation: 265966
you have to use ->
in php to call methods:
$iann->create();
the dot notation is used in .net and java, but not in php. the .
operator in php concatenates two strings, so php is probably converting your $iann
object to a string and then tries to concatenate it with the return value of the function create()
which does exist in the global namespace.
Upvotes: 1