Jump to content

runnerjp

Members
  • Posts

    2,214
  • Joined

  • Last visited

Everything posted by runnerjp

  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"); }
  15. Hello guys. I have 4 posts for each users in the db but it only displays one. $sql = "SELECT * FROM tweet_feeds left join twitter_person on (tweet_feeds.twitter_person_id = twitter_person.id)"; //ORDER BY twitter_person.id asc, TweetTime DESC if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } else { while ($row = $result->fetch_assoc()) { $tweet_feeds[] = $row; } $result->free(); } $first_tweet_feeds[] = array(); $tweeter_id = 0; $count = 0; foreach ($tweet_feeds as $tweet) { $pattern = '/(#mudder)/'; if(preg_match($pattern,$tweet['TweetText'])) { if ($tweeter_id != $tweet['twitter_person_id']) { $tweetcontent = $tweet['TweetText']; $tweetcontent = preg_replace('/[#]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/search?q=%23$1" target="_blank"" class="tweet_hashtag">#$1</a>', $tweetcontent); $first_tweet_feeds[$tweet['twitter_person_id']] = html_entity_decode($tweetcontent); $tweeter_id = $tweet['twitter_person_id']; } } } $tweets_list = array(); foreach ($tweet_feeds as $tweet) { $tweets_list[$tweet['twitter_person_id']][] = $tweet; } //unset feed data unset($tweet_feeds); if (isset($tweets_list[5])) foreach ($tweets_list[5] as $tweet) { $tweetcontent = $tweet['TweetText']; $tweetcontent = preg_replace('/[#]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/search?q=%23$1" target="_blank"" class="tweet_hashtag">#$1</a>', $tweetcontent); $pattern = '/(#mudder)/'; if(preg_match($pattern,$tweet['TweetText'])) { ?> <li class="tweet_first tweet_odd"> <a class="tweet_avatar" href="http://twitter.com/<?php echo $tweet['TwitterName']; ?>"> <img src="assets/img/largeTwitter.jpg" height="32" width="32" alt="<?php echo $tweet['TwitterName']; ?> avatar" title="<?php echo $tweet['TwitterName']; ?> avatar" border="0"> </a> <span class="tweet_text"> <?php echo html_entity_decode($tweetcontent); ?> </span> <span class="tweet_time" style="color:#000;"> <?php echo $tweet['TweetTime']; ?> </span> </li> <?php } } ?> Someone must be able to spot why
  16. When you say it doesn't work. What's happening? Any errors?
  17. An Undefined index means that you are referencing an array index that doesn't exist yet. Have you checked if $i is set? <?php echo $ip = $_SERVER['REMOTE_ADDR']; echo "<br />"; echo $date = date("Y-m-d"); echo "<br />"; $d = ""; $i = ""; $ip1 = mysql_query("SELECT * FROM ip WHERE date='$date' AND ip='$ip'"); while($row = mysql_fetch_array($ip1)){ $d = $row['date']; $i = $row['ip']; } if($i == $ip && $d == $date) <--------------------------------------------------------------------- the warnings.... echo 'You have already visited the page today.'; else { $insert_ip = mysql_query("INSERT INTO ip (id,date,ip) VALUES('','$date','$ip')") or die(mysql_errno()); echo 'Thank you for your visit'; } ?> TRY THE ABOVE
  18. Hello, I have this page http://rolleragency.co.uk/action/ and in the blue section it should show 4 tweets per user all the time but for some reason they disappear and I cannot figure out why. <?php //includes database configuration include('dbconfig.php'); include('classmytimeline.php'); //check if tweet already exist before expire time then load $sql = "select * FROM twitter_person"; if (!$result = $db->query($sql)) { die('There was an error running the query select [' . $db->error . ']'); } else { while ($row = $result->fetch_assoc()) { $user_records[] = $row; } $result->free(); } $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 $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 . ']'); } } $sql = "SELECT * FROM tweet_feeds left join twitter_person on (tweet_feeds.twitter_person_id = twitter_person.id)"; //ORDER BY twitter_person.id asc, TweetTime DESC if (!$result = $db->query($sql)) { die('There was an error running the query [' . $db->error . ']'); } else { while ($row = $result->fetch_assoc()) { $tweet_feeds[] = $row; } $result->free(); } $first_tweet_feeds[] = array(); $tweeter_id = 0; $count = 0; foreach ($tweet_feeds as $tweet) { $pattern = '/(#mudder)/'; if(preg_match($pattern,$tweet['TweetText'])) { if ($tweeter_id != $tweet['twitter_person_id']) { $tweetcontent = $tweet['TweetText']; $tweetcontent = preg_replace('/[#]+([A-Za-z0-9-_]+)/', '<a href="http://twitter.com/search?q=%23$1" target="_blank"" class="tweet_hashtag">#$1</a>', $tweetcontent); $first_tweet_feeds[$tweet['twitter_person_id']] = html_entity_decode($tweetcontent); $tweeter_id = $tweet['twitter_person_id']; } } } $tweets_list = array(); foreach ($tweet_feeds as $tweet) { $tweets_list[$tweet['twitter_person_id']][] = $tweet; } //unset feed data unset($tweet_feeds); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The Passengers & Roller Support Action Duchenne</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,600,700,800,300' rel='stylesheet' > <link rel="stylesheet" href="assets/css/font-awesome.min.css"> <!--[if IE 7]> <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css"> <![endif]--> <link href="assets/css/styles.css" rel="stylesheet"> <link href="assets/css/jquery.tweet.css" rel="stylesheet" > <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="assets/js/html5shiv.js"></script> <![endif]--> <? if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad')) { ?> Classtimeline <?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; } } ?> Any help would be great.
  19. Sorry just a quick question. Would the text file need to be like this: 1 2 3 4 5 6 what if the text file is 1,2,3,4,5,6,7 ???
  20. Ah yes that works great. Sorry it been a while since i have coded and it 100% not like riding a bike
  21. Hello, I have a text file with a list of post codes (one on each line) I am trying to read it to see if the postcode is in the list: <?php $file = fopen("postcodes.txt", "r"); $i = 0; while (!feof($file)) { $line_of_text .= fgets($file); } $members = explode("\n", $line_of_text); fclose($file); if (in_array("SE5", $members)) { echo "Got you"; } ?> Have I gone wrong somewhere as it does not show Got you even though when I use print_r($members); it shows: Array ( [0] => SE1 [1] => SE2 [2] => SE3 [3] => SE4 [4] => SE5 [5] => SE6 [6] => SE7 [7] => SE8 [8] => SE9 [9] => SE10 [10] => SE11 [11] => SE12 [12] => SE13 [13] => SE14 [14] => SE15 [15] => SE16 [16] => SE17 [17] => SE18 [18] => SE19 [19] => SE20 [20] => SE21 [21] => SE22 [22] => SE23 [23] => SE24 [24] => SE25 [25] => SE26 [26] => SE27 [27] => SE28 )
  22. sorry i copied the wrong part... died('We are sorry, but there appears to be a problem with the form you submitted.'); that should be die('We are sorry, but there appears to be a problem with the form you submitted.');
  23. Hello, Quick look at the code and you need to chnage function died($error) { to function die($error) { This should show you where the code is showing the error.
  24. Can anyone suggest why the drop down is not selecting the users selected option :S <select name="level_id"> <option value="" selected="selected">- Please Select -</option> <?php mysql_data_seek($rsl,0); if (mysql_num_rows($rsl)>0): while ($rowl = mysql_fetch_assoc($rsl)):?> <option value="<?=$row1['id']?>" <?if ($row1['id']==$rowq['level_id']) echo 'selected="selected"';?>><?=stripslashes($rowl['title'])?></option> <?php endwhile; endif; ?> </select>
×
×
  • 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.