Jump to content

kingb00zer

Members
  • Content Count

    128
  • Joined

  • Last visited

Community Reputation

0 Neutral

About kingb00zer

  • Rank
    Member
  • Birthday 06/06/1985

Previous Fields

  • Languages
    html, css

Profile Information

  • Location
    Shepparton, Victoria, Australia
  • Interests
    Online gaming, Programming, The Universe, Sports.
  1. its only used in this section below to create a loop but only runs once when there is data in a completely different table and works fine when not. I am completely stumped on this one. $sql = "SELECT * FROM `tracker` ORDER BY movement DESC"; $qry= mysql_query($sql); while ($row= mysql_fetch_array($qry))
  2. I moved the echo of the variable $qry to a different place later in the loop and it displays this SELECT * FROM transactions WHERE code='artna' artna is the code of the row which is displayed first after it has been ordered by movement. for some reason it fails to continue through the loop after the first iteration and it only does this when the autobuy script adds data into the transactions table which at no point alters or adds anything to the table tracker which im trying to display.
  3. <?php set_time_limit(360); include('connection.php'); //include('trackingtable.php'); echo "<br />"; /** * Printing out the data */ echo "<html><head><link rel='stylesheet' type='text/css' href='stockstyle.css'></head><body><table border='1'>"; echo "<tr><td class='one'>CODE</td><td class='one'>CURRENT PRICE</td><td class='spacer'></td><td class='track'>UPS</td><td class='track'>DOWNS</td><td class='track'>EVENS</td><td class='track'>MOVEMENT</td><td class='track'>AVG UP</td><td class='track'>AVG DOWN</td><td class='track'>BIGGEST UP</td><td class='track'>BIGGEST DOWN</td><td class='track'>LAST CHANGE</td><td class='one'>COMMISSION</td><td class='one'>CODE</td></tr>"; // set autobuy trip value //$count= 1; // select all data from tracker table and order from by highest movement to lowest movement $sql = "SELECT * FROM `tracker` ORDER BY movement DESC"; $qry= mysql_query($sql); echo "$qry"; while ($row= mysql_fetch_array($qry)) // this is line 21 **************************************************** { $code= $row['code']; $current= $row['25']; $up= $row['ups']; $down= $row['downs']; $evens= $row['evens']; $movement= $row['movement']; $bigup= $row['bigup']; $bigdown= $row['bigdown']; $upcount= $row['upcount']; $downcount= $row['downcount']; $twentyfive= $row['25']; $twentyfour= $row['24']; $commission= 15; // edit this to be number of shares worht 20000 divided by .05
  4. it echos out Resource id #5 sorry about that, i forgot about the code block.
  5. I seem to have encountered another issue with this script which has me baffled. Im going to paste the full script along with the script it calls on which works fine however after calling on the script (autobuy.php) it then gives me an error on the original page after having only displayed 1 row. what I dont understand is that autobuy.php doesnt make any changes to the table in the database which im trying to list. its probably something very simple but i cant get my head around it. page2.php (this page is set to auto refresh and display a list of 100 stocks in order of movement, this works fine until something is purchased in the autobuy.php script. I get this error Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\page2.php on line 21 <?php set_time_limit(360); include('connection.php'); //include('trackingtable.php'); echo "<br />"; /** * Printing out the data */ echo "<html><head><link rel='stylesheet' type='text/css' href='stockstyle.css'></head><body><table border='1'>"; echo "<tr><td class='one'>CODE</td><td class='one'>CURRENT PRICE</td><td class='spacer'></td><td class='track'>UPS</td><td class='track'>DOWNS</td><td class='track'>EVENS</td><td class='track'>MOVEMENT</td><td class='track'>AVG UP</td><td class='track'>AVG DOWN</td><td class='track'>BIGGEST UP</td><td class='track'>BIGGEST DOWN</td><td class='track'>LAST CHANGE</td><td class='one'>COMMISSION</td><td class='one'>CODE</td></tr>"; // set autobuy trip value //$count= 1; // select all data from tracker table and order from by highest movement to lowest movement $sql = "SELECT * FROM `tracker` ORDER BY movement DESC"; $qry= mysql_query($sql); while ($row= mysql_fetch_array($qry)) { $code= $row['code']; $current= $row['25']; $up= $row['ups']; $down= $row['downs']; $evens= $row['evens']; $movement= $row['movement']; $bigup= $row['bigup']; $bigdown= $row['bigdown']; $upcount= $row['upcount']; $downcount= $row['downcount']; $twentyfive= $row['25']; $twentyfour= $row['24']; $commission= 15; // edit this to be number of shares worht 20000 divided by .05 include('autosell.php'); // determine if change is up down or even and color code if($current > 0) { $classchange= "up2"; } else if($current < 0) { $classchange= "down2"; } else { $classchange= "even2"; } $bigdown2= abs($bigdown); if ($bigup > $bigdown2) { $classup="up3"; }else { $classup="track2"; } $difference= $twentyfive - $twentyfour; if($difference > 0) { $classtype='up3'; } else if($difference < 0) { $classtype='down3'; } else { $classtype='even3'; } //$na= "N/A"; //if ($stock[5] == $na) //{ $current= $twentyfive; //} else //{ //$current= $stock[5]; //} //error_reporting(0); // get average ups and downs $avgup = $upcount / $up; $avgup= number_format($avgup,2); $avgdown = $downcount / $down; $avgdown= number_format($avgdown,2); $avgdown2= abs($avgdown); if($avgup > $avgdown2) { $classavg="up3"; }else { $classavg="track2"; } $downs2= $down * 1.3; if($up > $downs2) { $classmove="up3"; }else { $classmove="track2"; } if ($up >= 8 && $up > $downs2 && $avgup > $avgdown2 && $bigup > $bigdown2) { $classbuy= "buy"; include('autobuy.php'); } else { $classbuy="three"; } if ($movement > 0) { $classmove2= "up3"; } else { $classmove2= "track2"; } echo "<tr><td class='three'>$code</td></td><td class='two' align='center'>$$current</td><td class='spacer'></td><td class='$classmove'>$up</td><td class='track2'>$down</td><td class='track2'>$evens</td><td class='$classmove2'>$movement %</td><td class='$classavg'>$avgup</td><td class='track2'>$avgdown</td><td class='$classup'>$bigup</td><td class='track2'>$bigdown</td><td class='$classtype'>$difference</td><td class='track2'>$commission</td><td class='$classbuy'>$code</td></tr>"; //$count2++; } echo "</table>"; $queryg= "SELECT * FROM userinfo"; $resultg = mysql_query($queryg) or die(mysql_error()); while($row = mysql_fetch_array($resultg)) { $name= $row['user']; $money= $row['money']; } echo "<table class='userinfo' >"; echo "<tr><td>$name </td><td>Cash: $$money</td></tr>"; echo "</table>"; echo "</body></html>"; ?> autobuy.php (this script is triggered on occasion and theoretically buys shares and stores the information in the database in a completely different table to what im displaying in page2.php) <?php include('connection.php'); // check if stock is already purchased $querybuy3= "SELECT * FROM transactions WHERE code='$code'"; $resultbuy3 = mysql_query($querybuy3) or die(mysql_error()); $check= mysql_num_rows($resultbuy3); if ($check == 0) { //if ($count == 1) //{ // set the buying parameter $querybuy= "SELECT * FROM tracker WHERE code='$code'"; $resultbuy = mysql_query($querybuy) or die(mysql_error()); while($row = mysql_fetch_array($resultbuy)){ $bigdown= $row['bigdown']; $bigup= $row['bigup']; $price= $row['25']; } if ($bigdown == 0) { $stop= $price * .035; } else { $stop= $bigdown; } $stop= $stop * 1.2; $stop= abs($stop); $stop= round($stop,2); $querybuy2= "SELECT * FROM userinfo WHERE user='ash'"; $resultbuy2 = mysql_query($querybuy2) or die(mysql_error()); while($row = mysql_fetch_array($resultbuy2)){ $money= $row['money']; //$shares= $row['shares']; //$networth= $row['totalvalue']; //$trades= $row['tradecount']; } if($money >= 20030) { $commission= 15; $amount= 20000 / $current; $amount= floor($amount); $cost= $current * $amount + $commission; $sellprice= $current - $stop; if($money > $cost) { // make first purchase mysql_query("INSERT INTO `transactions` (`code`, `cost`, `quantity`, `trailingstop`, `high`, `sold`, `sellprice` ) VALUES ('$code', '$current', '$amount', '$stop', '$current', 'no', '$sellprice' )"); // update user info $money= $money - $cost; //$shares= $shares + $cost; //$networth= $money + $shares; //$trades++; mysql_query("UPDATE `userinfo` SET `money`= '$money' WHERE `userinfo`.`user`='ash'"); //mysql_query("UPDATE `userinfo` SET `shares`= '$shares' WHERE `userinfo`.`shares`='ash'"); //mysql_query("UPDATE `userinfo` SET `totalvalue`= '$networth' WHERE `userinfo`.`totalvalue`='ash'"); //mysql_query("UPDATE `userinfo` SET `tradecount`= '$trades' WHERE `userinfo`.`tradecount`='ash'"); echo "you purchased $amount shares of $code for $$cost with a commision of $commission, you have set your trailing stop to $stop <br />"; //$count++; } } //} } ?>
  6. hi i have been working with a piece of code i found on a website and edited it to suit a project im working on, it works 95% of the time but on occasion it gives me an error (failed to open stream: HTTP request failed! HTTP/1.0 999 Unknown HTTP Status in) which I googled and based on the results im seeing that I should be using cURL instead however i dont seem to understand how to update the code im currently working with so i thought ill paste what I have here and see if anyone can help me out. below i have pasted 2 scripts, the first one yahoostock.php which call on the script im having issues with named class.yahoostock.php <?php set_time_limit(360); include('connection.php'); include_once('class.yahoostock.php'); $objYahooStock = new YahooStock; /** Add format/parameters to be fetched a – Ask a2 – Average Daily Volume a5 – Ask Size b – Bid b2 – Ask (Real-time) b3 – Bid (Real-time) b4 – Book Value b6 – Bid Size c – Change and Percent Change c1 – Change c3 – Commission c6 – Change (Real-time) c8 – After Hours Change (Real-time) d – Dividend/Share d1 – Last Trade Date d2 – Trade Date e – Earnings/Share e1 – Error Indication (returned for symbol changed / invalid) e7 – EPS Est. Current Year e8 – EPS Est. Next Year e9 – EPS Est. Next Quarter f6 – Float Shares g – Day’s Low g1 – Holdings Gain Percent g3 – Annualized Gain g4 – Holdings Gain g5 – Holdings Gain Percent (Real-time) g6 – Holdings Gain (Real-time) h – Day’s High i – More Info i5 – Order Book (Real-time) j – 52-week Low j1 – Market Capitalization j3 – Market Cap (Real-time) j4 – EBITDA j5 – Change from 52 Week Low j6 – Percent Change from 52 Week Low k – 52-week High k1 – Last Trade (Real-time) with Time k2 – Change Percent (Real-time) k3 – Last Trade Size k4 – Change from 52 Week High k5 – Percent Change from 52 Week High l – Last Trade (with time) l1 – Last Trade (without time) l2 – High Limit l3 – Low Limit m – Day’s Range m2 – Day’s Range (Real-time) m3 – 50 Day Moving Average m4 – 200 Day Moving Average m5 – Change from 200 Day Moving Average m6 – Percent Change from 200 Day Moving Average m7 – Change from 50 Day Moving Average m8 – Percent Change from 50 Day Moving Average n – Name n4 – Notes o – Open p – Previous Close p1 – Price Paid p2 – Change in Percent p5 – Price/Sales p6 – Price/Book q – Ex-Dividend Date r – P/E Ratio r1 – Dividend Pay Date r2 – P/E (Real-time) r5 – PEG Ratio r6 – Price/EPS Est. Current Year r7 – Price/EPS Est. Next Year s – Symbol s1 – Shares Owned s7 – Short Ratio t1 – Last Trade Time t6 – Trade Links t7 – Ticker Trend t8 – 1 Year Target Price v – Volume v1 – Holdings Value v7 – Holdings Value (Real-time) w – 52 Week Range w1 – Day’s Value Change w4 – Day’s Value Change (Real-time) x – Stock Exchange y – Dividend Yield */ $objYahooStock->addFormat("soghca"); /** Add company stock code to be fetched from the form in the previous page using $GET method */ $stock1= $_GET['stock1']; $stock2= $_GET['stock2']; $stock3= $_GET['stock3']; $stock4= $_GET['stock4']; $stock5= $_GET['stock5']; $stock6= $_GET['stock6']; $stock7= $_GET['stock7']; $stock8= $_GET['stock8']; $stock9= $_GET['stock9']; $stock10= $_GET['stock10']; $stock11= $_GET['stock11']; $stock12= $_GET['stock12']; $stock13= $_GET['stock13']; $stock14= $_GET['stock14']; $stock15= $_GET['stock15']; $stock16= $_GET['stock16']; $stock17= $_GET['stock17']; $stock18= $_GET['stock18']; $stock19= $_GET['stock19']; $stock20= $_GET['stock20']; $stock21= $_GET['stock21']; $stock22= $_GET['stock22']; $stock23= $_GET['stock23']; $stock24= $_GET['stock24']; $stock25= $_GET['stock25']; $stock26= $_GET['stock26']; $stock27= $_GET['stock27']; $stock28= $_GET['stock28']; $stock29= $_GET['stock29']; $stock30= $_GET['stock30']; $stock31= $_GET['stock31']; $stock32= $_GET['stock32']; $stock33= $_GET['stock33']; $stock34= $_GET['stock34']; $stock35= $_GET['stock35']; $stock36= $_GET['stock36']; $stock37= $_GET['stock37']; $stock38= $_GET['stock38']; $stock39= $_GET['stock39']; $stock40= $_GET['stock40']; $stock41= $_GET['stock41']; $stock42= $_GET['stock42']; $stock43= $_GET['stock43']; $stock44= $_GET['stock44']; $stock45= $_GET['stock45']; $stock46= $_GET['stock46']; $stock47= $_GET['stock47']; $stock48= $_GET['stock48']; $stock49= $_GET['stock49']; $stock50= $_GET['stock50']; $stock51= $_GET['stock51']; $stock52= $_GET['stock52']; $stock53= $_GET['stock53']; $stock54= $_GET['stock54']; $stock55= $_GET['stock55']; $stock56= $_GET['stock56']; $stock57= $_GET['stock57']; $stock58= $_GET['stock58']; $stock59= $_GET['stock59']; $stock60= $_GET['stock60']; $stock61= $_GET['stock61']; $stock62= $_GET['stock62']; $stock63= $_GET['stock63']; $stock64= $_GET['stock64']; $stock65= $_GET['stock65']; $stock66= $_GET['stock66']; $stock67= $_GET['stock67']; $stock68= $_GET['stock68']; $stock69= $_GET['stock69']; $stock70= $_GET['stock70']; $stock71= $_GET['stock71']; $stock72= $_GET['stock72']; $stock73= $_GET['stock73']; $stock74= $_GET['stock74']; $stock75= $_GET['stock75']; $stock76= $_GET['stock76']; $stock77= $_GET['stock77']; $stock78= $_GET['stock78']; $stock79= $_GET['stock79']; $stock80= $_GET['stock80']; $stock81= $_GET['stock81']; $stock82= $_GET['stock82']; $stock83= $_GET['stock83']; $stock84= $_GET['stock84']; $stock85= $_GET['stock85']; $stock86= $_GET['stock86']; $stock87= $_GET['stock87']; $stock88= $_GET['stock88']; $stock89= $_GET['stock89']; $stock90= $_GET['stock90']; $stock91= $_GET['stock91']; $stock92= $_GET['stock92']; $stock93= $_GET['stock93']; $stock94= $_GET['stock94']; $stock95= $_GET['stock95']; $stock96= $_GET['stock96']; $stock97= $_GET['stock97']; $stock98= $_GET['stock98']; $stock99= $_GET['stock99']; $stock100= $_GET['stock100']; $objYahooStock->addStock("$stock1"); $objYahooStock->addStock("$stock2"); $objYahooStock->addStock("$stock3"); $objYahooStock->addStock("$stock4"); $objYahooStock->addStock("$stock5"); $objYahooStock->addStock("$stock6"); $objYahooStock->addStock("$stock7"); $objYahooStock->addStock("$stock8"); $objYahooStock->addStock("$stock9"); $objYahooStock->addStock("$stock10"); $objYahooStock->addStock("$stock11"); $objYahooStock->addStock("$stock12"); $objYahooStock->addStock("$stock13"); $objYahooStock->addStock("$stock14"); $objYahooStock->addStock("$stock15"); $objYahooStock->addStock("$stock16"); $objYahooStock->addStock("$stock17"); $objYahooStock->addStock("$stock18"); $objYahooStock->addStock("$stock19"); $objYahooStock->addStock("$stock20"); $objYahooStock->addStock("$stock21"); $objYahooStock->addStock("$stock22"); $objYahooStock->addStock("$stock23"); $objYahooStock->addStock("$stock24"); $objYahooStock->addStock("$stock25"); $objYahooStock->addStock("$stock26"); $objYahooStock->addStock("$stock27"); $objYahooStock->addStock("$stock28"); $objYahooStock->addStock("$stock29"); $objYahooStock->addStock("$stock30"); $objYahooStock->addStock("$stock31"); $objYahooStock->addStock("$stock32"); $objYahooStock->addStock("$stock33"); $objYahooStock->addStock("$stock34"); $objYahooStock->addStock("$stock35"); $objYahooStock->addStock("$stock36"); $objYahooStock->addStock("$stock37"); $objYahooStock->addStock("$stock38"); $objYahooStock->addStock("$stock39"); $objYahooStock->addStock("$stock40"); $objYahooStock->addStock("$stock41"); $objYahooStock->addStock("$stock42"); $objYahooStock->addStock("$stock43"); $objYahooStock->addStock("$stock44"); $objYahooStock->addStock("$stock45"); $objYahooStock->addStock("$stock46"); $objYahooStock->addStock("$stock47"); $objYahooStock->addStock("$stock48"); $objYahooStock->addStock("$stock49"); $objYahooStock->addStock("$stock50"); $objYahooStock->addStock("$stock51"); $objYahooStock->addStock("$stock52"); $objYahooStock->addStock("$stock53"); $objYahooStock->addStock("$stock54"); $objYahooStock->addStock("$stock55"); $objYahooStock->addStock("$stock56"); $objYahooStock->addStock("$stock57"); $objYahooStock->addStock("$stock58"); $objYahooStock->addStock("$stock59"); $objYahooStock->addStock("$stock60"); $objYahooStock->addStock("$stock61"); $objYahooStock->addStock("$stock62"); $objYahooStock->addStock("$stock63"); $objYahooStock->addStock("$stock64"); $objYahooStock->addStock("$stock65"); $objYahooStock->addStock("$stock66"); $objYahooStock->addStock("$stock67"); $objYahooStock->addStock("$stock68"); $objYahooStock->addStock("$stock69"); $objYahooStock->addStock("$stock70"); $objYahooStock->addStock("$stock71"); $objYahooStock->addStock("$stock72"); $objYahooStock->addStock("$stock73"); $objYahooStock->addStock("$stock74"); $objYahooStock->addStock("$stock75"); $objYahooStock->addStock("$stock76"); $objYahooStock->addStock("$stock77"); $objYahooStock->addStock("$stock78"); $objYahooStock->addStock("$stock79"); $objYahooStock->addStock("$stock80"); $objYahooStock->addStock("$stock81"); $objYahooStock->addStock("$stock82"); $objYahooStock->addStock("$stock83"); $objYahooStock->addStock("$stock84"); $objYahooStock->addStock("$stock85"); $objYahooStock->addStock("$stock86"); $objYahooStock->addStock("$stock87"); $objYahooStock->addStock("$stock88"); $objYahooStock->addStock("$stock89"); $objYahooStock->addStock("$stock90"); $objYahooStock->addStock("$stock91"); $objYahooStock->addStock("$stock92"); $objYahooStock->addStock("$stock93"); $objYahooStock->addStock("$stock94"); $objYahooStock->addStock("$stock95"); $objYahooStock->addStock("$stock96"); $objYahooStock->addStock("$stock97"); $objYahooStock->addStock("$stock98"); $objYahooStock->addStock("$stock99"); $objYahooStock->addStock("$stock100"); ?> <?php set_time_limit(360); /** * Class to fetch stock data from Yahoo! Finance * */ class YahooStock { /** * Array of stock code */ private $stocks = array(); /** * Parameters string to be fetched */ private $format; /** * Populate stock array with stock code * * @param string $stock Stock code of company * @return void */ public function addStock($stock) { $this->stocks[] = $stock; } /** * Populate parameters/format to be fetched * * @param string $param Parameters/Format to be fetched * @return void */ public function addFormat($format) { $this->format = $format; } /** * Get Stock Data * * @return array */ public function getQuotes() { $result = array(); $format = $this->format; foreach ($this->stocks as $stock) { /** * fetch data from Yahoo! * s = stock code * f = format * e = filetype */ $s = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$stock&f=$format&e=.csv"); /** * convert the comma separated data into array */ $data = str_getcsv($s, ",", '"'); /** * populate result array with stock code as key */ $result[$stock] = $data; } return $result; } }
  7. that works perfectly, i over complicated the way I thought about it with my attempts. thank you so much.
  8. $count2 and $result im attempting to use to trigger the loop to end but im almost certain that im using the wrong kind of loop to display this information. i wish my external hd wasnt a 10 hour drive away, I did this a few years ago on a previous project but forget what i did to make it work lol I managed to make the loop stop when it is supposed to by making this change pasted below but I am a little unsure how to select the correct row from the database in the loop. Also im lacking a where clause because im not what what to put after WHERE.. // select all data from tracker table and order from by highest movement to lowest movement $sql = "SELECT * FROM `tracker` ORDER BY movement ASC"; $qry= mysql_query($sql); $result= mysql_num_rows($qry); for($count2 = 0; $count2 <= $result; $count2++ ) { $sql = "SELECT * FROM `tracker` ORDER BY movement ASC"; $qry= mysql_query($sql); while ($row= mysql_fetch_array($qry)) { $code= $row['code']; $current= $row['25']; $up= $row['ups']; $down= $row['downs']; $evens= $row['evens']; $movement= $row['movement']; $bigup= $row['bigup']; $bigdown= $row['bigdown']; $upcount= $row['upcount']; $downcount= $row['downcount']; $twentyfive= $row['25']; $twentyfour= $row['24']; $commission= 15; // edit this to be number of shares worht 20000 divided by .05 } } // here is where the code that would display the details goes, there is no errors here } EDIT: I also think I might be needing to use the foreach loop but could not remember how to do so correctly to save my life lol
  9. Hi I cant seem to get my data to display correctly, at the moment it is ordered correctly but repeats the same data continuously instead of the entire table. I used to know how to do this but have not been actively coding for a couple of years now. Can someone please point me in the right direction? thanks. // select all data from tracker table and order from by highest movement to lowest movement $sql = "SELECT * FROM `tracker` ORDER BY movement ASC"; $qry= mysql_query($sql); $result= mysql_num_rows($qry); $count2= 1; while ($count2 <= $result ) { while ($row= mysql_fetch_array($qry)) { $code= $row['code']; $current= $row['25']; $up= $row['ups']; $down= $row['downs']; $evens= $row['evens']; $movement= $row['movement']; $bigup= $row['bigup']; $bigdown= $row['bigdown']; $upcount= $row['upcount']; $downcount= $row['downcount']; $twentyfive= $row['25']; $twentyfour= $row['24']; $commission= 15; // edit this to be number of shares worht 20000 divided by .05 } // her is where the code that would display the details goes, there is no errors here $count2++; } I removed most of the code that I know works and left the part where Im positive im wrong.
  10. Thank you I will try it out, if I have any issues ill report back to this thread.
  11. I tried playing around with the curls first but i dont really understand it just yet and am limited on time at the moment so i chose to use this. ini_set('default_socket_timeout', 900); // 900 Seconds = 15 Minutes I dont know if I put it in the right place as Im still getting the same error. <?php /** * Class to fetch stock data from Yahoo! Finance * */ class YahooStock { /** * Array of stock code */ private $stocks = array(); /** * Parameters string to be fetched */ private $format; /** * Populate stock array with stock code * * @param string $stock Stock code of company * @return void */ public function addStock($stock) { $this->stocks[] = $stock; } /** * Populate parameters/format to be fetched * * @param string $param Parameters/Format to be fetched * @return void */ public function addFormat($format) { $this->format = $format; } /** * Get Stock Data * * @return array */ public function getQuotes() { $result = array(); $format = $this->format; foreach ($this->stocks as $stock) { /** * fetch data from Yahoo! * s = stock code * f = format * e = filetype */ ini_set('default_socket_timeout', 900); // 900 Seconds = 15 Minutes $s = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$stock&f=$format&e=.csv"); /** * convert the comma separated data into array */ $data = str_getcsv($s, ",", '"'); /** * populate result array with stock code as key */ $result[$stock] = $data; } return $result; } }
  12. the code is pasted below, I created something based around some code I found form a google search which gives me stock prices from yahoo finance. its only ever shows me this error 50% of the time while the market is closed. its no big deal if I can extend the time I just need to know how to change that time. <?php /** * Class to fetch stock data from Yahoo! Finance * */ class YahooStock { /** * Array of stock code */ private $stocks = array(); /** * Parameters string to be fetched */ private $format; /** * Populate stock array with stock code * * @param string $stock Stock code of company * @return void */ public function addStock($stock) { $this->stocks[] = $stock; } /** * Populate parameters/format to be fetched * * @param string $param Parameters/Format to be fetched * @return void */ public function addFormat($format) { $this->format = $format; } /** * Get Stock Data * * @return array */ public function getQuotes() { $result = array(); $format = $this->format; foreach ($this->stocks as $stock) { /** * fetch data from Yahoo! * s = stock code * f = format * e = filetype */ $s = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$stock&f=$format&e=.csv"); // this is the line that causes the fatal error (sometimes) /** * convert the comma separated data into array */ $data = explode( ',', $s); /** * populate result array with stock code as key */ $result[$stock] = $data; } return $result; } }
  13. ok so I have no idea what to do, where do I go?
  14. thank you, ill have a look at that file. if I have any issues changing it ill let you know.
  15. Hi on occasion I get the error pasted below and am wondering if there is a way for it to either not be displayed or for it to not give up after 30 seconds? thanks Fatal error: Maximum execution time of 30 seconds exceeded in
×
×
  • Create New...