Hallo, hab mit folgendem script das Problem, das meine url`s aus der datenbankabfrage nivht in anklickbare links umgewandelt werden.
PHP
<?php
function html_links($str) {
$str = preg_replace('"(((f|ht){1}tp://)[a-z0-9-.] [.]{1}[a-z]{1,6}[-a-z0-9@:%_$.! *, .~#;?&//=]*)"i', '<a href="$1">$1</a>', $str);
$str = preg_replace('"([snr>]{1}|^)((www.)[a-z0-9-]{1,255}[.]{1}[a-z]{1,6}[-a-z0 -9@:%_$.!*, .~#;?&//=] )"i', '$1<a href="http://$2">$2</a>', $str);
$str = preg_replace('"(([snr>]){1}|mailto:|^)(([-a-z0-9@:%_$.!*,; .~#;?&//=] )@([a-z0-9-.] [.]{1}[a-z]{1,6}))"i', '$2<a href="mailto:$3">$3</a>', $str);
$str = preg_replace('"(((f|ht){1}tp://)([0-9]{1,3}([./sn]|$){1}){4}[-a-z0-9@:%_$.!*, .~#;?&//=]*)"i', '<a href="$1">$1</a>', $str);
return $str;
}
$host = "localhost";
$user = "user";
$pass = "password";
$dbase = "database";
$connection = mysql_connect("$host" , "$user" , "$pass")
OR die ("Keine Verbindung zu der Datenbank moeglich.");
$db = mysql_select_db($dbase , $connection)
OR die ("Auswahl der Datenbank nicht moeglich.");
$x = $_GET['nid'];
$query = "SELECT * FROM files,node_revisions WHERE files.nid = '$x' AND node_revisions.nid = '$x' AND files.filename = '_original' ";
$abfrage = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($abfrage)) {
$title = $row['title'];
$bild = $row['filepath'];
$body = $row['body'];
echo "<tr><td><strong>".$title."</strong></td></tr><br><br>";
echo "<tr><td><img src=\"".$bild."\" title=\"\" alt=\"\"></td><tr>\n";
echo "<tr><td><pre>".html_links($body)."</pre></td></tr><br>";
echo "<a href=\"index.php\">zurück</a>";
}
mysql_close();
?>
Alles anzeigen