I’m using mysql_fetch_object in my code, and am getting an error because the object I am trying to create an instance of has a constructor.
The error is as follows: Warning: Missing argument 1 for Ratio::__construct() in /Users/Alex/Sites/All Good Things/_manage/c/c_ratio.php on line 9
Which I can understand; here’s the code for the Ratio constructor:
function __construct($new_name, $new_x, $new_y)
{
$this->name = $new_name;
$this->x = $new_x;
$this->y = $new_y;
}
Anyway, how do I pass variables from the result I have just created to the function, ie, What I what to do is something like this:
while ($currentRatio = mysql_fetch_object(
$ratio_rs,
'Ratio',
array(
<VALUE OF NAME>,
<VALUE OF X>,
<VALUE OF Y>)))
I can’t find any examples of the syntax required for this third parameter.
Use the Column alias. Column alias depends on how you construct the query. If you use alias (by
as) then it should be alias otherwise use the column name. See the example bellow.