1
<?php 

  include("config.inc.php"); 

header("Cache-Control: no-cache, must-revalidate"); 
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"; 
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">"; 
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">"; 

    echo "<head>"; 
    echo "<title>$stitle</title>"; 
    echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"theme/theme.css\" />"; 
    echo "</head>"; 

?> 

<head> 
<META HTTP-EQUIV="Refresh" Content="10"> 
</head> 
<?php 

    echo "<body>"; 


echo "<p align=\"center\">"; 

echo "Live Score: 
--- 
"; 
$feed = "http://www.scorespro.com/rss/live-soccer.xml"; 
$fp = @fopen($feed,"r"); 
while(!feof($fp)) $raw .= @fgets($fp, 4096); 
fclose($fp); 
if( preg_match("/<item>(.*)<\/item>/", $raw, $rawitems ) ) { 
$items = explode("<item>", $rawitems[0]); 

  $p = 5; 
  if ($npage == "")$npage = "1"; 
  $countfile= count($items); 
  $countfile=$countfile-2; 
  $first=($npage*$p)-$p; 
  $npages = ceil($countfile / $p); 
  $items = array_reverse($items); 
  $next_arrays=($first+($p-1)); 
  if($next_arrays>$countfile)$next_arrays=$countfile; 
  for ($i=($first); $i <= $next_arrays; $i++) { 
    preg_match("<title>(.*)</title>",$items[$i+1], $title ); 
    preg_match("<link>(.*)</link>",$items[$i+1], $url ); 
    preg_match("<description>(.*)</description>",$items[$i+1], $description);  


  $title[1] =  str_replace("'", "", $title[1]); 
  $title[1] =  str_replace("& ", "&amp;", $title[1]); 
  echo $title[1].' '; 

  } 
} 
// if ($npage <= $npages and $npage>1) $gline_rew = '[url="'.$_SERVER["]Prev[/url] '; 
// if ($npages > 1 and $npage<$npages) $gline_next = ' [url="'.$_SERVER["]Next[/url]'; 
// echo " 
// --- 
// Page {$npage} of {$npages} 
// ".$gline_rew.$gline_next." 
// --- 
// "; 

echo "</small>\n"; 
echo "</p>"; 
echo "</body>"; 
echo "</html>"; 
?> 
<?php
public_static_function getInstance() {
  static $instance;
  $class = $title;

  if ( ! $instance instanceof $class) {
     $instance = new $class;
  }

  return $instance;
}

Hello! I am making a live-score site using PHP. But when I use this code and run it, I get a blank page. I hope that I will find the mistake by myself but for now I can`t. I would be happy if someone knows where the mistake is and help me. Thank you in advance !!!

a2800276
  • 3,272
  • 22
  • 33
Jough Drak
  • 17
  • 3
  • blank page could mean syntax errors http://php.net/manual/en/function.error-reporting.php and make sure it's `.php` and PHP is running. – Funk Forty Niner Dec 16 '15 at 14:37
  • Do you think you can turn this into an [MVCE](http://stackoverflow.com/help/mcve), doing so might well help you track down the error yourself. – DaveyDaveDave Dec 16 '15 at 14:38

2 Answers2

1

This is wrong

public_static_function getInstance() {

It should be

public static function getInstance() {

Also add error_reporting(E_ALL) when you have blank page(Which means you have errors)

Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41
0

Even when fixed, this will not work:

public static function getInstance() {
    static $instance;
    $class = $title;
    ...
}

Furthermore we have simpleXML_load_str() for handling RSS (or other XML) strings.

I think what you want is a decent way to handle an RSS feed. Have a look at this post about RSS feeds

Good luck!

Community
  • 1
  • 1
Lapidi
  • 116
  • 4