Fehler beim auslesen einer Datenbank mit PHP :(

Suchfunktion

Erfahrenes Mitglied
Hallo,

ich moechte mir Werte aus einder MySQL-Datenbank auslesen und in einem html-quelltext uebergeben lassen an eine template-Datei..
(Mh hoffe das habe ich nicht doof erklaert)

Naja hier erstmal der Source:
PHP:
<?php
 include("./config/class_eventmanager.inc.fk");
 require ("./config/config_eventmanager.inc.fk");
 
 $mysql["host"] = $conf['mysql']['host'];
 $mysql["user"] = $conf['mysql']['user'];
 $mysql["password"] = $conf['mysql']['pass'];
 $mysql["database"] = $conf['mysql']['db'];

 mysql_connect($mysql["host"],$mysql["user"],$mysql["password"]);
 mysql_select_db($mysql["database"]);
 
$sql_event = ('SELECT * FROM tbl_event ORDER BY id ASC;');
$_event = mysql_query($sql_event);
while ($e = mysql_fetch_assoc($_event)) {
  $title .= $e['title'];
  $date .= $e['date'];
  $time .= $e['time'];
  $day .= $e['day'];
  $place .= $e['place'];
  $sellart .= $e['sellart'];
  $abo .= $e['abo'];
  $preview .= $e['preview'];
  $extern .= $e['extern'];
  $city .= $e['city'];
  
  $out .= ('<table bordercolor="#e6c8ca" bordercolordark="#e6c8ca" bordercolorlight="#e6c8ca" width="58%" border="2" class="table" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
  	<tr> 
  	    <td width="44" height="43" id="date">
  	      <div class="DayOfMonth">'.$date.'</div>
  		  <div class="DayOfWeek">'.$day.'</div>
	    </td>
	    <td width="244" valign="middle" id="info">
		  <div class="time">'.$time.'</div>
		  <div class="title">'.$title.'</div>
		  <div class="info">
		    <span class="place">'.$place.' </span>
		    <span class="verkauf">| '.$sellart.' </span>
		    <span class="abo">| '.$abo.'</span>
		  </div>
	    </td>
	    <td width="55" valign="top" id="premiere">'.$preview.'</td>
	  <td width="1" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
	  <td width="359" valign="top" id="bla"><!--DWLayoutEmptyCell-->&nbsp;</td>
    </tr>
  </table>
  <br>');
};

$template  = 'content.html';

$var_array = array("TABELLE" => $out);
$tpl = new parser($template, $var_array);
?>

Die Dateien
- content.html
- /config/class_eventmanager.inc.fk
und
- /config/config_eventmanager.inc.fk
existieren und haben auch korrekte Inhalte.

Das Problem bezieht sich auf zeile 16 meines Codes:
PHP:
while ($e = mysql_fetch_assoc($_event)) {...

Hier die Fehlermeldung:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\apache\xampp\htdocs\kalender\index.php on line 16
(Also Fehler in der MySQL-Datenimport-Datei)

Was mache ich falsch?

Danke.
 
Probier mal Folgendes:
PHP:
<?php

	include './config/class_eventmanager.inc.fk';
	require './config/config_eventmanager.inc.fk';


	mysql_connect($conf['mysql']['host'], $conf['mysql']['user'], $conf['mysql']['pass']);
	mysql_select_db($conf['mysql']['db']);

	$query = '
		SELECT
		        `title`,
		        `date`,
		        `time`,
		        `day`,
		        `place`
		        `sellart`,
		        `abo`,
		        `preview`,
		        `extern`,
		        `city`
		  FROM
		        `tbl_event`
		  ORDER BY
		        `id` ASC
		';
	$resul = mysql_query($query) or die('<p><strong>Datenbankabfrage schlug fehl:</strong>'.htmlspechialchars(mysql_error()).'</p><pre>'.htmlspecialchars($query).'</pre>');
	while( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
		$out .= '<table bordercolor="#e6c8ca" bordercolordark="#e6c8ca" bordercolorlight="#e6c8ca" width="58%" border="2" class="table" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
      <tr>
          <td width="44" height="43" id="date">
            <div class="DayOfMonth">'.$row['date'].'</div>
            <div class="DayOfWeek">'.$row['day'].'</div>
        </td>
        <td width="244" valign="middle" id="info">
          <div class="time">'.$row['time'].'</div>
          <div class="title">'.$row['title'].'</div>
          <div class="info">
            <span class="place">'.$row['place'].' </span>
            <span class="verkauf">| '.$row['sellart'].' </span>
            <span class="abo">| '.$row['abo'].'</span>
          </div>
        </td>
        <td width="55" valign="top" id="premiere">'.$row['preview'].'</td>
      <td width="1" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
      <td width="359" valign="top" id="bla"><!--DWLayoutEmptyCell-->&nbsp;</td>
    </tr>
  </table>
  <br>';
	}

	$template  = 'content.html';

	$var_array = array('TABELLE' => $out);
	$tpl = new parser($template, $var_array);

?>
 
Hmm gerade mal ausprobiert.
Bringt mich auch nicht weiter :(

Hier nochmal mein aktueller Source:
PHP:
<?php
 include("./config/class_eventmanager.inc.fk");
 require ("./config/config_eventmanager.inc.fk");

$host = "localhost";
$user = "eventkalender";
$password = "test";
$database = "events";
 
 
 #print ($host.'<host - '.$user.'<user - '.$password.'<password - '.$database.'<Database');
# echo ($host.'<host - '.$user.'<user - '.$password.'<password - '.$database.'<Database');

 mysql_connect($host,$user,$password);
 mysql_select_db($database);

$sql = "SELECT * FROM tbl_event ORDER BY id ASC";
$_result = mysql_query($sql);
echo $_result;
 $data = mysql_query($sql);
 while ($e = mysql_fetch_assoc($data)) {
  $title = $e['title'];
  $date = $e['date'];
  $time = $e['time'];
  $day = $e['day'];
  $place = $e['place'];
  $sellart = $e['sellart'];
  $abo = $e['abo'];
  $preview .= $e['preview'];
  $extern = $e['extern'];
  $city = $e['city'];
  
  $out .= ('<table bordercolor="#e6c8ca" bordercolordark="#e6c8ca" bordercolorlight="#e6c8ca" width="58%" border="2" class="table" cellpadding="0" cellspacing="0">
    <!--DWLayoutTable-->
  	<tr> 
  	    <td width="44" height="43" id="date">
  	      <div class="DayOfMonth">'.$date.'</div>
  		  <div class="DayOfWeek">'.$day.'</div>
	    </td>
	    <td width="244" valign="middle" id="info">
		  <div class="time">'.$time.'</div>
		  <div class="title">'.$title.'</div>
		  <div class="info">
		    <span class="place">'.$place.' </span>
		    <span class="verkauf">| '.$sellart.' </span>
		    <span class="abo">| '.$abo.'</span>
		  </div>
	    </td>
	    <td width="55" valign="top" id="premiere">'.$preview.'</td>
	  <td width="1" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
	  <td width="359" valign="top" id="bla"><!--DWLayoutEmptyCell-->&nbsp;</td>
    </tr>
  </table>
  <br>');
};

$template  = 'content.html';

$var_array = array("TABELLE" => $out);
$tpl = new parser($template, $var_array);
?>

Selbe Fehlermeldung,
selbe Zeile.
(also mit dem "mysql_fetch_assoc")

Weiss jemand was ich da falsch gemacht habe?
 
Wende mal die Hinweise unter Punkt c) in den Regeln des PHP-Boards an.
Mit der entsprechenden MySQL-Fehlermeldung kann man Dir viel besser helfen.

Gumbo hat den Hinweis in seinem Code übrigends beherzigt.

Gruß hpvw
 
Ah ich knallkopf habe die rechtevergabe nicht beachtet.. laeuft jetzt alles :)

Danke :)
 
Zuletzt bearbeitet:
Zurück