Jump to content

pealo86

Members
  • Posts

    60
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.mattpealing.co.uk

Profile Information

  • Gender
    Not Telling

pealo86's Achievements

Member

Member (2/5)

0

Reputation

  1. I'm using the following script on my website, it used to work fine but now it just outputs 'error' from the else statement: <?php $username = 'pealo86'; $scrobbler_url = "http://ws.audioscrobbler.com/2.0/user/" . $username . "/recenttracks"; $scrobbler_cache_file = 'scrobbler_' . $username . '_data.cache'; if (file_exists($scrobbler_cache_file)) { if (time() - filemtime($scrobbler_cache_file) > 180) { // if the file was created more than 3 minutes ago then delete. unlink($scrobbler_cache_file); } else { $scrobbler_url = realpath('./' . $scrobbler_cache_file); } } if ($scrobbler_xml = file_get_contents($scrobbler_url)) { $scrobbler_data = simplexml_load_string($scrobbler_xml); if (!file_exists($scrobbler_cache_file)) { file_put_contents($scrobbler_cache_file, $scrobbler_xml); } // limit to 3 songs $count = 0; echo '<ul id="feed-lastfm">'; foreach ($scrobbler_data->track as $track) { if ($count == 3) { break; } else { $string = '<li>'; $string .= '<div class="cover">'; if ($track->image[1] != '') { $string .= '<a href="' . $track->url . '"><img src="' . $track->image[1] . '" alt="' . $track->album . '" /></a>'; } $string .= '</div>'; $string .= '<div class="content">'; $string .= '<span class="title"><a href="' . $track->url . '"><strong>' . $track->artist . '</strong>: ' . $track->name . '</a></span>'; if (!$track->date) { $date = '<span class="highlight-00a2f5 currently-listening">Currently Listening</span>'; } else { $date = 'Played: ' .$track->date; } $string .= '<span class="date">' . $date . '</span>'; $string .= '</div>'; $string .= '</li>'; echo $string; $count ++; } } echo '</ul>'; } else { echo 'error'; } ?> I got the script from here: - http://www.hashbangcode.com/blog/simple-php-code-get-lastfm-last-played-tracks-605.html Does anyone have any idea what I'm missing?
  2. I am positioning an anchor like so: #test-link { position: relative; bottom: 100px } As I need it so that when I visit #test-link the page jumps down to that particular section, but 100px higher. Otherwise the page scrolls too far down for what I need. This works fine in decent browsers, however in IE7, 8 and 9 the relative positioning gets completely ignored. I've tried different ways to fix it such as adding text to the anchor as well as various CSS properties (e.g. display: block) however nothing makes any difference. Does anyone have any ideas?
  3. Ahhh yes! I didn't think it would be needed in my WP loop, but obviously it is! Thanks again.
  4. Thank you! The script appears to work fine on it's own, however in my WordPress loop it behaves the same as the previous solution. In that it gives me I have no idea why this is! My WordPress loop is like so: <?php query_posts('post_type=team-member&posts_per_page=-1&orderby=menu_order&order=ASC'); ?> <?php if(have_posts()) : ?> <?php $count = 1; ?> <div id="feed" class="feed"> <?php while(have_posts()) : the_post(); ?> <?php // determine alpha / omega class if (($count - 1) % 4 == 0) { $grid = 'alpha'; } elseif ($count % 4 == 0) { $grid = 'omega'; } echo '<br class="clear" />'; echo '<p>' . $count . ' ' . $grid . '</p>'; echo '<br class="clear" />'; ?> <?php $count ++; ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_query(); ?> I'm not sure how familiar with WordPress anyone here is, but can you think of any reason why it might be doing this? :/
  5. Ahhh no, what I'd like is something like the following: If you could let me know how to acheive this with the modulus operator that would be great
  6. Hmmm okay this is confusing, I've simplified my WordPress loop like so: <?php query_posts('post_type=team-member&posts_per_page=-1&orderby=title&order=ASC'); ?> <?php if(have_posts()) : ?> <?php $count = 1; ?> <div id="feed-the-team" class="feed"> <?php while(have_posts()) : the_post(); ?> <?php // determine alpha / omega class if ($count % 4 == 1) { $grid = 'alpha'; } elseif ($count % 4 == 0) { $grid = 'omega'; } ?> <h2><?php echo $grid; ?></h2> <?php $count ++; ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_query(); ?> Yet it's outputting the following: Am I missing something really obvious here?
  7. Just tested in a basic PHP file and it seems to work! There must be something in my WP loop that I haven't spotted so I'll look into it further. Thanks again!
  8. Thanks! That's what I mean yes, however those snippets of code seem to return true on iterations 1, 2 and 3 instead of just 1. I should probably point out, $count starts off at 1 as opposed to 0. But I can't seem to get it to work either way?
  9. Thanks, but that's not what I meant exactly. I suppose a better way of putting it is to say every 4th iteration, but starting from the first if that makes sense?
  10. I can use the modulus operator to target a specific iteration of a loop... other than the first! As dividing by '1' will obviously never give a remainder. Here is the code I'm using: <?php // determine alpha / omega class if ($count % 1 == 0) { // do this } elseif ($count % 4 == 0) { // do that } ?> Can anyone see another way around it?
  11. Oops, managed to fix it in the end. Turns out it's more common than I thought: http://stackoverflow.com/questions/6111823/disable-horizontal-scrollbar-due-to-a-div-with-positionabsolute-which-is-outsid Adding left:-100px is fine but browsers don't seem to like it on the right!? Thanks anyway though!
  12. On the following page: http://www.mattpealing-server.co.uk/~devcurti/ I'm positioning #banner-disc like so: #banner-disc { background: url("../image/banner-disc.gif") repeat scroll 0 0 transparent; clear: both; display: block; height: 270px; margin-right: -100px; position: absolute; right: 0; top: 0; width: 846px; z-index: 0; } However it's causing a horizontal scrollbar at a 1024px wide display. I've tried other ways of positioning the element, even using relative positioning. However I just can't seem to get rid of the scrollbar. Can anyone else see what I'm doing wrong?
  13. I'm using the following code as I don't want people to view singular custom posts. If they try to visit one, I want them to get forwarded to a page: <?php // forward necessary single custom posts $forward = 0; if(is_singular('external-link')) { $location = get_permalink(12); $forward = 1; } if ($forward == 1) { header('Location: ' . $location); } exit; ?> However even with error reporting turned on I just get a blank white screen. I normally use the following script on most websites I make: <?php // forward necessary single custom posts if(is_singular('external-link')) { $location = get_permalink(12); $forward = 1; } if ($forward) { header('Location: ' . $location); } exit; ?> However on this site it is just giving me this error: Notice: Undefined variable: forward in /home/devspare/public_html/wp-content/themes/sparetimetocash/header.php on line 8 Can anyone see any issues?? It seems like if I resolve the error messages all I get is a white screen of death
  14. I've set up a form in the sidebar of: - http://www.mattpealing-server.co.uk/~devashwo/ When the form is submitted, the results are supposed to be displayed in the iframe on this page: - http://www.mattpealing-server.co.uk/~devashwo/search/ However as you can see, if you submit the form from the homepage, the page strangely opens up in a new tab (and the form data isn't posted properly to the iframe resulting in an error message). Also, if you try to submit the form from the search page itself, sometimes the page you are browsing then opens up in the iframe. (see attached image). This doesn't appear to happen all the time however, it seems to be an intermittent problem. I've set my form up like so: <form action="<?php echo get_permalink(17); ?>" method="post" target="vebra"> and my iframe: <iframe id="vebra" name="vebra" src="http://www.vebra.com/home/quick/PFresults.asp"></iframe> But cannot see anything wrong with the code that would cause bizarre errors such as this?
×
×
  • 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.