/    Sign up×
Community /Pin to ProfileBookmark

same php classes requires not working on one of two pages

Okay I have a class (blog) that requires another php class to run (bridge).

So my blog class is called in two different pages, one page runs like it should, the other says that the require failed because the bridge class couldn’t be found. Error:

[QUOTE]

Warning: require(../libraries/bridge.class.php) [function.require]: failed to open stream: No such file or directory in D:Hosting4808805htmlantiwarteezbloglibrariesblog.class.php on line 2

Fatal error: require() [function.require]: Failed opening required ‘../libraries/bridge.class.php’ (include_path=’.;C:php5pear’) in D:Hosting4808805htmlantiwarteezbloglibrariesblog.class.php on line 2

[/QUOTE]

why would it work on one page and not the other?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@xeteaOct 24.2010 — Could it be that the different pages are in different folders?

You're using relative paths to include the files, so if the different pages are in different folders the real path will be different.
Copy linkTweet thisAlerts:
@antaresauthorOct 24.2010 — If necessary, my folder structure, where the two offending files can be found is as:

[]

..[libraries] "bridge.class.php, guardian.class.php found here"

..[blog]

....index.php "blog.class.php runs properly"

....[libraries] "blog.class.php found here"

....[admin] "file in here does not run blog.class.php here"

I'm now having another problem securing that blog admin file: I have a class set for that (guardian) with a static function isAdmin that takes a user id. When I try to make sure that the person accessing that those admin files in Blog->Admin I get tons of errors dealing with, again, bridge, but more specifically:


Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'DB_HOST' (11004) in D:Hosting4808805htmlantiwarteezlibrariesbridge.class.php on line 19

Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to MySQL server on 'localhost' (10061) in D:Hosting4808805htmlantiwarteezlibrariesbridge.class.php on line 20

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in D:Hosting4808805htmlantiwarteezlibrariesbridge.class.php on line 20

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:Hosting4808805htmlantiwarteezlibrariesbridge.class.php on line 26

Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in D:Hosting4808805htmlantiwarteezlibrariesbridge.class.php on line 38
[/QUOTE]


Soo now I have two problems ? Hopefully someone can explain why its happening so I can think up the solution on my own ? I like learning that way

I'm thinking its my folder structure.
Copy linkTweet thisAlerts:
@antaresauthorOct 24.2010 — @xetea: I am using relative and they are in different folders. However, its just blog that getting the problem.

Wait, when I use require, or include, does that load that file into my page... that would explain this problem. ><
Copy linkTweet thisAlerts:
@xeteaOct 24.2010 — About the first problem:

Use this code to include your blog class:
[code=php]
require($_SERVER['DOCUMENT_ROOT']."/libraries/blog.class.php");
[/code]


$_SERVER['DOCUMENT_ROOT'] contains the absolute path to your public_html directory (in your case that should be D:Hosting4808805htmlantiwarteez but I'm not sure, so you might have to modify it a bit).

About the second problem:

All the warnings are a result of the first warning. It seems like you're trying to connect to a host that doesn't exist. A guess is that you've defined DB_HOST somewhere but forgot to include that file.
Copy linkTweet thisAlerts:
@xeteaOct 24.2010 — @xetea: I am using relative and they are in different folders. However, its just blog that getting the problem.

Wait, when I use require, or include, does that load that file into my page... that would explain this problem. ><[/QUOTE]


Yeah, that's the problem. Including something is pretty much like copy-pasting the code of the included file to the including file.
Copy linkTweet thisAlerts:
@antaresauthorOct 24.2010 — Ah I see, I should be able to solve the problem with this help ? Thanks
×

Success!

Help @antares spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...