Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support Error in showing news article
Gosain
Posted on 25 Oct 2009, 19:27:14

Access: Member
Total Posts: 14
Joined: 2009-10-25

Hi Chris,

After getting over with my first tour of admin section I went ahead to show an article added at the website's php file by this code:

Code:
<?php
$cat[] = 'News';
#$cat[] = 'Events';
#if specified any posts assigned to those categories will be displayed.
#if no cats are specified then all posts will be displayed.
include 'newsevents/index.php';
?>

But, I got the following fatal error:

[img]http://i35.tinypic.com/vg7pdw.gif[/img]
Thanks.

#1125
Chris
Posted on 25 Oct 2009, 19:32:22

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Try editing the newslangmsg.php file and add this to the beginning just after the <?php code

Code:
<?php
include 'config.php';


....
#1126
Gosain
Posted on 25 Oct 2009, 19:46:48

Access: Member
Total Posts: 14
Joined: 2009-10-25

Hi Chris,

We already have following at line 12 of index.php:
Code:
include_once 'config.php';

According to me, we can not include config.php twice, please correct me if I am wrong.

Then, I did as per your instructions and included the following line in newslangmsg.php:

Code:
include 'config.php';

But I got this error:
Code:
Fatal error: Cannot redeclare class Config in D:\xampp\php\PEAR\Config.php on line 44

Then I tried this:

I removed "x(" and then ")" at the end of every line in newslangmsg.php ( I dont know if I was suppose to do it or not but I wanted to give it a try) but then I got more set of errors:

[img]http://i36.tinypic.com/281yc0z.gif[/img]
Then I reverted back to my original newslangmsg.php.

So, currently I am unable to display news articles.

Thanks.
#1127
Last edited by Gosain at 2009-10-25 19:51:48 Reason:
Chris
Posted on 25 Oct 2009, 19:48:09

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

You're right, I was supposed to write include_once

Code:
<?php
include_once 'config.php';
?>


#1128
Gosain
Posted on 25 Oct 2009, 19:54:29

Access: Member
Total Posts: 14
Joined: 2009-10-25

Hi Chris,

Still getting this error:

Code:
Fatal error: Call to undefined function x() in newsevents\newslangmsg.php on line 9

I tried to echo a variable in newslangmsg.php by this way:

Code:
echo "newstable=".$newstable."<hr>";
die();

But it displayed nothing which is very surprising because all definitions from config.php must have been available in newslangmsg.php as config.php was called before newslangmsg.php


Thanks.
#1129
Last edited by Gosain at 2009-10-25 20:01:54 Reason:
Gosain
Posted on 25 Oct 2009, 20:27:07

Access: Member
Total Posts: 14
Joined: 2009-10-25

Just wondering if any one else had this same problem of not showing articles at all?

Thanks.
#1130
Gosain
Posted on 25 Oct 2009, 21:54:14

Access: Member
Total Posts: 14
Joined: 2009-10-25

Hi Chris,

My problem is solved. :original:

The cause for the errors was that the files were not being actually included reason of which is not known to me. I used file_exists function to see if php was actually able to find the file and surprisingly files were not being found then I used absolute path location in conjunction with file_exists then only files were included.

Below is the code I used in index.php to include three files: 1) db.php, 2) config.php and 3) newslangmsg.php

Code:
<?php
$curpath 
= $_SERVER{'DOCUMENT_ROOT'}."/httpdocs/newsevents/";
$filename = $curpath."db.php";
if(
file_exists($filename)){
    include 
$filename;
} else {
    die(
"Database error.");
}
$filename = $curpath."config.php";
if(
file_exists($filename)){
    include 
$filename;
} else {
    die(
"Configuration error.");
}
$filename = $curpath."newslangmsg.php";
if(
file_exists($filename)){
    include 
$filename;
} else {
    die(
"Language error.");
}
?>


Once db.php and config.php were properly included then there was no need to include them again in newslangmsg.php any more.

I hope this will be of some help to a needy person having similar problem.

Thanks.
#1131
Last edited by Gosain at 2009-10-25 21:56:57 Reason:
Network-13.com © 2013