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 Very odd include problem - mysql error
Morx
Posted on 28 May 2010, 03:54:23

Access: Member
Total Posts: 4
Joined: 2010-05-28

hi!

I got a site that's built with a php/html/css template. i've used html and css to format the page and php to include functions to 3 divs that i call contentMenu, contentMain and contentRight. then i have lots of other php files with these functions in them, that when they load (by clicking a link to them) the file loads and get formated by the included template file in the end. example of how they look:
Code:
<?php

$sPage = 'main';

function contentMenu() {
?>


<h3>left side text</h3>

<?}

function contentRight() {
?>

<p>rightside text</p>

<?}

function contentMain() {
?>
<?php
include ('news/index.php');
?>

<?}
include('lib/php/template.php');?>

As you can see i've included the "news/index.php" as i should in my contentMain function. but here's the problem. when i do this i get ALOT of mysql errors this is what i get:
Code:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'tidacese'@'localhost' (using password: NO) in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 23

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'tidacese'@'localhost' (using password: NO) in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 24

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 24

Warning: mysql_query() [function.mysql-query]: Access denied for user 'tidacese'@'localhost' (using password: NO) in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 81

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 81

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home2/tidacese/public_html/tidancenew/news/mysql.php on line 92
Error:
Statement: SELECT registrationverification,loginverification,deleteowncomments,publickey,privatekey,commentspop,uploadpath,commentsorder,newsorder,newstime,commentstime,nppage,cppage,template,registrationaccess,registrationallow,commentslength,furlextension,furlenabled,furlprefix,furldirname,spamtime,spammsg,commentmsg,commentapprovemsg,timezone,bannedmsg,catdelimiter,useimgverification,salt,version,scriptpath,regcomment,commentsnotify,registernotify,emailnotify,unapprovednotify,filetime,tail FROM news30_options WHERE 1
Arguments:

however, when i make a test.php file that only holds the included "news/index.php" everything works fine. This seemes really odd and strange to me do you have any ideas on how to resolve this in any way?

regards
Jimmy
#2343
Last edited by Morx at 2010-05-28 03:56:23 Reason:
Chris
Posted on 28 May 2010, 04:01:46

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

Are you using any other scripts that connect to a database?
#2344
Morx
Posted on 28 May 2010, 04:06:27

Access: Member
Total Posts: 4
Joined: 2010-05-28

Not on this site but on the same web-server, yes.
but that's another database with another database account.

However i might have a folder that i can't delete from an old news system on this site. But all the code that's related to that is on another template and another page.
#2345
Morx
Posted on 28 May 2010, 14:00:55

Access: Member
Total Posts: 4
Joined: 2010-05-28

wow here's something odd...

when i do include the news directly into the template file it loads as it should....

so what seems to go wrong is when i try to include the news in a seperate php file that loads through my template...

any ideas?

would be great to resole this cause then i can use this script on multiple pages and only show different categories to be able to dynamically update most of the site.

regards
jimmy
#2346
Chris
Posted on 28 May 2010, 14:13:54

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

The problem occurs when you try doing the include within a function, for example

Code:
<?php
function test(){
    include 
'news/index.php';
}
?>


Because it's within the function it's not able to access some variables which is a problem I've overlooked as I never though to test for includes within functions.

To make this work would be extremely tedious, you would need to manually make all the variables that the script needs to access global by specifying them before the include, for example I just tested this

Code:
<?php
function contentMain() {
    global 
$cfg, $smilies, $filters;
    include 
'news/index.php';
}
ContentMain();
?>


Which displayed the news without any errors, but when you click to view the full news article it throws more errors because there's a lot more variables that would need to be specified.

My best advice would be for the time being not specify the include within the function.

I've made this into a bug report so this limitation will definitely be fixed in the next version of the script.
#2347
Morx
Posted on 28 May 2010, 19:23:16

Access: Member
Total Posts: 4
Joined: 2010-05-28

Thanks for the quick responses.

It's a really good and nice system you got and excellent support. thanks a lot chris.

for now i've included the news directly in the main template with an if function that checks the page's name that i define at the top of every page. so if my page is 'currentnews' then it will show the news from the template. this is a good workaround for now :) but thanks for looking into the matter for future releases. :)

I got another question, is it possible to relocate your "powered by N-13 News" to my footer so it's on all pages? the reason for this is that i cot a scrolling "newsticker" at the top but the "powered by N-13 news" gets under the news in a separate div and make the newsticker really weird.

would be great if i could put the text in the center or on the left hand side in my footer...

regards
Jimmy

and thanks again for all the help.
#2348
Network-13.com © 2013