/    Sign up×
Community /Pin to ProfileBookmark

Server keeps dropping connection.

Hi,

For some odd reason every time I try and execute one of my codes (an a XAMPP server on my laptop) I get a “server dropped the connection” message…
I was wondering what the cause could be, preferably without having to post my code as it is part of a project I’m doing and is a commercial web program…
If you could offer any suggestions I’d be very grateful.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@TJ111Feb 07.2008 — Check settings in your php.ini file. Especially this section:
<i>
</i>;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 32M ; Maximum amount of memory a script may consume (8MB)


Also, check your PHP and Apacha error logs.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorFeb 07.2008 — Thanks. I discovered the root of the problem, and it lay in a mysql error, however, although it looked trivial at first, it wasn't, and there's a problem that I can't really fathom.

For some reason parts of my configuration file won't work, and hence it was unable to connect to the database using the values specified.

Here's the relevant bit of the config file, basically, $CONFIG_database is an array which contains information about the databases. I've tried setting it up in two ways, neither of which has yeilded any results:

[code=php]
#MySQL configuration

$CONFIG_database = array(
"server"=>"localhost",
"user_name"=>"root",
"password"=>"pwd",

"databases"=>array(
"users"=>"lms",
"fixtures"=>"lms"
)
);


/*$CONFIG_database['server'] = "localhost";
$CONFIG_database['user_name'] = "root";
$CONFIG_database['password'] = "pwd";

$CONFIG_database['databases']['users'] = "lms";
$CONFIG_database['databases']['fixtures'] = "lms";*/
[/code]


The config vars are then accessed as follows for example:
[code=php]
mysql_select_db($CONFIG_database['databases']['fixtures']);
[/code]


I really don't understand why this won't work.
Copy linkTweet thisAlerts:
@TJ111Feb 07.2008 — I'm assuming this is after calling mysql_connect? Here's a sample of a connect function from a database interface class I wrote. I used the optional second argument in the mysql_select_db, which just references which connection I'm using. What error are you getting when running that script?

[code=php]
//connect to the database (returns boolean)
//will be called automatically using the default db if a table is passed on creation
public function connect() {
$this->db = @mysql_connect($this->db_host, $this->db_user, $this->db_pass);
if ($this->db && (@mysql_select_db($this->db_database, $this->db))) {
return true;
} else {
$this->error = "Error connecting to database -- ". mysql_error();
return false;
}
}
[/code]


Also, as a note, you should never allow PHP to connect to mysql as root. Always use a user with restricted database privileges (usually SELECT, INSERT, UPDATE, DELETE, FILE is all you should need). Connecting as root makes a hackers life alot easier.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorFeb 08.2008 — That wasn't my real user name and password by the way...

My issue is that the variables aren't working properly, that's all... I'll play around though and try to get them to work.

I think I might have worked it out.

Thanks anyway.

By the way, I don't really understand your function, what do the "->"s do? Oh... do they call array keys?
Copy linkTweet thisAlerts:
@TJ111Feb 11.2008 — Oh no it's part of a database class. The -&gt; refer's to properties of the class, for example:
[code=php]
$db = new DB();
$db->connect(); //assuming an error occurres here.
print $db->error;
//prints something like "Error connecting to database --- Access denied for user@localhost. Using Password: NO".[/code]
Copy linkTweet thisAlerts:
@blue-eye-labsauthorFeb 11.2008 — safe... I was thinking of using classes, but decided against it ultimately... I got my code to work in the end... it was all to do with variables and globals.
×

Success!

Help @blue-eye-labs 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 5.12,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...