<?php
$con = mysql_connect("localhost","user","pass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>
<?php
function ShortenText($text, $chars=80)
{
$text = substr($text,0,$chars);
$text = substr($text,0,strrpos($text,' '));
$text .= '...';
return $text;
}
// get the latest 3 news feeds
$sql = 'SELECT title from table ORDER by id LIMIT 3';
$result = mysql_query($sql);
// display news
while($row = mysql_num_rows($result))
{
// display shortened title, returns the first 30 chars.
echo shortText($row['title'], 80);
}
?>
however the following is displayed now
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/deswo/public_html/clients/baseyouthproject/shorten_a_text_string1.php on line 27
line 27 is
while($row = mysql_num_rows($result))
please help
Thank You