Hi,
I'm trying to make an article script for my site where the content is stored in MySQL and now I want to break it in several pages but I'm failing miserably.
I have this code:
<?
function get_article($article_id,$page){
$info = get_article_info($article_id);
ob_start();
highlight_string(stripslashes($info['articles_text']));
$buffer = ob_get_contents();
ob_end_clean();
$story = $buffer;
function get_article_info($article_id){
global $page, $id;
$sql = "SELECT ssarticles.*, ncat_name, user_id, user_nick FROM
FROM ssarticles, ssusers, ssnewscats
WHERE news_cat = ncat_id
AND news_user = user_id
AND articles_id = $id";
$r = mysql_query($sql);
if(@mysql_num_rows($r)){
return mysql_fetch_array($r);
}else{
return 0;
}
}
// STUFF FOR ARTICLE MANAGEMENT
// If no page specified, default to the first page ($page = 0)
if (!strlen($page)){
$page = 0;
}
// Split the text into an array of pages
$textarray = split("\[pagebreak]",$story);
// Select the page we want
$story = $textarray[$page];
if ($page != 0) {
$prevpage = $page - 1;
$pages[] = '<A HREF="http://www.objeqt.com/maniacs/articles.php?id=.$id.'&'.$prevpage.'">'.
'Previous Page</A>';
}
if(sizeof($textarray)){
for($i = 0 ; $i < sizeof($textarray) ; ++$i){
if($page == $i){
$pages[] = ($i + 1);
}else{
$pages[] = '<A HREF="http://www.objeqt.com/maniacs/articles.php?id=.$id.'&'.$i.'">'.($i + 1).'</A>';
}
}
}
if ($page < count($textarray) - 1) {
$nextpage = $page + 1;
$pages[] = '<A HREF="http://www.objeqt.com/maniacs/articles.php?id=.$id.'&'.$nextpage.'">'.
'Next Page</A>';
}
$story .= '<center>[ '.implode(' ][ ',$pages).' ]</center>';
$content = nl2br(['articles_text']);
dump_box($content);
return nl2br($story);
}
function print_story($story)
{
echo format_story($story);
}
if(!strlen($id)){
echo 'NO ID!!!';
}else{
$sql = "SELECT * FROM ssarticles WHERE articles_id='$id'";
$r = mysql_query($sql);
if(@mysql_num_rows($r)){
$row = mysql_fetch_array($r);
while(list($key,$val) = each($row)){
$$key = $val;
}
print_story($story);
}else{
echo 'No Record with ID of '.$id.'!!!<br>';
echo 'SQL: '.$sql;
}
}
?>
I get a Parse error on line:
$pages[] = '<A HREF="http://www.objeqt.com/maniacs/articles.
Could anybody tell me what the problem is?