Suchfunktion
Erfahrenes Mitglied
Aloah, bzw. Morgen
Erstmal vorweg:
Im grossen und ganzen stammt die Vorlage fuer das Templatesystem von Nils Hitze.
Ich habe nur alle Kommentare geloescht weil der source hier sonst viel zu gross wird.
Und los:
Also ich bin auch gerade testweise dabei ein cms zu schreiben, allerdings haenge ich gerade an einem fehler.
Hier die Fehlermeldung:
Und hier mein source:
index.php
class_muhkuh.inc.php:
content.html (Ausgabeseite)
(Das man die daten von meiner mysql-db etc. sieht juckt mich nich.. is eh nich ans inet angeschlossen )
Also die genaue Fehlerzeile ist in der index.php und zwar die erste zeile der while-schleife
Aber was ist daran falsch? *grml*
help!
Danke schonmal im Voraus!
//Nachtrag:
Also nochma zum Ablauf der index.php:
Erstmal vorweg:
Im grossen und ganzen stammt die Vorlage fuer das Templatesystem von Nils Hitze.
Ich habe nur alle Kommentare geloescht weil der source hier sonst viel zu gross wird.
Und los:
Also ich bin auch gerade testweise dabei ein cms zu schreiben, allerdings haenge ich gerade an einem fehler.
Hier die Fehlermeldung:
(Tjaja.. die misterioese 23.. heil eris diskordia! )Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\foobar\test.php on line 23
Und hier mein source:
index.php
PHP:
<?php
include("class_muhkuh.inc.php");
$mysql["host"] = "127.0.0.1";
$mysql["user"] = "root";
$mysql["password"] = "";
$mysql["database"] = "lalune";
if(!isset($_GET["id"])) $id = 1;
if(!isset($id)) $id = $_GET["id"];
mysql_connect($mysql["host"],$mysql["user"],$mysql["password"]);
mysql_select_db($mysql["database"]);
$sql = "SELECT * FROM doc_desc, doc_text "
. "WHERE doc_desc.c_id = doc_text.id AND doc_text.id = $id";
$sql_link = "SELECT * doc_text ORDER BY position ASC";
$_result = mysql_query($sql);
$_array = mysql_fetch_assoc($_result);
$link = mysql_query($sql_link);
while ($e = mysql_fetch_assoc($link)) {
$link .= '<a href="index.php?id='.$e['id'].'">'.$e['name']."</a><br />\n";
}
$title = $_array["title"];
$sitename = $_array["name"];
$css = $_array["css"];
$template = $_array["template"];
$text = $_array["text"];
$date = $_array["date"];
$var_array = array("TITLE" => $title,
"SITENAME" => $name,
"CSS" => $css,
"MAIN" => $text,
"DATE" => $date,
"LINK" => $link);
$tpl = new parser($template, $var_array);
?>
class_muhkuh.inc.php:
PHP:
<?php
Class parser
{
var $template;
var $temp_content;
function parser($template, $var_array)
{
$this->template = $template;
$this->temp_content = file($this->template);
$parsed = $this->rplc($var_array);
echo(implode("", $this->temp_content));
}
function rplc($var_array)
{
foreach($var_array as $key => $value)
{
$regex['var_name'] = "#{[[:space:]]*?(".strtoupper($key)."){1,}?[[:space:]]*?}#si";
$this->temp_content = preg_replace($regex['var_name'], $value, $this->temp_content);
}
}
}
?>
content.html (Ausgabeseite)
PHP:
<html>
<head>
<title>{TITLE}</title>
<link rel="Stylesheet" href="{CSS}" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Stil1 {color: #000000}
-->
</style>
</head>
<body>
<div align="center">
<p> </p>
<table width="700" border="1" class="text">
<tr>
<td width="150"> </td>
<td colspan="3"> </td>
<td width="150"> </td>
</tr>
<tr>
<td width="150"> </td>
<td colspan="3"><div align="left">{SITENAME}</div></td>
<td width="150"> </td>
</tr>
<tr>
<td width="150">{LINK}</td>
<td width="5"> </td>
<td>{MAIN}</td>
<td width="5"> </td>
<td width="150"> </td>
</tr>
<tr>
<td width="150"> </td>
<td colspan="3"><div align="right">{DATE}</div></td>
<td width="150"> </td>
</tr>
<tr>
<td width="150"> </td>
<td colspan="3"> </td>
<td width="150"> </td>
</tr>
</table>
</div>
</body>
</html>
(Das man die daten von meiner mysql-db etc. sieht juckt mich nich.. is eh nich ans inet angeschlossen )
Also die genaue Fehlerzeile ist in der index.php und zwar die erste zeile der while-schleife
PHP:
while ($e = mysql_fetch_assoc($link)) {
$link .= '<a href="index.php?id='.$e['id'].'">'.$e['name']."</a><br />\n";
}
Aber was ist daran falsch? *grml*
help!
Danke schonmal im Voraus!
//Nachtrag:
Also nochma zum Ablauf der index.php:
Code:
1. Anmelden an datenbank
2. Waehle Datenherkunft aus
3. Speichere Daten + HTML-Code in $link
4. Speicher $link in LINK
Zuletzt bearbeitet: