Hi, $string doesn't have any spaces in it, so after you do explode: $string_arr=explode(" ",$string); $string_arr only has one element in it ($string_arr[0]).
You are trying to access elements 0,1,2,3,4,5,6,7,8,9, but 1-9 don't exist when there is no space character in $string. You could change this: for($i=0;$i<$wordnum;$i++) { $re_string=" ".$string_arr[$i]; $str=$re_string; print $str; } into this: for($i=0;$i<$wordnum;$i++) { // nothing to do if this element of $string_arr // does not exist! if(!isset($string_arr[$i])) break; // break out of loop $re_string=" ".$string_arr[$i]; $str=$re_string; print $str; } Or if you are unfamiliar with 'break', you could use this: for($i=0;$i<$wordnum;$i++) { if(isset($string_arr[$i])) { $re_string=" ".$string_arr[$i]; $str=$re_string; print $str; } } regards, Peter --- Jeremy Oliver <[EMAIL PROTECTED]> wrote: > Hi > > This script was working fine, now all of a sudden I am getting an error: > > Date: 06/05/06 Comment By: test > Comment: test > *Notice: Undefined offset: 1 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 2 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 3 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 4 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 5 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 6 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 7 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 8 in C:\pub\com_summ.php on line 17 > > Notice: Undefined offset: 9 in C:\pub\com_summ.php on line 17* > > - You can see the results here under "View Feedback".. > http://www.bluejayspc.co.uk ...The strange thing is this is only > happening on the last 2 records, there are quite a few previous comments > that have displayed perfectly...... any ideas? > > Regards > Jeremy > > ================script====================== > <HTML> > <HEAD><TITLE>Comments</TITLE></HEAD> > > <body> > <p><font size="6"><strong><a name="intro"></a></strong></font></p> > <p align="center"><img src="logo.gif" > </p> > <center><h2>What our Customers have to say</h2> > <font face="arial" size=1> > <TABLE width="75%" border="0" cellspacing="0" cellpadding="0"> > <?php > > function cut_string($string,$wordnum) > { > $string_arr=explode(" ",$string); > for($i=0;$i<$wordnum;$i++) > > { > $re_string=" ".$string_arr[$i]; > > $str=$re_string; > > print $str; > } > > > } > > //connect, select db, create query, run query, close connection > $conn=mysql_connect("localhost", "userid", "password") or > die(mysql_error()); > $database=mysql_select_db("fback", $conn)or die(mysql_error()); > $sql="SELECT * FROM customer_feedback ORDER by id DESC LIMIT 25"; > > $result=mysql_query($sql); > > //PHP goes into while loop to return summaries of comments > while($row=mysql_fetch_array($result)){ > echo"<TR><td><B>Date: " > .strftime('%d/%m/%y',strtotime($row["date"]))."</B></td> > > <td><B>Comment By:</B> ".Stripslashes($row["name"])."<td></tr>"; > > echo"<TR><TD COLSPAN=\"2\" valign\"top\"><B>Comment: </B>"; > > stripslashes(nl2br(cut_string($row["comment"],"10"))); > echo"<a href=\"full_summ.php?id=$row[id]\">...Read More>>> </a>"; > > echo"<hr></td></tr>"; > } > > //close database > mysql_close($conn); > ?> > </table> > </font> > </center> > </BODY> > > </HTML> > > > ____________________________________________________ The LOST Ninja blog: Exclusive clues, clips and gossip. http://au.blogs.yahoo.com/lostninja