On 8 Mar 2005, at 11:40, Richard Lynch wrote:

1. $content = substr($article['content'], 0 200); // get first 200
chars is choking, and I've looked in docs and can't understand why.
I get


Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57

In this line, PHP is somehow encountering a T_NUMBER (a number) where it
*expects* to see something else.


Like a comma.

Look between your 0 and 200 very carefully.



Thanks for taking the time. I had suspected that earlier, but when I put it in all sorts of OTHER stuff happened.

Then I saw your post and tried again. I saw that I had made another mistake later on. So you've solved that part - thanks!.

Except....Except it doesn't pull the content from the db and substr it to 200 characters. It pulls the id number and the title no problem, and I am sure that $article['content'] points to the right place (or at least it's named right) but it's just not getting the content:

if (!empty($where)) {

echo "
 <ul>";
$article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0, 400); // get first 200 chars
// print and see if we get, what we expect
// print "id=$article_id<br>title=$title<br>content=$content<p>";
// now make the real stuff
$table_of_contents[] = "<li><a href='{$_SERVER['PHP_SELF']}? a={$article_id}'}&title='{$title}'>{$article['title']}</a><br/ >$content<br /><a href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}' title='{$article['title']}'> ... [Read article]</a></li></li>";
}
}


echo "
 </ul>";

Thanks in advance. . .

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to