Forums Archive Index > Cool free scripts > Blank line at end error
Date: 17 Jun 2005 8:00 am
Hello!
I'm using the script dinamically with php with this piece of script:
Code:
<?php
$resultado=mysql_query("select * from destaquesccipd order by cod desc") or die("Erro ao listar tabela");
$ticker_output="";
while ($line = mysql_fetch_array($resultado))
$ticker_output.="['index.php?id=info&lista=0&cod=".$line[0]."','<span class=titulo><b>".$line[1]."</b></span><br>".$line[2]."','_self'],";
$ticker_output=substr($ticker_output,0,-1); // removes the last comma
echo $ticker_output;
?>
Then I have a textare that inserts the content in a database. The problem is that when that content is inserted with an Enter at the end (a new blank line) the script doesn't load.
Any ideas?
Thanks in advance!
Date: 17 Jun 2005 3:47 pm
I think it should work this way:
<?php
$resultado=mysql_query("select * from destaquesccipd order by cod desc") or die("Erro ao listar tabela");
$ticker_output="";
while ($line = mysql_fetch_array($resultado)){
if (substr($line[1],-2) == "\r\n")
$line[1]=substr($line[1],0,-2);
if (substr($line[2],-2) == "\r\n")
$line[2]=substr($line[2],0,-2);
$ticker_output.="['index.php?id=info&lista=0&cod=".$line[0]."','<span class=titulo><b>".$line[1]."</b></span><br>".$line[2]."','_self'],";
}
$ticker_output=substr($ticker_output,0,-1); // removes the last comma
echo $ticker_output;
?>
Please try it and let me know..