Jump to content

cahamilton

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by cahamilton

  1. Scratch that, just found the Apache server access in OS X. Cheers
  2. As in install these on my hard drive?? How would I go about doing that?
  3. Is it possible to set up some kind of "virtual web host" on my computer? I want to be able to start trying out things such as Wordpress and various other server side apps beforehand, and arrange some sort of hosting once my site is complete. I'd buy some hosting now, but I'm going travelling in 2 weeks for about 4 months, so it would be wasted money if I didnt have a site complete by then. On a side note, I'm currently running Mac OSX and use Dreamweaver CS3.
  4. Well anyway of doing it would be great. Would there be any advantages using explode() over the preg_replace?
  5. Hello again....quick question! How would I rewrite a variable, so that everything after a certain point in the text, is deleted? Currently, Im trying to do something like this: The Offspring – Long Way Home <<< Starting with this The Offspring <<< End like this So anything after the " – " I want to delete. I think it has something to do with preg_replace, but I cant quite seem to get my head around the actual function itself to rewrite it. Would anyone be able to explain it to me?
  6. That worked great thanks! I'll keep that in mind for next time
  7. Hey guys. I've been working on a script recently, which Im going to be using to take my recent "Tweets" from Twitter, and post them into my portfolio site. So far, all is good and I've been able to retrieve this data using the API feeds. The only problem is, I cant find anywhere in the API that allows me to control how many entries will show up on my page. Is there any way using PHP, to restrict how many entries are fed out? Here's the code I've been working with so far.... <?php $user_id = "USER_ID"; $feed_url = "http://twitter.com/statuses/user_timeline/".$user_id.".rss"; $sxml_twitter = @simplexml_load_file($feed_url); ?> <?php foreach ($sxml_twitter->channel->item as $entry) { $news_title = $entry->description; $date = $entry->pubDate; ?> <?php echo " <ul> <li class='tweet'>$news_title</li> <li class='date_twitter'>$date</li> </ul>"; ?> <?php } ?>
  8. Good stuff lol. I managed to get a caching system working in there last night aswell, which Im pretty proud of lol. A friend off my course messaged me, to tell me that she found her friend on there as well lol
  9. As part of my final year dissertation, I was required to produce a website that uses data scraping and feeds. With all this in mind, I have come up with Music Mashup. A website which takes advantage from the Flickr, Youtube, Last FM and Idiomag API's. Please take a look around and let me know what you think! If you also have a spare moment, please give the feedback form in the bottom right hand of the site a go. Or just post your comments back on here . www.cahamilton.at-uclan.com/fyp While I'm here, I just want to say cheers to some of the guys on here, who helped me out on this project. Very much appreciated !
  10. Bah fuck. I've figured it out. Thanks everyone for helping. If your interested, heres what fixed it: <?php if ($news_content2 != "") { echo "<ul class=\"news_item\"> <li><h2>$news_title2</h2></li> <li><span class='news_date'>$news_date2</span></li> <li>$news_content2...</li> <li><a href=\"$news_article_url\" title='$news_title2' class='readmore' target='_blank'>Read More</a></li> </ul>";} ?> <?php } ?> <?php if ($news_content2 == "") { echo "<p class='error'>Sorry, News For This Artist is Currently Unavailable.</p> <img src='images/error.gif' alt='Error' title='Error' class='center' /> <p class='error'>Please try again Later</p>";} ?> </div>
  11. The whole page code <?php $news_url = 'http://www.idiomag.com/api/artist/articles/rss?key=42306fb6d05692ad116515c562f48254&artist='; $artist_name = str_replace(" ","+",$artist_name); $artist_name_normalised = normaliser($artist_name); //takes out special charcters for news search $news_result = $news_url.$artist_name_normalised; // read feed into SimpleXML object $sxml_news = @simplexml_load_file($news_result);?> <h1 class="news_title">News Content</h1> <div id="news_stream"> <?php if($sxml_news && $sxml_news) // iterate over entries in feed foreach ($sxml_news->channel->item as $news_entry) { // Get news title $news_title = $news_entry->title; $news_title2 = ucwords($news_title); // sentence case // Date of publishment $news_date = $news_entry->pubDate; $news_date2 = str_replace(" +0100"," ",$news_date); // take out +0100 timezone from date in entry // URL to the news article $news_article_url = $news_entry->source; // Author of Article $news_author = $news_entry->author; $news_content = $news_entry->description; $news_content2 = strip_tags($news_content,''); $news_content3 = substr($news_content2,0,200); ?> <?php if ($news_content2 != "") { echo "<ul class=\"news_item\"> <li><h2>$news_title2</h2></li> <li><span class='news_date'>$news_date2</span></li> <li>$news_content2...</li> <li><a href=\"$news_article_url\" title='$news_title2' class='readmore' target='_blank'>Read More</a></li> </ul>"; } elseif ($news_content2 == "") { echo "<p class='error'>Sorry, News For This Artist is Currently Unavailable.</p> <img src='images/error.gif' alt='Error' title='Error' class='center' /> <p class='error'>Please try again Later</p>";} ?> <?php } ?> </div>
  12. No it doesnt work. I really cant see why. Any item that contains data echoes out fine, but if there anything that doesnt include data, the error message isn't echoing out for some reason. I cant figure it out, it was working fine last night. I cant remember what part of it I changed, which would be quite nice to know lol. Just an example Artist with News http://cahamilton.at-uclan.com/fyp/query.php?artist=Muse Artist without News http://cahamilton.at-uclan.com/fyp/query.php?artist=Bad+Astronaut+vs.+Armchair+Martian As you can see, the news echoes out nicely without a problem. With the artist with no news, nothing happens. It should generate an error message like the one below it.
  13. Yeh some of it is left out, its part of of a foreach loop, but I only changed that specific segment last night. I couldn't remember what I had done, so I only posted that bit. Ill give it a shot now once my FTP decides to start working...
  14. Can anyone figure out why this IF statement isn't currently working. I was working on part of my website last night and altered the code slightly. Now for some reason, I cant figure out what I did and how to fix it. <?php if ($news_content2 != "") { echo " <ul class=\"news_item\"> <li><h2>$news_title2</h2></li> <li><span class='news_date'>$news_date2</span></li> <li>$news_content2...</li> <li><a href=\"$news_article_url\" title='$news_title2' class='readmore' target='_blank'>Read More</a></li> </ul>"; } elseif ($news_content2 == "") { echo "<p class='error'>Sorry, News For This Artist is Currently Unavailable.</p>"; echo "<img src='images/error.gif' alt='Error' title='Error' class='center' /> "; echo "<p class='error'>Please try again Later</p>"; } ?> <?php } ?>
  15. Great, thanks for explaining that! Its good to know for future tense . Im gradually getting there was PHP lol
  16. Brilliant! Thanks for your help, it worked a treat. So what exactly did the "preg_replace('~\s+~' " part of the code do?
  17. Would it be possible to replace multiple instances of one character for a single replacement instance. For example: String 1 Name1 Surname1 Name2 Surname2 Name3 Surname3 What I want it to look like is: String 1 Result Name1+Surname1+Name2+Surname2+Name3+Surname3 So far I'm using this method: $string1 = str_replace(" ","+",$string 1); And what this is returning is a string like this: String 1 Name1+Surname1++++++Name2+Surname2+++++++++++++++Name3+Surname3++++++++++++++ Would it be possible to do this, as I want to use the result as a URL query?
  18. Taking this feed for example: http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist=muse I'm simply trying to extract the <opensearch:totalResults> of the feed. Because of the structure of this feed is different to all others I have worked with (this is an OpenSearch feed), its proving difficult to understand and get the correct syntax for extracting that element of the feed.
  19. Can anyone tell me how it is possible to parse the "totalResults" item in and OpenSearch XML document such as this one: http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist=ehfdfjfgjvhfgndfobndfhnfdgnhdfh I've been working on it for about 2 hours and I can't seem to figure it out ??? So far I have: <?php $lastFM_url = 'http://ws.audioscrobbler.com/2.0/?api_key=c7d55f27a911c6a0f77040f18758fc5a&method=artist.search&artist='; $lastFM_search_results = $lastFM_url.$artist_query; // read feed into SimpleXML object $lastFM_searchXML = simplexml_load_file($lastFM_search_results); // get summary counts from opensearch: namespace $counts = $lastFM_searchXML->results->children('http://a9.com/-/spec/opensearchrss/1.0/'); $total = $counts->totalResults; ?> Anyone have any ideas?
  20. You my friend, are brilliant! For days I've been trying to figure that out! Just out of interest, what impact does the @ sign have in front of the simplexml_load_file? All my simplexml statements have been without that, but thats seems to have fixed the problem pretty easily.
  21. Hey guys. I'm midway through creating my mashup website and I've run into an error. I've basically written a line of code, that will detect whether or not there is any data contained within the feed sources and output an error message as required. But, I've run into a problem were it is detecting no content from feed sources, where feeds don't exist. I still get the error message I coded in, but a HTTP request failed error message on top of it. Here's an example of what I mean. http://cahamilton.at-uclan.com/fyp/query.php?artist=Amiina Here is a source were the feed exists, but there is no content. Hence the error message is output. http://cahamilton.at-uclan.com/fyp/query.php?artist=jackson+united Here is a source were the feed DOESNT exist. The same error message is output, but with the PHP warnings messages aswell. Would there be any way to work around this and avoid the PHP error messages?
  22. Aha, thanks for your help. Just been pointed in the right direction from one of my friends. Anyone that's interested, this has worked for me: <?php function normaliza ($string){ $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ ßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuy bsaaaaaaaceeeeiiiidnoooooouuuyybyRr'; $string = utf8_decode($string); $string = strtr($string, utf8_decode($a), $b); $string = strtolower($string); return utf8_encode($string); } ?> from here: http://uk.php.net/strtr Cheers premiso
  23. Does anyone know of a function or script that would help me convert special characters such as ê and á to normal characters (e and a)? Rather than str_replace'ing them all, is there a function I can just wrap around my variable to escape and convert all the misc characters?
×
×
  • 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.