...

View Full Version : click link creates file over a template - file error : warning ....



thondra
01-28-2010, 01:56 AM
hello to all of you

i am writing here today, because i got a problem and need your help

i got a mysql database, there i got a table.

i got now a file where i read some informations into a table on a template with the id





<?php
require_once ('connect.php');
$db_link = mysql_connect (MYSQL_HOST, MYSQL_USER, MYSQL_PASS);

$db_sel = mysql_select_db( MYSQL_DATA )
or die("Auswahl der Datenbank fehlgeschlagen");

$sql = "SELECT * FROM table WHERE uk = 'bilder'";

$db_erg = mysql_query( $sql );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysql_error());
}

echo '<table>';

while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{

$id = $zeile['id'];
echo "<tr><td>";
echo "<a href=\"_detail.php?id=".$id."\">".$zeile['name']."</a>"."<br>";
echo $zeile['ort'] . "<br>";
echo $zeile['kurzbeschreibung'] . "</td></tr>";
}
echo "</table>";
mysql_free_result( $db_erg );
echo "<br/>";

?>
</table>


this template got the following code :



<?php
require_once ('connect.php');
$db_link = mysql_connect (MYSQL_HOST, MYSQL_USER, MYSQL_PASS);

$db_sel = mysql_select_db( MYSQL_DATA )
or die("Auswahl der Datenbank fehlgeschlagen");

$id = $_GET['id'];
$anfrage = "SELECT * FROM tabelle WHERE id = $id";
$db_erg = mysql_query( $anfrage );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysql_error());
}
if ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{

echo "<html><head>";
echo "<title>".$zeile['name']."</title>";
echo "</head>";
echo "<body>";

echo "<table>";
echo "<tr>";
echo "<td><div><font face=\"Arial\"><b>".$zeile['name']."</b></font></div></td>";
echo "</tr>";
echo "</table>";

echo "<tr>";
echo "<td><div><font face=\"Arial\">".nl2br($zeile['langbeschreibung'])."<br></font></div></td>";
echo "</tr>";

echo "<tr>";
echo "<td ><div><font face=\"Arial\"><br/><br/><img src=\"images/".$zeile['screenshot_link']."\"><br></font></div>";
echo "</tr>";

}

echo "</table>";
mysql_free_result($db_erg);
echo "<br/>";
?>
</body></html>


sofar everything worked fine, but this way i have just a file wich opens for reading and vanishes again (dynamic? SP?), but i wanted a fix file (so you can find it with google too), and so i tried to call the file from the table and create a file

therefore i wrote this code :



<?php
require_once ('connect.php');
$db_link = mysql_connect (MYSQL_HOST, MYSQL_USER, MYSQL_PASS);

$db_sel = mysql_select_db( MYSQL_DATA )
or die("Auswahl der Datenbank fehlgeschlagen");

$sql = "SELECT * FROM tabelle WHERE uk = 'bilder'";

$db_erg = mysql_query( $sql );
if ( ! $db_erg )
{
die('Ungültige Abfrage: ' . mysql_error());
}

echo '<table>';

while ($zeile = mysql_fetch_array( $db_erg, MYSQL_ASSOC))
{

$id = $zeile['id'];
$file = '_detail.php';
$newfile = $zeile['name'].".php";

if (!copy($file, $newfile))
{
echo "failed to copy $file...\n";
}

echo "<tr><td>";
echo "<a href=\"";
echo $newfile;
echo "?id=".$id;
echo "\">".$zeile['name']."</a>"."<br>";

echo $zeile['ort'] . "<br>";
echo $zeile['kurzbeschreibung'] . "</td></tr>";
}
echo "</table>";
mysql_free_result( $db_erg );
echo "<br/>";

?>
</table>


i got now 2 entries in the data table, and an output of a table with 2 entries
if i click on the link, it creates the file, and all displays properly.
my problem now :
it creates a file with the name text_read.php?id=401
but it saves the file into the folder with name text_read.php

so if i try to call the file with name text_read.php, i get a error :
Ungültige Abfrage: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

i supose, here its missing the $_GET(id) information i gave from the other file ....
i guess i have to search for the record where it says text_read in, and get the id working somehow.

but with all the reading and searching i dont get along (i dont realy understand the manual descriptions, they are like chinese to me) and i cant find a sample i can try out

maybe someone here can help me please ?
i dont want anyone to do my work - but i am realy stupid when it comes to understand programming language




ps
sorry for posting in german first time .... i didnt even realise it somehow



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum