Jump to content


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

runnerjp's Achievements

Advanced Member

Advanced Member (4/5)



  1. also in logs i have found Session Cache is not configured [hint: SSLSessionCache]
  2. Cookies: array(0) { } Session: array(0) { } is displayed both times... but if i go into the session temp file in server i see : test-8165|s:4:"test";
  3. The sessions on my server are being written but are not getting read the following code used: <?php session_start(); if (isset($_POST['submit'])) { if(!isset($_SESSION['cheese'])) { $_SESSION['cheese'] = 1; } else { $_SESSION['cheese']++; } } ?> session_start() creates new session on page reload meaning its not picking up the session. The above code displays no value. php ini file looks like this for sessions:
  4. know in excel to Calculate poisson probability percentage i just use =POISSON( 2, 3.55, FALSE) but is there a similar thing I can use in php as i have found http://php.net/manual/en/function.stats-cdf-poisson.php but it has no documentation to use it
  5. I am trying to join 3 tables together using the following sql command: SELECT tg.Kickoff, tg.League, tg.home, tg.away, ln.Full, ln.Mysite, ln.Country, tl.mydb FROM `todaysgames` AS tg INNER JOIN `leaguenames` AS ln ON tg.League = ln.Othersites INNER JOIN `teamlookup` AS tl ON tg.home = tl.websitedb OR tg.away = tl.websitedb; The issue is I get is it doubles each row. What I am looking to do is for each tg.home and tg.away is replace it with the tl.websitedb (this basically amends the name). would this be possible? (Below is the current output) And here is the desired output
  6. Hi, Im using Mysqli and im trying to limit the results by 10 and order them from last to first from the database. $sqlhorses = "SELECT Place FROM `*` WHERE `Horse` ='".$db->real_escape_string($row['horse']). "'"; the above works but when i added the limit 6 to the end it shows errors. Can anyone help?
  7. I have been able to pull the html of a given node <td class="winner"> <a href="/jockey/497-g-lee">G Lee</a><br><em><a href="/trainer/3372-r-varian">R Varian </a></em> </td> what im trying to do is pull the text if href contains jockey (in this case the result will be G Lee). im doing this by doing the following @$dom2->loadHTML($trainer); $xpath2 = new DOMXPath($dom2); //chekc to see if it had html in it? $result_rows2 = $xpath2->query('//a[contains(@href, "jockey")]'); note trainer is just the html posted above. now i do a var_dump on the data and get this: object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) } object(DOMNodeList)#13 (1) { ["length"]=> int(1) } object(DOMNodeList)#12 (1) { ["length"]=> int(1) }im not sure why but its not picking up the results?!?!? would anyone be able to assist?
  8. Im trying to add value into my database and i keep getting the following error my query looks like this mysqli_query($db,"INSERT INTO `Horses` (`Date`,`Track`,`Runners`, `Going`, `Distance`,`Class`,`Place`,`Losing_Dist`,`Stall`,`Horse`,`Age`,`Weight`,`Headgear`,`Horse_OR`,`Trainer`,`Odds`,`Jockeys_Claim`,`Comments`,`Race_Name` )VALUES ('$date','$place','$norunner','$going','$distance','$class',$place','$distance_bt','$stall','$horse','$age','$weight','$headgear','$OR','$trainer','$odds','$jockey','$comments','$event')")or die(mysqli_error($db)); and my table looks like this: Column Type Null Default ID int(255) No Date varchar(250) Yes NULL Track varchar(100) Yes NULL Runners varchar(50) Yes NULL Going varchar(50) Yes NULL Distance varchar(50) Yes NULL Class varchar(50) Yes NULL Place varchar(10) Yes NULL Losing_Dist varchar(50) Yes NULL Stall varchar(250) Yes NULL Horse varchar(50) Yes NULL Age varchar(50) Yes NULL Weight varchar(50) Yes NULL Headgear varchar(50) Yes NULL Horse_OR varchar(50) Yes NULL Trainer varchar(50) Yes NULL Odds varchar(50) Yes NULL Jockeys_Claim varchar(50) Yes NULL Comments varchar(250) Yes NULL Race_Name varchar(250) Yes NULL
  9. Ok so i have done the following $dom = new DOMDocument(); $html = $content; // load html @$dom->loadHTML($html); $xpath = new DOMXPath($dom); //this will gives you all td with class name is jobs. $my_xpath_query = '//table/tr/td[contains(@class, "databreakdown")]'; $result_rows = $xpath->query($my_xpath_query); //iterate all td foreach ($result_rows as $result_object){ echo $result_object->nodeValue. "<br />"; } what i would like to do is if the table contains td[contains(@class, "databreakdown")] then grab the whole table! at the moment it just returns the td
  10. Hello, Currently my webscraper signs into the site and pulls all the html -> perfect. What I need to do is to loop only specific information (horses that ran) here is my current php code <? $url = 'site'; $postdata = array('username' => "username", 'password' => "password"); $ch = curl_init(); if($ch){ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); // set cookie file to given file curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); // set same file as cookie jar $content = curl_exec($ch); $headers = curl_getinfo($ch); curl_close($ch); // Debug option // print_r($headers); if($headers['http_code'] == 200){ echo $content; } } ?> here is the html im pulling <table width=100% border=1><tr><td class=instruction6 colspan=4><b>My Race Notes</b></td></tr> <tr><td width=90%><form action='races.php?id=7456132' method=post> <textarea name='comments' rows=2 cols=38>Type notes & press Add</textarea></td> <td width=5%><input type=submit class='weestatbutton' value='Add'></form></td></tr></table></td></tr></table><table width=100%><tr class=databreakdown2253><th><a href='races.php?id=7456132&sortby=1'>Place</a></th><th>Dist Bt</th><th>Stall</th> <th>Horse</th><th>Age</th><th><a href='races.php?id=7456132&sortby=3'>Weight</a></th><th>Headgear</th><th>OR</th><th>Trainer</th> <th><a href='races.php?id=7456132&sortby=2'>Odds</a></th><th>Jockey (Claim)</th></tr><tr><td class=databreakdown2253>1st</td><td class=databreakdown2253></td><td class=databreakdown2253>4</td> <td class=databreakdown2253><a href='horses.php?id=298745'>Telegraph (IRE)</a></td> <td class=databreakdown2253>3</td><td class=databreakdown2253>9-3</td><td class=databreakdown2253></td> <td class=databreakdown2253>57</td> <td class=databreakdown2253><a href='trainers.php?id=2448'>Evans, P D</a></td> <td class=databreakdown2253>28/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=694'>Egan, John</a> </td></tr><tr class=databreakdown18><td colspan=12>soon led, brought field stands side from 3f out, headed 2f out, rallied inside final furlong, bumped and led again towards finish</td></tr><tr><td class=databreakdown2253>2nd</td><td class=databreakdown2253>0.5</td><td class=databreakdown2253>3</td> <td class=databreakdown2253><a href='horses.php?id=305855'>Ecliptic Sunrise</a></td> <td class=databreakdown2253>3</td><td class=databreakdown2253>8-12td><td class=databreakdown2253></td> <td class=databreakdown2253>52</td> <td class=databreakdown2253><a href='trainers.php?id=4516'>Donovan, D</a></td> <td class=databreakdown2253>10/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=3414'>Cosgrave, Pat</a> </td></tr><tr class=databreakdown18><td colspan=12>chased leaders, challenged 2f out, led 2f out, edged right inside final furlong, rider lost whip and headed towards finish</td></tr><tr><td class=databreakdown2253>3rd</td><td class=databreakdown2253>1.5</td><td class=databreakdown2253>1</td> <td class=databreakdown2253><a href='horses.php?id=300316'>Bookmaker</a></td> <td class=databreakdown2253>4</td><td class=databreakdown2253>9-6</td><td class=databreakdown2253><a title='Blinkers worn'>Blnk</a></td> <td class=databreakdown2253>59</td> <td class=databreakdown2253><a href='trainers.php?id=933'>Bridger, J J</a></td> <td class=databreakdown2253>6/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=3848'>Carson, William</a> </td></tr><tr class=databreakdown18><td colspan=12>prominent, took keen hold, led 2f out, headed over 1f out, not much room inside final furlong, stayed on same pace</td></tr><tr><td class=databreakdown2253>4th</td><td class=databreakdown2253>1</td><td class=databreakdown2253>2</td> <td class=databreakdown2253><a href='horses.php?id=261986'>Night Trade (IRE)</a></td> <td class=databreakdown2253>7</td><td class=databreakdown2253>8-8</td><td class=databreakdown2253><a title='Cheekpieces worn'>CkPc</a></td> <td class=databreakdown2253>50</td> <td class=databreakdown2253><a href='trainers.php?id=2653'>Harris, R A</a></td> <td class=databreakdown2253>6/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=7348'>Hardie, Cameron</a> (3)</td></tr><tr class=databreakdown18><td colspan=12>prominent, ridden over 2f out, switched left inside final furlong, no extra close home</td></tr><tr><td class=databreakdown2253>5th</td><td class=databreakdown2253>1.5</td><td class=databreakdown2253>6</td> <td class=databreakdown2253><a href='horses.php?id=299296'>Trigger Park (IRE)</a></td> <td class=databreakdown2253>3</td><td class=databreakdown2253>8-10</td><td class=databreakdown2253></td> <td class=databreakdown2253>50</td> <td class=databreakdown2253><a href='trainers.php?id=2653'>Harris, R A</a></td> <td class=databreakdown2253>20/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=3422'>Dobbs, Pat</a> </td></tr><tr class=databreakdown18><td colspan=12>chased leaders, ridden over 2f out, one pace over 1f out, no impression</td></tr><tr><td class=databreakdown2253>6th</td><td class=databreakdown2253>2.25</td><td class=databreakdown2253>7</td> <td class=databreakdown2253><a href='horses.php?id=300337'>Port Lairge</a></td> <td class=databreakdown2253>4</td><td class=databreakdown2253>8-11</td><td class=databreakdown2253><a title='Blinkers worn'>Blnk</a></td> <td class=databreakdown2253>50</td> <td class=databreakdown2253><a href='trainers.php?id=914'>Gallagher, J</a></td> <td class=databreakdown2253>33/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=193'>Catlin, Chris</a> </td></tr><tr class=databreakdown18><td colspan=12>slowly into stride, in rear, stayed on inside final furlong, never dangerous</td></tr><tr><td class=databreakdown2253>7th</td><td class=databreakdown2253>NK</td><td class=databreakdown2253>11</td> <td class=databreakdown2253><a href='horses.php?id=289934'>Lionheart</a></td> <td class=databreakdown2253>4</td><td class=databreakdown2253>8-13</td><td class=databreakdown2253></td> <td class=databreakdown2253>59</td> <td class=databreakdown2253><a href='trainers.php?id=4910'>Crate, Peter</a></td> <td class=databreakdown2253>10/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=7375'>Crouch, Hector</a> (7)</td></tr><tr class=databreakdown18><td colspan=12>reared start and slowly away, held up in rear, headway over 1f out, weakened inside final furlong</td></tr><tr><td class=databreakdown2253>8th</td><td class=databreakdown2253>2.75</td><td class=databreakdown2253>14</td> <td class=databreakdown2253><a href='horses.php?id=289421'>Koharu</a></td> <td class=databreakdown2253>4</td><td class=databreakdown2253>9-4</td><td class=databreakdown2253><a title='Cheekpieces worn'>CkPc</a></td> <td class=databreakdown2253>60</td> <td class=databreakdown2253><a href='trainers.php?id=2495'>Makin, P J</a></td> <td class=databreakdown2253>9/4 (Fav) </td> <td class=databreakdown2253><a href='jockeys.php?id=5952'>Bates, Mr D J</a> (3)</td></tr><tr class=databreakdown18><td colspan=12>in rear, ridden over 3f out, no impression</td></tr><tr><td class=databreakdown2253>9th</td><td class=databreakdown2253>3</td><td class=databreakdown2253>5</td> <td class=databreakdown2253><a href='horses.php?id=269827'>Saskias Dream</a></td> <td class=databreakdown2253>6</td><td class=databreakdown2253>9-6</td><td class=databreakdown2253><a title='Visor worn'>Vsor</a></td> <td class=databreakdown2253>59</td> <td class=databreakdown2253><a href='trainers.php?id=2002'>Chapple-Hyam, Jane</a></td> <td class=databreakdown2253>4/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=3544'>Hughes, Richard</a> </td></tr><tr class=databreakdown18><td colspan=12>mid-division, headway and switched left over 1f out, edged left entering final furlong, soon eased</td></tr><tr><td class=databreakdown2253>10th</td><td class=databreakdown2253>1.75</td><td class=databreakdown2253>12</td> <td class=databreakdown2253><a href='horses.php?id=304248'>Crafty Business (IRE)</a></td> <td class=databreakdown2253>3</td><td class=databreakdown2253>9-2</td><td class=databreakdown2253><a title='Visor worn'>Vsor</a></td> <td class=databreakdown2253>59</td> <td class=databreakdown2253><a href='trainers.php?id=695'>Moore, G L</a></td> <td class=databreakdown2253>14/1 </td> <td class=databreakdown2253><a href='jockeys.php?id=6669'>Bishop, Mr C</a> (3)</td></tr><tr class=databreakdown18><td colspan=12>towards rear, pushed along over 3f out, well beaten 2f out</td></tr></table><br><hr></td></tr></table> *note I'm using this for personal reasons
  11. Hi all, Im moving back into php coding after a few years of using .net. Would anyone be able to point me in the direction of a good login/register tutorial as a) i forgotten alot b) i have been told mysql is a big no no now and to use mysqli. I have searching google and found nothing hat a) works b) is any good
  12. How do i handle the ' in a sql query ? New SqlDataAdapter("select * from PB's", local)
  13. Hello all, I am able to pull the last 4 tweets made by a user and add them to a database but I only want to add the last 4 tweets that have '#mudder' in. this is what I have so far MyTimeLine.php <?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class MyTimeLine { /** * myTimeline PHP Script * This script gets a user's twitter timeline and returns it as a multidimension array * each array containing 'tweet, date and link' respectively. * * @author Opeyemi Obembe <ray@devedgelabs.com> * @copyright Copyright (c) 2010, devEdgeLabs. */ var $count; var $feedUrl; var $username; //@params: twitter username, number of needed updates (20 max) function myTimeline($username, $count = 20) { $this->feedUrl = 'http://api.twitter.com/1/statuses/user_timeline/'.$username.'.rss'; $this->count = $count > 20 ? 20 : $count; $this->username = $username; } function since($date) { $timestamp = strtotime($date); $seconds = time() - $timestamp; $units = array( 'second' => 1, 'minute' => 60, 'hour' => 3600, 'day' => 86400, 'month' => 2629743, 'year' => 31556926 ); foreach($units as $k => $v) { if($seconds >= $v) { $results = floor($seconds/$v); if($k == 'day' | $k == 'month' | $k == 'year') $timeago = date('D, d M, Y h:ia', $timestamp); else $timeago = ($results >= 2) ? 'about '.$results.' '.$k.'s ago' : 'about '.$results.' '.$k.' ago'; } } return $timeago; } // Returns a multidimentional array, each containg 'tweet, date and link' respectively function get() { // Append the count $url = $this->feedUrl; $url .= $this->count == 20 ? '' : '?count='.$this->count; // The http CURL thingy $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);//10 secs max $data = curl_exec($curl_handle); curl_close($curl_handle); // Some error? Return an empty array // You may want to extend this to know the exact error // echo curl_error($curl_handle); // or know the http status // echo curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); if(!$data) return array(); // Some reformatting $pattern = array( '/[^(:\/\/)](www\.[^ \n\r]+)/', '/(https?:\/\/[^ \n\r]+)/', '/@(\w+)/', '/^'.$this->username.':\s*/i' ); $replace = array( '<a href="http://$1" rel="nofollow">$1</a>', '<a href="$1" rel="nofollow">$1</a>', '<a href="http://twitter.com/$1" rel="nofollow">@$1</a>'. '' ); $tweets = array(); $xml = new SimpleXMLElement($data); foreach($xml->children()->children() as $item) { $tweet = preg_replace($pattern, $replace, $item->description); $date = $this->since($item->pubDate); $permalink = $item->link; $tweets[] = array($tweet, $date, $permalink); } return $tweets; } } ?> index.php $db_values = ''; $tweet_feeds = ''; $min = 0; $to_time = strtotime(date("Y-m-d H:i:s")); $from_time = strtotime($user_records[0]['FeedUpdatedDate']); $min = round(abs($to_time - $from_time) / 60, 0); if ($min > 10) { $sql = "select * FROM tweet_feeds"; if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } if ($result->num_rows > 0) { $result->free(); $sql = "Delete FROM tweet_feeds"; if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } } foreach ($user_records as $user) { $mytimeline = new MyTimeLine($user['TwitterName'], 4); $timeline = $mytimeline->get(); $index = 0; foreach ($timeline as $tweet) { if ($index > 4) $db_values .= "('" . htmlentities($tweet[0], ENT_QUOTES, 'UTF-8') . "','" . $tweet[1] . "'," . $user['ID'] . "),"; $index++; } } //insert all records in database if (strpos($db_values,'#mudder') !== false) { $db_values = substr($db_values, 0, strlen($db_values) - 1); $sql = "INSERT INTO tweet_feeds (TweetText,TweetTime,twitter_person_id) Values " . $db_values; if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } $sql = "UPDATE twitter_person SET FeedUpdatedDate = '" . date("Y-m-d H:i:s") . "' where ID > 0"; if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } } As you can see I have tried to add if (strpos($db_values,'#mudder') !== false) { $db_values = substr($db_values, 0, strlen($db_values) - 1); $sql = "INSERT INTO tweet_feeds (TweetText,TweetTime,twitter_person_id) Values " . $db_values; to try and add only mudder to the database but it just seems to add any of them. Can anyone hold?
  14. Thats because you have no if statement to tell it otherwise. Each time the page loads it will just fire $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); Unless you have a stament which says - if something then delete row e.g if ($delete = '1' ){ $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); }
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.