ERLEDIGT
NEIN
NEIN
ANTWORTEN
6
6
ZUGRIFFE
274
274
EMPFEHLEN
-
10.04.05 00:33 #1
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:
(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-Code:<?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-Code:<?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)
(Das man die daten von meiner mysql-db etc. sieht juckt mich nich.. is eh nich ans inet angeschlossenPHP-Code:<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>
)
Also die genaue Fehlerzeile ist in der index.php und zwar die erste zeile der while-schleifeAber was ist daran falsch? *grml*PHP-Code:while ($e = mysql_fetch_assoc($link)) {
$link .= '<a href="index.php?id='.$e['id'].'">'.$e['name']."</a><br />\n";
}
help!
Danke schonmal im Voraus!
//Nachtrag:
Also nochma zum Ablauf der index.php:
Code :1 2 3 4
1. Anmelden an datenbank 2. Waehle Datenherkunft aus 3. Speichere Daten + HTML-Code in $link 4. Speicher $link in LINK
Geändert von Suchfunktion (10.04.05 um 00:47 Uhr)
-
10.04.05 00:55 #2
- Registriert seit
- Aug 2003
- Beiträge
- 113
beim ersten Schleifendurchlauf wird $link verändert, dadurch ist es keine gültige MySQL result resource mehr.PHP-Code:$link = mysql_query($sql_link);
while ($e = mysql_fetch_assoc($link)) {
$link .= '<a href="index.php?id='.$e['id'].'">'.$e['name']."</a><br />\n";
}
Viele haben das mit der Demokratie nicht so richtig begriffen.
Man darf in der Demokratie eine Meinung haben,
man muss aber nicht.
Wenn man keine Ahnung hat: einfach mal die Fresse halten.
Ist mir ganz wichtig, dass sich das mal rumspricht.
-
10.04.05 01:23 #3Mein aktueller code, alelrdings haargenau der selbe FehlerPHP-Code:
$link = mysql_query($sql_link);
while ($e = mysql_fetch_assoc($link)) {
$muh .= '<a href="index.php?id='.$e['id'].'">'.$e['name']."</a><br />\n";
}
-
da fehlt irgendwie der Tabellenname, oder?Code :
1
$sql_link = "SELECT * doc_text ORDER BY position ASC";
-
ne da fehlt das FROM
Zitat von Sven Mintel
PHP-Code:$sql_link = "SELECT * FROM doc_text ORDER BY position ASC";
Wie man Fragen richtig stellt
Wichtig: Bitte markiert eure beantworteten Fragen als "erledigt" (links unten auf "Erledigt" klicken).
__________________
.:Mitglied #26 des 1. offiziellen Sven Uwe Fan-Clubs:.
-
Wieauchimmer..da fehlt was
-
10.04.05 11:11 #7
uiuiui.. muss wohl am Rest-Alkohol im Blut gelegen haben
Danke an euch alle
//Nachtrag:
So habs ma ausprobiert.. klappt erste sahne
Vielen, vielen dank..
(Man das war nen doofheitsfehler *grins*)
Ähnliche Themen
-
Fehler in mysql_fetch_assoc
Von Xching im Forum PHPAntworten: 11Letzter Beitrag: 07.12.10, 20:38 -
mysql_fetch_assoc() fehler
Von alex130 im Forum PHPAntworten: 16Letzter Beitrag: 30.05.09, 02:57 -
Problem mit mysql_fetch_assoc
Von Kolloid im Forum PHPAntworten: 4Letzter Beitrag: 21.04.07, 15:58 -
Warning: mysql_fetch_assoc()
Von putzi im Forum PHPAntworten: 9Letzter Beitrag: 21.07.06, 16:44 -
Frage zu mysql_fetch_assoc()
Von maczack im Forum PHPAntworten: 7Letzter Beitrag: 31.01.05, 13:56





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren