Looking for an explanation on ajrequest issue [SOLVED] - Joomla! Forum - community, help and support


hello

here s problem ve got , solved. problem not sure on happened... here's problem , solution ve found, great if give me explanation on why not working. ( know should use jinput :geek: )

i have 2 template pages (in tpl directory) of view. 1 create office entry in database (default) , other 1 edit view (edit). they share same model file

for each office, there photo. function, placed in model gets image, displayed in edit page .

with function below. works, , display photo.


code: select all

function getofficephoto(){
        $id = jrequest::getvar('id');
        $query = "select * #__locplantes_offices x ".
                 "left join #__locplantes_work y on x.id = y.fk_office_id ".
                 "where y.id = ".$id;
            $this->db->setquery($query);
            $officephoto = $this->db->loadobjectlist();
            return $officephoto;
    }


the problem is, kills default page, if not displaying photo there, giving me 1064 error . way ve found rewrite function follow

code: select all

function getofficephoto(){
        if (jrequest::getvar('id')){
            $query = "select * #__locplantes_offices x ".
                     "left join #__locplantes_work y on x.id = y.fk_office_id ".
                     "where y.id = ".jrequest::getvar('id');
            $this->db->setquery($query);
            $officephoto = $this->db->loadassoc();
             return $officephoto;
        }
    }



with syntax, works correctly. idea on ? id variable not exist int default page ? 'if jrequest' ? going if id variable exists ?

tks answers

schlogo wrote:( know should use jinput :geek: )
not soon, should first choise long time.
schlogo wrote:what 'if jrequest' ? going if id variable exists ?
goes if block if not 0 or false, right.
schlogo wrote:with syntax, works correctly. idea on ? id variable not exist int default page ?
right, value not exist , not issue of error, 1064 syntax error in sql statement.
id int value, you're requesting string, getvar() default value "null" causes sql error.
since id int should use getint(), default value of getint "0" , should not give sql error.





Comments

Popular posts from this blog

Joomla 3.3 Installation Error message - Joomla! Forum - community, help and support

Multilanguage infinite redirect loop error. - Joomla! Forum - community, help and support

trim media limit reached