Note that there are some explanatory texts on larger screens.

plurals
  1. POMath Results Inaccurate PHP
    primarykey
    data
    text
    <p>Are there any rules to using math within PHP. I'm getting some off the wall numbers when I try to do some simple math. </p> <p>Here is the specific script</p> <pre><code> $profit = $quote_1 - $entry; </code></pre> <p>Here is a snippet of the full script</p> <pre><code> if ($productCount &gt; 0) { // get all the product details while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $symbol = $row["symbol"]; $sym = strtoupper($sym); $entry = $row["entry"]; $exit = $row["exit"]; $openclosed = $row["openclosed"]; $entrydate = $row["entrydate"]; $profit = $quote_1 - $entry; $color = "#000000"; $positive = ""; if ($profit &gt;= 0){ $color = "#00a900"; $positive = "+"; } else if ($profit &lt; 0){ $color = "#ef3600"; $positive = "";} if(empty($symbol)) { echo nothing; } else { $open = fopen("http://quote.yahoo.com/d/quotes.csv?s=$symbol&amp;f=sl1d1t1c1ohgv&amp;e=.csv", "r"); $quote = fread($open, 1000); fclose($open); $quote = str_replace("\"", "", $quote); $quote = explode(",", $quote); $quote_0 = ($quote[0]); $quote_1 = ((float)$quote[1]); $quote_2 = ($quote[2]); $quote_3 = ($quote[3]); $quote_4 = ((float)$quote[4]); $quote_5 = ((float)$quote[5]); $quote_6 = ((float)$quote[6]); $quote_7 = ((float)$quote[7]); $quote_8 = ((float)$quote[8]); echo "&lt;ul&gt;&lt;li&gt;&lt;div class='wrapPicks'&gt; &lt;div class='symbolPicks'&gt; &lt;div class='quoteTitle'&gt;$quote_0&lt;/div&gt; &lt;/div&gt; &lt;div class='bgPicks'&gt; &lt;div class='quote'&gt;Entry Price: $$entry&lt;/div&gt; &lt;div class='quote'&gt;Last trade: $$quote_1&lt;/div&gt; &lt;!--&lt;div class='quote'&gt;Date: $quote_2&lt;/div&gt;--&gt; &lt;div class='quote'&gt;Open P/L: &lt;div class='bigGreen'&gt;&lt;span style=\"color: $color\"&gt;$positive $$profit &lt;/span&gt;&lt;/div&gt;&lt;/div&gt; &lt;!-- &lt;div class='quote'&gt;Change From Previous Close: $$quote_4&lt;/div&gt;--&gt; &lt;!--&lt;div class='quote'&gt;High: $$quote_6&lt;/div&gt; &lt;div class='quote'&gt;Low: $$quote_7&lt;/div&gt; &lt;div class='quote'&gt;Volume: $quote_8&lt;/div&gt;--&gt; &lt;/div&gt; &lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;"; } </code></pre> <p>Now something I thought of was that the yahoo data was coming in as a string possible and that may have been throwing things off. I'm also unclear as to whether my MYSQL table must be an int or is a VARChAR acceptable? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload