Fehler im Script - ich finde ihn nicht!

PHP:
substr($comm["comment"], 0, 50)

Schöner ist es jedoch so:

PHP:
substr($comm["comment"], 0, strpos($comm["comment"], ".", 50))
 
Wahrscheinlich dort, wo der Kommentar ausgegeben werden soll, oder?
Sprich letzte zeile, vor das <br>-Tag, wo jetzt die volle Ausgabe des Kommentars ist.
 
Sieht jetzt so aus:
PHP:
mysql_connect($host, $user, $pass); 
mysql_select_db($db); 

$abfrage = "SELECT * FROM corenews2_comments ORDER BY time DESC LIMIT 0,10"; 
$result = mysql_query($abfrage); 

while ($comm = mysql_fetch_array($result)) 

echo "<a href='http://www.eblogx.de/index.php?&comments=".$comm["news_id"]."'>".$comm["author"]."</a>: substr($comm["comment"], 0, strpos($comm["comment"], ".", 50))<br>";

und es kommt folgende Fehlermeldung:
Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/htdocs/v150119/lastcomments.php on line 15

Zeile 15 ist in diesem Fall die Zeile mit "echo".

Mfg Ragey
 
Ok ich habs, so funktioniert es:
PHP:
mysql_connect($host, $user, $pass); 
mysql_select_db($db); 

$abfrage = "SELECT * FROM corenews2_comments ORDER BY time DESC LIMIT 0,10"; 
$result = mysql_query($abfrage); 

while ($comm = mysql_fetch_array($result)) 

echo "<a href='http://www.eblogx.de/index.php?&comments=".$comm["news_id"]."'>".$comm["author"]."</a>: ".substr($comm["comment"], 0, 30)."<br>";

Mfg Ragey
 
Du kannst auch den zweiten Code nehmen:

PHP:
echo "<a href='http://www.eblogx.de/index.php?&comments=".$comm["news_id"]."'>".$comm["author"]."</a>: ".substr($comm["comment"], 0, strpos($comm["comment"], ".", 50))."<br>";

Sonst sollten die Kommentare so "abgehackt" aus


:p
 
Zurück