small news section. how?
Moderator: General Moderators
small news section. how?
hello, i would like to learn how to develop a script that allows me to be able to write, update and delete news on one column of my webpage (trhus is not going to be a big section on my website, about three newstitles). i would like to it to show a small description or news title and have the 'read more...' link.
where do i start, please?
do you know a great tutorial for this?
many thanks.
where do i start, please?
do you know a great tutorial for this?
many thanks.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
save the articles in a database. Fetch the articles contents for your main page. trim the articles to the size you want to display on your main page. include a 'read more' link at the bottom of the 'snippet' that is a link to the full article (based on its row number). fetch the article in question and show the whole thing on the article page.
hi kieran, i installed the news script you kindly pointed out to me (many thanks again!) but i am experiencing some difficulties in installing it eventhough it seemed straight forward.
http://zulumonkey.org/?id=tutorials&pag ... nt&oid=171
the problem is i am getting the following errors.
the only changes i've made are here:
i don't get why am i getting those errors. could please help me on this?
many thanks.
http://zulumonkey.org/?id=tutorials&pag ... nt&oid=171
the problem is i am getting the following errors.
Code: Select all
Notice: Use of undefined constant newsuser - assumed 'newsuser' in j:\program files\easyphp1-8\www\news\config.php on line 94
Notice: Undefined index: newsuser in j:\program files\easyphp1-8\www\news\config.php on line 94
Notice: Use of undefined constant newspass - assumed 'newspass' in j:\program files\easyphp1-8\www\news\config.php on line 94
Notice: Undefined index: newspass in j:\program files\easyphp1-8\www\news\config.php on line 94Code: Select all
/* Insert Your MySql Details here then run config.php in your browser, if the page is blank it means its working but if there is writing on it it means that you put in the wrong details */
$dbh=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db_news");
/* Set Your Timezone in here, eg -2 */
$timezone_local = "0";
/* Comments To Be Displayed Per Page */
$compp = "10";
/* News Posts To Be Displayed On Front Page */
$frontpagelimit = "5";
/* Set the length of the messages you want to display on the front page */
$stripnews = "200";
/* Admin Usernames And Password */
$admins = array(
"Kiki " => "johns",
);many thanks.
thanks feyd, i quoted the named arrays and changed array to
i also used isset() and still getting errors.
but i am still getting errorsarray_key_exists
.Parse error: parse error in j:\program files\easyphp1-8\www\news\config.php on line 25
i also used isset() and still getting errors.
Code: Select all
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in j:\program files\easyphp1-8\www\news\config.php on line 25feyd | Please use
thanks feyd
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
here is the whole config.phpCode: Select all
<?
/* ==================================== START OF EDITABLE VARIABLES ================================ */
/* Insert Your MySql Details here then run config.php in your browser, if the page is blank it means its working but if there is writing on it it means that you put in the wrong details */
$dbh=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("news");
/* Set Your Timezone in here, eg -2 */
$timezone_local = "0";
/* Comments To Be Displayed Per Page */
$compp = "10";
/* News Posts To Be Displayed On Front Page */
$frontpagelimit = "5";
/* Set the length of the messages you want to display on the front page */
$stripnews = "200";
/* Admin Usernames And Password */
$admins = array_key_exists(
"username" => "password", [b]this is where the error is: Parse error: parse error in j:\program files\easyphp1-8\www\news\config.php on line 25[/b]
);
/* ============================ END OF EDITABLE VARIABLES ============================== */
/* ============================ DO NOT TOUCH THIS AREA BELOW ============================== */
/* This will return to the current filename to link between forms */
$self = $_SERVER['PHP_SELF'];
$selffull = $_SERVER['REQUEST_URI'];
/* Some settings */
$time = time();
$timezone_offset = date("Z");
$timezone_add = round($timezone_local*60*60);
$time = round($time-$timezone_offset+$timezone_add);
$date = date("d/m/y", $time);
$ip = $REMOTE_ADDR;
function is_member($username) {
global $admins;
if ($admins[$username] != "") {
return true;
}
return false;
}
function loggedin($username, $password) {
global $admins;
if (empty($username) || empty($password)) {
return false;
} if ($admins[$username] == $password) {
return true;
}
return false;
}
function bbcode($message){
$search = array(
'#\[B\](.+?)\[\/B\]#is',
'#\[i\](.+?)\[\/i\]#is',
'#\[U\](.+?)\[\/U\]#is'
);
$replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<span style="border-bottom: 1px solid;">$1</span>'
);
return preg_replace($search, $replace, $message);
}
function striplink($text) {
$word = array(
"http://" => "",
"www." => "",
);
foreach ($word as $bad => $good) {
$text = str_replace($bad, $good, $text);
}
$text1 = strip_tags(addslashes($text));
$text = "http://";
$text .= "$text1";
return $text;
}
if (loggedin($_COOKIE[newsuser], $_COOKIE[newspass])) {
$profile = array();
$profile[username] = $_COOKIE[newsuser];
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
array_key_exists() is a function. It does not work with array creation notation.