Hi, all
I have one assignment about implement the stock website.
i stuck in some problem which i can't solve.
i want to implement one function which all the $row related to the $result in sql and for each row initialize the class once.
i found if i gave the exactly name of the stock to initialize the class it works. But if i got the name from the sql row, it does not work.

Do not know why this happens??
Here is my code:

while ($row = mysql_fetch_assoc($result)) 
        $A = $row['foo'];
        $B = new Quotes ($A, $from, $to);//this one does not work, give me some error information
        $B = new Quotes ("$A", $from, $to);//also does not work
        $B = new Quotes (AIG, $from, $to);//this one works, AIG is the name of the sotck.

Many thanks.

8 Years
Discussion Span
Last Post by shasha821110
$A = $row['foo'];

Here 'foo' must match the column name in the table you are trying to access. Try outputting $A to see if it is correctly being assigned:

$A = $row['foo'];
echo $A;
// ...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.