php - Error : Stock ticker is not working properly -


iam working on stock ticker , search number of site stock ticker. found ticker in below site stockticker

but iam getting error while displaying screen, please can on , going wrong?

enter image description here

i feel error in below code, iam not figuring how fix it.

        // ...format, , output them. made symbols links yahoo's stock pages.         echo "<span class=\"stockbox\"><a href=\"http://finance.yahoo.com/q?s=".$stock_info[0]."\">".$stock_info[0]."</a> ".sprintf("%.2f",$stock_info[1])." <span style=\"";         // green prices up, red down         if ($stock_info[2]>=0) { echo "color: #009900;\">&uarr;";   }         elseif ($stock_info[2]<0) { echo "color: #ff0000;\"> }         echo sprintf("%.2f",abs($stock_info[2]))."</span></span>\n";         // done!         fclose($local_file);      } ?> 

please can me fix it?

your error exists on line 5

elseif ($stock_info[2]<0) { echo "color: #ff0000;\"> } 

should be

elseif ($stock_info[2]<0) { echo "color: #ff0000;\">"; } 

or

elseif ($stock_info[2]<0) { echo 'color: #ff0000;">'; } 

as rule, can avoid escaping quotes, forces me know when quote closed or open.
example, rather

echo "my name '$bernard'";    //and if " quotes compulsory echo 'my name "'.$bernard.'"';     

than

echo "my name \"bernard\""; 

it's cleaner, , easier read.
hope helps

update

didn't notice url, it's *.htm file
code run, need run through server can process php code :)


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -