0

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

3
  • NB. your sql code is highly vulnerable to sql injections Commented Apr 21, 2011 at 15:25
  • nope it is not, it was checked for injections with "guvenlik" function. But thanks for reminding :) Commented Apr 21, 2011 at 15:27
  • i don't know what guvenlik does or even means … still, $orgs_id looks 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->var in a string and expect php to replace it with the actual values, you'd have to use ${this->var} Commented Apr 21, 2011 at 15:30

2 Answers 2

4
$iann->create();

not

$iann.create();

. is the concatenation operator

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.