Jump to content

kingb00zer

Members
  • Posts

    128
  • Joined

  • Last visited

Posts posted by kingb00zer

  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. 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++;
    }
    }
    //}
    }

    ?>

  5. 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;
    }
    }
  6. $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
  7. 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.
  8. 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;
    }
    }
  9. Show us your code. Something in your code is taking far too long to run, it could be an infinite loop or a slow MySQL query.

    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;
    }
    }
  10. 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

  11. each entry into that table in my database is a stock symbol and 25 price changes, basically im attempting to use an auto refresh every so often to track recent movement of multiple stocks in the same page. just a silly tool im making for fun while im injured and cant work lol. each refresh takes the information from lets say 25 and inserts it into 24 and so on until 1 while the latest price enters into 25. it works now I just got the syntax wrong. im currently having a similar issue with insert but confident ill fix it soon.

     

    I created a turn based browser game a while ago but dont have my files with me to use as reference and have not done any php or sql in a couple of years so im forgetting things i used to do in my sleep hehe

  12. nevermind I fixed it, turns out I am just very rusty. sorry to waste a post.

     

    my solution

    mysql_query("UPDATE `tracker` SET `1`= '$onea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `2`= '$twoa' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `3`= '$threea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `4`= '$foura' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `5`= '$fivea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `6`= '$sixa' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `7`= '$sevena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `8`= '$eighta' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `9`= '$ninea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `10`= '$tena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `11`= '$elevena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `12`= '$twelvea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `13`= '$thirteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `14`= '$fourteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `15`= '$fifteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `16`= '$sixteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `17`= '$seventeena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `18`= '$eighteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `19`= '$nineteena' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `20`= '$twentya' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `21`= '$twentyonea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `22`= '$twentytwoa' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `23`= '$twentythreea' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `24`= '$twentyfoura' WHERE `tracker`.`code`='$code'");
    mysql_query("UPDATE `tracker` SET `25`= '$twentyfivea' WHERE `tracker`.`code`='$code'");
  13. Hi its been a couple of years since i last coded and it seems I have missed out on some recent changes and how it affects php/mysql. I cant seem to get my database to update values and im assuming it is because of php7 or maybe I have completely forgotten how to do so. Im not really interested in learning the new way at this moment as Im just playing around with something to kill time which im running low on and would like to just proceed to do things as i always had. pasted below is the code im using and if it is my code that ist working could someone lease let me know what it is? if it is a case of php7 changes then can someone please tell me how to downgrade my php in xampp so i can continue with my project?, thank you

     

    attempting to update multiple entries

    mysql_query("UPDATE tracker SET 1= '$onea' 2= '$twoa', 3= '$threea', 4= '$foura', 5= '$fivea', 6= '$sixa', 7= '$sevena' 8= '$eighta', 9= '$ninea', 10= '$tena', 11= '$elevena', 12= '$twelvea', 13= '$thirteena', 14= '$fourteena', 15= '$fifteena', 16= '$sixteena', 17= '$seventeena', 18= '$eighteena', 19= '$nineteena', 20= '$twentya', 21= '$twentyonea', 22= '$twentytwoa', 23= '$twentythreea', 24= '$twentyfoura', 25= '$twentyfivea' WHERE code= '$code' ");

    same thing but with single entries

    mysql_query("UPDATE tracker SET 1= '$onea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 2= '$twoa' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 3= '$threea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 4= '$foura' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 5= '$fivea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 6= '$sixa' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 7= '$sevena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 8= '$eighta' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 9= '$ninea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 10= '$tena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 11= '$elevena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 12= '$twelvea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 13= '$thirteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 14= '$fourteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 15= '$fifteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 16= '$sixteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 17= '$seventeena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 18= '$eighteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 19= '$nineteena' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 20= '$twentya' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 21= '$twentyonea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 22= '$twentytwoa' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 23= '$twentythreea' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 24= '$twentyfoura' WHERE code='$code'");
    mysql_query("UPDATE tracker SET 25= '$twentyfivea' WHERE code='$code'");
  14. Hi I have recently been playing around with a script I found on a website recently which retrieves stock market information from yahoo finance and have found that some of the important information I require the most is only providing me with N/A. I did notice that this post on the website is quite old and I'm thinking that maybe the way I retrieve the information from yahoo finance may be out dated. Instead of pasting the code I will provide a link (below this post) to the page I learned this from. For the most part it works just fine however I cant get the real time price which is what I need the most leaving me with 2 options. 1 do I find a way to get what I need from yahoo finance still? or 2 do I find a way to get the same data from the nasdaq website (is that even possible?)

     

    LINK: http://blog.chapagain.com.np/php-how-to-get-stock-quote-data-from-yahoo-finance-complete-code-and-tutorial/

  15. The web server will have error logs that you can check, PHP can also use an error log if you configure it to. I wouldn't run multiple servers at once though.
    How to I check my web server error logs with wamp? Also keep in mind this has absolutely nothing to do with my code, I ahvnt even had the chance to import my database or put my php files into the www folder (htdocs if xampp) I just test to see if tables are viewbale before even bothering as I have ocme to realise no tables in any DB are viewable
  16. Hi I have been getting the same issue with phpmyadmin on both wamp and xampp its been almost 2 weeks of downtime and Im really stressing about what to do. This is the issue, I can access phpmyadmin, I can then click on a database but when I click on any of the tables all that I can see is the menu (listed tables in said database) to the left and the main screen shows but a blank screen. I have tried un installing and re installing these programs (each used separately I never have both xamp and wamp installed at the same time) yet I get the same problem. I don't know what is wrong, how it happens or how to check of any kind of error. Any suggestions?

  17. have added any error reporting? done any debugging? it would be better than guessing.
    I found depreciated code in my log ins so that side of things is fine, I also got my wamp working, I just had to log in via the 127.0.0.1 ip in the url. all was going fine until I created a new table. when I attempted to access a table after having creating this table I wound up with the same issue my xampp had, where the main screen went blank. So I re opened phpmyadmin and viewed my database and noticed a couple of things. 1) all of the tables I had created in xampp were using the myisam storage engine and the new table was innodb, so I re created the new table with myisam set as storage engine... same issue occurred, I then noticed that at the bottom of the list of tables it said innodb and I put my curser over it and a bubble appeared saying that "the default storage engine for this mysql database is innodb" I would have to assume this is the root of all of my current problems, what I don't know is what to do about it... any suggestions?
×
×
  • Create New...