Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:03:35+00:00 2026-06-01T23:03:35+00:00

I know my code is messy, I am very new to this and am

  • 0

I know my code is messy, I am very new to this and am learning as I go.

My site is this: http://itsalllegit.com (currently running off my home computer and using the tvdb api so its a bit slow at times).

Most of it appears to work, currently the only thing that doesn’t is NCIS as shown here: http://itsalllegit.com/season.php?sid=72108&season=1.

I know its bad and long but here is my code… I’m stuck hard on this one and help would be greatly appreciated (so would any tips on making it better in general).

btw… if I echo $url3 it comes up with "(*#YR&(^#R(@$#%$&^@#%$*@#%$&^@$#&" and so on.

    <html>
    <head>
        <title>Saars - Homepage</title>
            <link rel="stylesheet" type="text/css" href="default.css" />
    </head> 
        <body>
            <?php

                $series_id = $_GET["sid"];
                $season_number = $_GET["season"];
                $local_path = "images/Banner/".$series_id."-Banner.jpg";
                $url1 = file_get_contents("http://thetvdb.com/api/E676DF9578EF38D7/series/".urlencode($series_id));
                $xml = simplexml_load_string($url1);
                $series_name = $xml->Series[0]->SeriesName;
                $series_rating = $xml->Series[0]->Rating;
                $series_network = $xml->Series[0]->Network;
                $series_status = $xml->Series[0]->Status;
                    echo '<img src="'.$local_path.'"><br />';
                    echo "Name: ".$series_name."<br />";
                    echo "Rating: ".$series_rating."<br />";
                    echo "Network: ".$series_network."<br />";
                    echo "Status: ".$series_status."<br />";
                    echo "<hr />";
                        echo '<table bgcolor="#000000">';
                            echo '<tr>';
                                echo '<td width="30">';
                                    echo '<font color="white">#</font>';
                                echo '</td>';
                                echo '<td width="500">';
                                    echo '<font color="white">Episode Name</font>';
                                echo "</td>\n";
                                echo '<td width="100">';
                                    echo '<font color="white">First Aired</font>';
                                echo "</td>\n";
                            echo "</tr>\n";
                        echo "</table>";
                for ($episode_number = 1; $episode_number <= 200; $episode_number++) {
                    $url2 = "http://thetvdb.com/api/E676DF9578EF38D7/series/".$series_id."/default/".urlencode($season_number)."/".urlencode($episode_number)."/en.xml";
                    $handle = @fopen($url2, 'r');
                    if ($handle === false) {
                        return;
                    } else {
                        $url3 = file_get_contents("http://thetvdb.com/api/E676DF9578EF38D7/series/".$series_id."/default/".urlencode($season_number)."/".urlencode($episode_number)."/en.xml");
                        $xml = simplexml_load_string($url3);
                        $episode_name = $xml->Episode[0]->EpisodeName;
                        $episode_rating = $xml->Episode[0]->Rating;
                        $episode_firstaired = $xml->Episode[0]->FirstAired;
                        $episode_overview = $xml->Episode[0]->Overview;
                        $column1 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_number.'</a>';
                        $column2 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_name.'</a>';
                        $column3 = '<a href="episode.php?sid='.$series_id.'&season='.$season_number.'&episode='.$episode_number.'">'.$episode_firstaired.'</a>';
                            echo '<table>';
                                echo "<tr>\n";
                                    echo '<td width="30">';
                                        echo $column1;
                                    echo "</td>\n";
                                    echo '<td width="500">';
                                        echo $column2;
                                    echo "</td>\n";
                                    echo '<td width="100">';
                                        echo $column3;
                                    echo "</td>\n";
                                echo "</tr>\n";
                            echo "</table>";
                    fclose($handle);
                    }
                }
                ?>
        </Body>
    </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:03:36+00:00Added an answer on June 1, 2026 at 11:03 pm

    You are opening each URL twice but only reading the data once. The server may rejecting this behaviour as slamming and rejecting the second connection after a while. Try changing the contents of the loop to this:

    // Define the URL
    $url2 = "http://thetvdb.com/api/E676DF9578EF38D7/series/$series_id/default/".urlencode($season_number)."/".urlencode($episode_number)."/en.xml";
    
    // Try and fetch the XML
    // You are returning a value - are you in a function? Should you maybe break; instead?
    if (!$xmlStr = file_get_contents($url2)) return FALSE;
    if (!$xml = simplexml_load_string($xmlStr)) return FALSE;
    
    // Get data
    $episode_name = $xml->Episode[0]->EpisodeName;
    $episode_rating = $xml->Episode[0]->Rating;
    $episode_firstaired = $xml->Episode[0]->FirstAired;
    $episode_overview = $xml->Episode[0]->Overview;
    
    // Output HTML
    // A single-row table per record? Maybe you should have one table with multiple rows?
    $epURL = htmlspecialchars("episode.php?sid=$series_id&season=$season_number&episode=$episode_number");
    echo "
    <table>
      <tr>
        <td width='30'><a href='$epURL'>$episode_number</a></td>
        <td width='500'><a href='$epURL'>$episode_name</a></td>
        <td width='100'><a href='$epURL'>$episode_firstaired</a></td>
      </tr>
    </table>";
    

    If it still doesn’t work, try echoing out $url2 in the loop to see what it contains when you get the errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would i go about this? I tried Net::HTTP.new(@site).head('/').kind_of? Net::HTTPOK but I receive this:
Can someone take a look at this menu http://www.abmoldremediationnj.com/3 and let me know how
Is there a way to know when code is being called from running a
In code: //I know that to get this effect (being able to use it
Does anyone know why this code doesn't work. This means, the alert is NOT
I know that there are several very similarly-related questions on this website, however after
I am running a short bit of code that will occasionally (very rarely) Access
I know the code is missing (Someone will give negative numbers). But I only
I know inline code is preferable, but there's a bunch of code that's needed
I know the code to make an image grow in size is: imageView.transform =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.