cannot connect to mysql server

Reply

Join Date: Jul 2007
Posts: 3
Reputation: muruganasm is an unknown quantity at this point 
Solved Threads: 0
muruganasm muruganasm is offline Offline
Newbie Poster

cannot connect to mysql server

 
0
  #1
Jul 25th, 2007
hi.
i am senthilmurugan. i am learning to php language.
one error occur. i try to connect to database.
Can't connect to MySQL server on 'localhost' (10061). how to correct the error .
please reply the answer...
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 136
Reputation: dr4g is an unknown quantity at this point 
Solved Threads: 5
dr4g's Avatar
dr4g dr4g is offline Offline
Junior Poster

Re: cannot connect to mysql server

 
0
  #2
Jul 25th, 2007
Your Database information is incorrect
In order to connect you will need to have the valid information for;

DB Name
DB Username
DB Userpass
DB Host

One of these is incorrect.
GardCMS :: Open Source CMS :: Gardcms.org
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: mayacn is an unknown quantity at this point 
Solved Threads: 0
mayacn mayacn is offline Offline
Newbie Poster

Re: cannot connect to mysql server

 
0
  #3
Dec 30th, 2008
hallo ppl,

i also have the same problem,

my php connection with MySQL is not working, and couldnt connect to server is displayed y my PHP

should i alter PHP's php.ini to access mysql?

is there any restriction that i have to store the Mysql directly in my C drive... if so i have currently installed in C:\Program Files\MySQL\MySQL Server 4.1

how can i change?

thanks in advance




this is what i did

  1. <?php
  2. // Connect to the database
  3. $dbhost = 'localhost';
  4. $dbusername = 'testuser';
  5. $dbpasswd = 'testpassword';
  6. $database_name = 'simple';
  7. $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
  8. or die ('Couldn\'t connect to server.');
  9. $db = mysql_select_db("$database_name", $connection)
  10. or die('Couldn\'t select database.');
  11.  
  12. // Generate SQL code to store data on database.
  13. $insert_sql = 'INSERT INTO simple_table (text) VALUES (\'test text, 1,2,3\')';
  14.  
  15. // Execute SQL code.
  16. mysql_query( $insert_sql )
  17. or die ( 'It Didn€™t Work: ' . mysql_error() );
  18.  
  19. // Tell User we are done.
  20. echo 'Code Inserted';
  21. ?>
  22.  
  23. Create a new file called "test_select_mysql.php" and enter the following code into it:
  24.  
  25. <?php
  26. // Connect to the database
  27. $dbhost = 'localhost';
  28. $dbusername = 'testuser';
  29. $dbpasswd = 'testpassword';
  30. $database_name = 'simple';
  31. $connection = mysql_connect("$dbhost","$dbusername","$dbpasswd")
  32. or die ('Couldn\'t connect to server.');
  33. $db = mysql_select_db("$database_name", $connection)
  34. or die('Couldn\'t select database.');
  35.  
  36. // Generate code to retrieve data from database.
  37. $select_sql = 'SELECT text FROM simple_table';
  38.  
  39. // Retrieve code from database.
  40. $result = mysql_query( $select_sql )
  41. or die ( 'It Didn€™t Work: ' . mysql_error() );
  42.  
  43. // Display results to user.
  44. while ( $row = mysql_fetch_object ( $result ) )
  45. {
  46. echo $row->text . ‘<br>’;
  47. }
  48. ?>

Browse to http://localhost/test_insert_sql.php, then http://localhost/test_select_sql.php. Every time you view test_insert_sql.php, it adds a line to the database; viewable from test_select_sql.php. Now, even if you reset you computer the data is still stored in the database.
Last edited by peter_budo; Jan 6th, 2009 at 1:59 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 4
Reputation: sumchtarek is an unknown quantity at this point 
Solved Threads: 1
sumchtarek sumchtarek is offline Offline
Newbie Poster

Re: cannot connect to mysql server

 
0
  #4
Jan 2nd, 2009
hi!
Just write according to my code.I think that will work.
  1. <?php
  2. $host="localhost";
  3. $user="root" //It may different
  4. $pass="" //If u use password that write between " "
  5. $database="test" //you can also use any any created database name.
  6. @mysql_connect($host,$user,$pass) or die("Sorry ,User name Or Password problem);
  7. @mysql_select_db($database);
  8.  
  9. //What's you want to do write in here.
  10.  
  11. //More comple Email me: <EMAIL SNIPPED>
  12.  
  13. ?>
  14.  
Last edited by peter_budo; Jan 6th, 2009 at 2:00 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 87
Reputation: TopDogger is an unknown quantity at this point 
Solved Threads: 5
TopDogger's Avatar
TopDogger TopDogger is offline Offline
Junior Poster in Training

Re: cannot connect to mysql server

 
0
  #5
Jan 3rd, 2009
You might want to check with your hosting company about the MySQL connection. Not all hosting companies allow you to connect via localhost.

With GoDaddy and some others the MySQL database resides on a different server so they use a different sever name.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC