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:
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.

$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;
// ...

yes, i tried and it give me correct result if i do
echo $A;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.