I trying to write betting script so i need odds here i trying to get odds and store on my mysql database
<?php
$db_host='localhost';
$db_user='karpovci_see';
$db_pass='*****';
$db_name='karpovci_bet';
//establish your connection
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully";
//set the variables which you will send to the api call
$data = array();
$data['uid'] = '22489';
$data['key'] = '1dc40';
$data['graded'] = 2; //get both graded and ungraded games
$data['sports'] = 'Baseball-MLB,Basketball-NCAA,Basketball-NBA,Football-NCAA,Football-NFL,Hockey-NHL';
$target_url = 'http://ift.tt/15oN5OZ';
$response = http($target = $target_url,'','GET',$data,EXCL_HEAD);
$content = $response['FILE'];
echo 'test'; <----- here code stop
if($content == false)
{
echo 'An error has occured.';
exit();
}
else
{
//use the simplexml library to do wonderous things
$xml = simplexml_load_string($content);
$lines = array();
foreach ($xml->lines->game as $game)
{
if($game->line->score->winner)
{
//the game has been graded, so let's process all of the bets on the game
}
else
{
//the game hasn't been graded, so let's update the lines
//you could do various checks like checking to make sure te game hasn't already started,
//but as long as you don't pass full_call = 1 then we do those checks for you on our side
//first let's check to see if the game is already in our datbase.
$result = $mysqli->query("SELECT id FROM games WHERE id = ".$game->id);
if($result->num_rows == 0)
{
//the game isn't in our databse, so let's insert it
$mysql->real_query("INSERT INTO lines VALUES(
'$game->id',
'$game->sporttype',
'$game->sportsubtype',
'$game->gamedate',
'$game->last_update',
'$game->team1->rotnum',
'$game->team1->name',
'$game->team1->pitcher',
'$game->team2->rotnum',
'$game->team2->name',
'$game->team2->pitcher',
'".$game->line->periodnum."',
'".$game->line->perioddesc."',
'".$game->line->wagercutoff."',
'".$game->line->money->team1."',
'".$game->line->money->team2."',
'".$game->line->spread->points."',
'".$game->line->spread->team1."',
'".$game->line->spread->team2."',
'".$game->line->total->points."',
'".$game->line->total->team1."',
'".$game->line->total->team2."',
'".$game->line->score->team1."',
'".$game->line->score->team2."',
'".$game->line->score->winner."'
)");
}
else
{
//we already have the game, so let's just update the lines
$mysql->real_query("UPDATE lines SET
sporttype = '$game->sporttype',
sportsubtype = '$game->sportsubtype',
gamedate = '$game->gamedate',
last_update = '$game->last_update',
team1rotnum = '$game->team1->rotnum',
team1name = '$game->team1->name',
team1pitcher = '$game->team1->pitcher',
team2rotnum = '$game->team2->rotnum',
team2'$game->team2->name',
'$game->team2->pitcher',
'".$game->line->periodnum."',
'".$game->line->perioddesc."',
'".$game->line->wagercutoff."',
'".$game->line->money->team1."',
'".$game->line->money->team2."',
'".$game->line->spread->points."',
'".$game->line->spread->team1."',
'".$game->line->spread->team2."',
'".$game->line->total->points."',
'".$game->line->total->team1."',
'".$game->line->total->team2."',
'".$game->line->score->team1."',
'".$game->line->score->team2."',
'".$game->line->score->winner."'
WHERE id = ".$game->id);
}
}
}
}
?>
but php stop here
$response = http($target = $target_url,'','GET',$data,EXCL_HEAD);
no error no nothink.. can sombady help what is wrong in this php code... on line 36 echo 'test'; not work...
No comments:
Post a Comment