Current location: Hot Scripts Forums » Programming Languages » PHP » can't connect to MySQL all of a sudden, PHP My Admin still works


can't connect to MySQL all of a sudden, PHP My Admin still works

Reply
  #1 (permalink)  
Old 03-09-06, 06:19 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
can't connect to MySQL all of a sudden, PHP My Admin still works

i'm making a database driven website and everything works perfect. but, every once in a while, i'm unable to connect to MySQL from my own script. out of the blue it just will not connect. however, PHP My Admin will always connect without problems.

does anyone have a clue why i'm having this problem, and how to fix it? my solution has always been to haggle for a few hours and reinstall MySQL etc which is a pain.
Reply With Quote
  #2 (permalink)  
Old 03-09-06, 06:36 AM
ben.periton ben.periton is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
What is the code you are using to connect?
__________________
Ben Periton
http://ben.periton.co.uk
Reply With Quote
  #3 (permalink)  
Old 03-09-06, 06:43 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

// database query START

// ··························

function global_DbQuery($selection$input$extra1$extra2$extra3){

// Calling values from outside the function
global $text_Db_ErrorConnection$text_Db_ErrorDatabaseSelection$text_Db_ErrorDbQueryNotSelected$text_Db_ErrorDbQueryNotAvailable$global_PathIncludesSite;


// filter submitted "extra" values
$extra1 global_QuoteValue($extra1);
$extra2 global_QuoteValue($extra2);
$extra3 global_QuoteValue($extra3);

// INSERT, SELECT, DELETE queries only
if ($selection <= 999){
// put each value from array on a single line, add commas
foreach ($input as $key => $input2){$value .= global_QuoteValue($input2); if ($key < (count($input) -1)){$value .= ', ';}}
}

// UPDATE queries only
elseif (($selection >1000) and ($selection <=1999)){
// keep array as is, set $value = $input
$value $input;
}

// include database info and custom database queries for website
include $global_PathIncludesSite.'dbInterface.php';

// Connecting to, and selecting database
$db_connection mysql_connect($db_Server$db_Username$db_Password)
or die(
$text_Db_ErrorConnection mysql_error());
mysql_select_db($db_Database) or die($text_Db_ErrorDatabaseSelection);

// Querying database
$result mysql_query($query);

// Return result of query
return $result;
}

// ··························
// database query END 



this is what is actually failing
Quote:
mysql_select_db($db_Database) or die($text_Db_ErrorDatabaseSelection);
so, it's not able to select the database for some reason.
Reply With Quote
  #4 (permalink)  
Old 03-09-06, 06:44 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
and it's not just my script that isn't working. other scripts i got from online don't work. but PHP My Admin always works.





also, i found this is PHP My Admin:
Quote:
Error
The additional features for working with linked tables have been deactivated.

PMA Database ... not OK[ Documentation ]
General relation features Disabled
and i can't really figure out what it is..
Reply With Quote
  #5 (permalink)  
Old 03-09-06, 02:14 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
try this:

PHP Code:

$db_connection mysql_connect($db_Server$db_Username$db_Password)

or die(
$text_Db_ErrorConnection mysql_error());
mysql_select_db($db_Database$db_connection) or die($text_Db_ErrorDatabaseSelection); 
don't know if it's gonna help, but you might give it a try

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #6 (permalink)  
Old 03-09-06, 02:18 PM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
interesting idea, i'll try that and see if it saves me the next time, hoping there won't be a next time.

thanks!
Reply With Quote
  #7 (permalink)  
Old 03-10-06, 01:24 PM
Jon_Ptavis Jon_Ptavis is offline
New Member
 
Join Date: Mar 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
possible admin solution

I'm new to mysql but I noticed the same thing. I went into the 'mysql Admin\useradministration\"user" \ resource' here you will find three setting max_questions: max_updates: max_connection: increase these to a number that will allow you to test you code. Once your done and ready to co to production lower the numbers.
I hope this helps
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP scripts unable to connect to DB after MySQL 4.1.10 upgrade Jason L PHP 3 03-08-05 12:32 AM
When I try to connect to mysql from php I get this error: "Call to unsupported or.... laxy_m PHP 2 09-29-04 07:11 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 06:02 AM


All times are GMT -5. The time now is 06:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.