/    Sign up×
Community /Pin to ProfileBookmark

Can connect to MySQL only in 1 single folder

When I tried to connect to MySQL using PHP, it always fails except in an one single folder.

That is there is folder 1 (1 is its name) in the document root.I uploaded some PHP files into that and tried to connect MySQL. N P. I connected successfully.

However when I uploaded some files to document root & its subfolders, I was unable to connect MySQL all the times. But when I uploaded the same files to aforesaid directory [/1] they works fine and connect to MySQL suucessfully. But not outside folder /1/ .

And also even in /1/ folder its only possible to connect the initial DB. But not others. So now I am using 1 DB with many tables.

I think this might be strange. However I’d like to know what causes these type of problems. MySQL ? PHP? or else?

And also I’d like to know, are such files work fine onlly in said 1/ dir, can function properly outside of my server. == Another server ?

Regards.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@scragarNov 29.2004 — try copying and pasting the content of a conection file to a different location as see if it works then.


If you can't get it working then try making an conn file in you folder and include it where nessesary:

conn.php[code=php]<?
$username="MyUserName";
$password="MyPassWord";
$database="MyDataHBase";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
?>[/code]

any other file:
[code=php]<?
include "/home/1/conn.php";
// do you normal code like you normaly would.
?>
[/code]



just a final idea, but ensure you don't open the database too many times without closing it.
Copy linkTweet thisAlerts:
@GUIRauthorNov 29.2004 — ThanX very much for your setup...

Your code must work fine,, I'll try it out.

Regards.
×

Success!

Help @GUIR 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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