Re: Non-Object errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/4/28 Miller, Terion <tmiller@xxxxxxxxxxxxxxxxxxxx>:
> Can someone help with how to make this work, trying to get the number of
> rows but am getting the "trying to get property of non-object"
>
> Code-----------------
>
> $query = "select blah, blah, blah from table where ".$type." like
> '%".$name."%'";
>
> $result = mysql_query($query);
>
> $num_results = $result->num_rows; <---------------this is the line with
> error
>
Hi Terion,

you're mixing normal mysql_* with mysqli. Mysqli is object oriented
and the mormalö mysql_ functions aren't - thei're procedural.

So you can do it either like

$result = mysql_query("SELECT 1");
$num = mysql_num_rows($result);

Or in OOP

$res = $mysqlObj->query("SELECT 1"); // $mysqlObj should be
initialized first ;) hint: new mysqli()
$num = $res->num_rows();



Check ot this URL: http://php.net/mysqli



byebye

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux