Code: Select all
class stockdata {
//var's
var $multiplier;
//set methods
function set_multiplier($number){
$this->multiplier=$multiplier;
}
//get methods
function get_multiplier(){
return $this->multiplier;
}
//mysql methods
function mysql_multiplier($ticker){
$url = "http://moneycentral.msn.com/detail/stock_quote?ipage=qd&Symbol=US%3A".$ticker;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$result = curl_exec($ch);
curl_close($ch);
$pattern='!P/E</td><td class="cl1">([^<]*)</td></tr>!';
preg_match($pattern,$result,$multiplier);
print_r($multiplier);
$this->set_multiplier($multiplier[1]);
}
function getdata_storemysql(){
$this->mysql_multiplier($this->ticker);
//insert values into mysql
$mysql_tickname_insert="UPDATE curldata SET multiplier = '".$this->multiplier."' WHERE ticker='$this->ticker';";
if ( $sqldb = mysql_connect( "localhost", "localuser", "localpass" ) ) {
print "<br>Connection to coldowl.com username: localuser complete<br>";
}
else {
die ("Unable to connect to coldowl.com username: localuser . Error: <b>".
mysql_error()."</b>");
}
if ( mysql_select_db( intelligent , $sqldb ) ) {
print "Select of intelligent complete<br>";
}
else {
die ("Select failed database name intelligent Error number: <b>".mysql_errno().
" Message: ".mysql_error()."</b>");
}
if ( mysql_query( $mysql_tickname_insert, $sqldb ) ) {
print $mysql_tickname_insert." complete<br>";
}
else {
print $mysql_tickname_insert." failed. Error number: <b>".mysql_errno().
" Message: ".mysql_error()."</b>";
}
mysql_close($sqldb);
}
}I began troubleshooting by inserting the print_r() to test if the regex and curling in the mysql_multiplier() was working properly, which it is. I've checked the name of the database, DB table, and DB table column 100x.
***IN STEWIE'S VOICE FROM FAMILY GUY***
How on earth is this thing not storing my values?!