CODE
<?php
include("conf.php");
function crunch($tx,$lg) {
$tmp = 0;
if(strlen($tx)>$lg) $tmp = strpos($tx," ",$lg);
if($tmp) $tx2 = substr($tx,0,$tmp);
else $tx2 = substr($tx,0,$lg);
if($tx2!=$tx) $tx2.=" ...";
return $tx2;
}
$i = 0;
mysql_connect($sql_ch,$sql_no,$sql_pa) or die ("ugyyu");
mysql_select_db($sql_db) or die ("ikgogyu");
$q = mysql_query("select * from articles LIMIT 0,1") or die ("ihlhbfrliuh");
while($row = mysql_fetch_array($q)){
$st2 = strlen($row['tx']);
$s = crunch($row['tx'],$row['lg1']);
echo $s;
}
?>
include("conf.php");
function crunch($tx,$lg) {
$tmp = 0;
if(strlen($tx)>$lg) $tmp = strpos($tx," ",$lg);
if($tmp) $tx2 = substr($tx,0,$tmp);
else $tx2 = substr($tx,0,$lg);
if($tx2!=$tx) $tx2.=" ...";
return $tx2;
}
$i = 0;
mysql_connect($sql_ch,$sql_no,$sql_pa) or die ("ugyyu");
mysql_select_db($sql_db) or die ("ikgogyu");
$q = mysql_query("select * from articles LIMIT 0,1") or die ("ihlhbfrliuh");
while($row = mysql_fetch_array($q)){
$st2 = strlen($row['tx']);
$s = crunch($row['tx'],$row['lg1']);
echo $s;
}
?>
il sert à ne prendre que les premiers caractères d'une chaine ...
mais le probleme, c'est que le script ne retourne rien ...
mais, en le modifiant un peu :
CODE
<?php
include("conf.php");
function crunch($tx,$lg) {
$tmp = 0;
if(strlen($tx)>$lg) $tmp = strpos($tx," ",$lg);
if($tmp) $tx2 = substr($tx,0,$tmp);
else $tx2 = substr($tx,0,$lg);
if($tx2!=$tx) $tx2.=" ...";
return $tx2;
}
$i = 0;
mysql_connect($sql_ch,$sql_no,$sql_pa) or die ("ugyyu");
mysql_select_db($sql_db) or die ("ikgogyu");
$q = mysql_query("select * from articles LIMIT 0,1") or die ("ihlhbfrliuh");
while($row = mysql_fetch_array($q)){
$st2 = strlen($row['tx']);
crunch($row['tx'],$row['lg1']);
echo "crunch($row['tx'],$row['lg1'])";
}
?>
include("conf.php");
function crunch($tx,$lg) {
$tmp = 0;
if(strlen($tx)>$lg) $tmp = strpos($tx," ",$lg);
if($tmp) $tx2 = substr($tx,0,$tmp);
else $tx2 = substr($tx,0,$lg);
if($tx2!=$tx) $tx2.=" ...";
return $tx2;
}
$i = 0;
mysql_connect($sql_ch,$sql_no,$sql_pa) or die ("ugyyu");
mysql_select_db($sql_db) or die ("ikgogyu");
$q = mysql_query("select * from articles LIMIT 0,1") or die ("ihlhbfrliuh");
while($row = mysql_fetch_array($q)){
$st2 = strlen($row['tx']);
crunch($row['tx'],$row['lg1']);
echo "crunch($row['tx'],$row['lg1'])";
}
?>
j'obtiens ça :
CITATION
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/free.fr/0/0/bdbourgeron/repertoire/scripratik.php on line 18
que se passe t il ?
pourquoi ce message ?
merci !