Eric Boerner wrote:

Hello all,

I am having trouble setting array data from within a MySQL results
query. I have modified data from the result and wish to enter it into
it's own array ($data). That then is used to generate a graph. The
following code basically gives me an empty array...

I doubt the array is empty. It may not contain what you think it should, though. Try using print_r() on $data as you run through the code so you can see what it contains.


if ($sig1 > "-150") { $aval = "$sig1"; }

Don't put quotes around -150. As you have it right now, you're comparing strings. If $sig1 is a number, PHP plays nice and assumes you mean -150 instead of "-150", though. Also, you don't need quotes around $sig1 at the end of the line.


        if ($sig2 > "-150") { $bval = "$sig2"; } if ($bval > $aval)
{$aval = bval;}

Missing a dollar sign for "bval" on this line, unless "bval" is really a constant. Same deal with the quotes, too.


        if ($sig3 > "-150") { $bval = "$sig3"; } if ($bval > $aval)
{$aval = $bval;}        

Same deal here with the quotes, also.

$data[] = array('$time' => '$time','$aval' => 'aval');

Variables in single quotes are not evaluated. '$val' is not the same as "$val". Either way, you don't need any quotes here (assuming you mean $aval for the last entry.


$data[] = array($time=>$time, $aval=>$aval);

$aval = "-999";

$aval = -999;

Again, $data has something in it so long as your query is running. It is probably just not what you think it is.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Reply via email to