Hallo,
ich habe mir ein eigenes PHP Script geschrieben, welches mir ein derzeit laufendes Event aus einer Datenbanktabelle (andere als die von WP) ausgibt.
Hier der Code für das auslesen sendeplan.php [LEFT]
<?php
class Sendeplan {
private $properties_file = 'ical2sendeplan.properties';
private $config = null;
private $db = null;
public function __construct()
{
if ( file_exists( "/etc/funky/$this->properties_file" ) )
{
$this->config = parse_ini_file( "/etc/funky/$this->properties_file" );
}
elseif ( file_exists( getenv( 'HOME' ) . "/.$this->properties_file" ) )
{
$this->config = parse_ini_file( getenv( 'HOME' ) . "/.$this->properties_file" );
}
else
{
die( "Couldn't find neither /etc/funky/$this->properties_file nor " . ( getenv( 'HOME' ) ) . "/.$this->properties_file file.\nAborting\n" );
}
}
public function getCurrent()
{
$this->db = mysql_connect('localhost', $this->config[ 'SQL_USER' ], $this->config[ 'SQL_PASSWORD' ] );
if ( !$this->db )
{
die( 'No connection: ' . mysql_error() );
}
mysql_select_db( $this->config['SQL_DATABASE'] ) or die( 'Couldn\'t select database '.$this->config['SQL_DATABASE']."\n" );
mysql_query( "SET NAMES 'utf8'" ) or die( mysql_error() );
$current = time();
$result = mysql_query( "SELECT * FROM ".$this->config[ 'SQL_TABLE' ]." WHERE $current>start AND $current<stop" ) or die( mysql_error() );
if ( mysql_num_rows( $result ) )
{
$item = mysql_fetch_array( $result );
mysql_close( $this->db );
return $item;
}
else
{
mysql_close( $this->db );
return array(
'start'=> -1,
'stop'=>-1,
'name'=>"BBC world service",
'description' => "Aktuell macht radio hsf eine Sendepause. Außerhalb unserer Sendezeit hört Ihr über UKW den <i>BBC world service</i> und im Campuskabel <i>radio eins</i>.",
'log'=>0,
'stream'=>0,
'rerun'=>0,
'dlf'=>0,
'url'=>'http://www.bbc.co.uk');
}
}
}
?>
Alles anzeigen
Und dann noch das Anzeigen des Ergebnisses onair.php
<?php
include_once( 'sendeplan.php' );
$plan = new Sendeplan();
$current = $plan->getCurrent();
// Aktuelle Sendung
if ( $current['start'] == -1 && $current['stop'] == -1 )
{
// OffAir
echo '<b>OffAir</b>'.$current['name'];
}
else
{
// iswiradio
echo '<b>OnAir</b>'.$current['name'];
}
?>
Alles anzeigen
Aufgerufen wird es im Template ganz normal mit <?php include('onair.php'); ?>.
Ja, an dem Script gibt es selbst kein Problem. :D
Aber in Verbindung mit WORDpress dann irgendwie schon. Folgender Fehler wird angezeigt:
Warning: mysql_error(): 10 is not a valid MySQL-Link resource in /var/www/iswiradio-blog/wp-includes/wp-db.php on line 601
Die entsprechende Zeile sieht in der wp-db.php dann folgendermaßen aus
/**
* Perform a MySQL database query, using current database connection.
*
* More information can be found on the codex page.
*
* @since 0.71
*
* @param string $query
* @return unknown
*/
function query($query) {
...
// If there is an error then take note of it..
if ( $this->last_error = mysql_error($this->dbh) ) { // line 601
$this->print_error();
return false;
}
...
}
Alles anzeigen
Die ist übrigens nicht modifiziert.
Allerdings ist die Warnmeldung für mich nicht nachvollziehbar. Kann mir einer den Grund verraten?
*Update* Das Problem tritt nur auf Seiten auf, die ein PlugIn beinhalten. In meinem Falle NextGen und podPress.
[/LEFT]