Welcome Guest, Not a member yet? Register   Sign In
Argument passed to [...] must be an instance of int, string given
#1

[eluser]Unknown[/eluser]
Hello, (sorry for ma english i am french)
I wrote this in my controller message.php :
Code:
function action_delete(int $idmessage)
    {
        mysql_query("DELETE * FROM Message WHERE IdMessage=$idmessage");
    }

and i want to pass argument to this method.

I do this in my view :
Code:
echo anchor('message/action_delete/'.$idmessage,'Delete');

I expected an int, and $idmessage=1...
I have this...
Quote:Argument passed to [...] must be an instance of int, string given

Someone could help me?
#2

[eluser]gigas10[/eluser]
PHP uses dynamic typing, that is you do not need to specify the variable type. Try this in your controller:
Code:
function action_delete($idmessage)
{
    $this->db->where('IdMessage', $idmessage);
    return $this->db->delete('Message');
}

If you want to ensure you are only getting an integer, you must check it yourself.
#3

[eluser]Unknown[/eluser]
thanks a lot!
that works Wink




Theme © iAndrew 2016 - Forum software by © MyBB