Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,672 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,165 people online right now. Registration is fast and FREE... Join Now!




connecting mysql to php coding

 
Reply to this topicStart new topic

connecting mysql to php coding

brainy_creature
post 3 Aug, 2007 - 11:24 AM
Post #1


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


am working on mysql on awardspace.com
and i have done the coding for connecting the DB
<?php
$db_hostname='fdb.awardspace.com:3036';
$db_username='_____';
$db_password='______';
$db_databasename='____';
$connection=mysql_connect($db_hostname,$db_username,$db_password);
if(!$connection){
die("couldnotconnect to the data base".mysql_error());
}
?>
AND I GET SUCH ERRORS---->Warning: mysql_connect(): Lost connection to MySQL server during query in /home/www/bakwas.awardspace.com/index.html on line 23
couldnotconnect to the data baseLost connection to MySQL server during query

can anybody help me ...wats happening??
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 3 Aug, 2007 - 01:27 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


According to MySQL server documentation there are a few reasons for this error. Either the connection has shutdown to time being idle for 8 hours or the connection has been closed prior to you issuing the query. Now the reasons for it being closed can be numerous. Some include things like...

1) You (or the db administrator) has killed the running thread with a KILL statement or a mysqladmin kill command.

2) You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected.

3) A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host.

4) You got a timeout from the TCP/IP connection on the client side. This may happen if you have been using the commands: mysql_options(..., MYSQL_OPT_READ_TIMEOUT,...) or mysql_options(..., MYSQL_OPT_WRITE_TIMEOUT,...). In this case increasing the timeout may help solve the problem.

5) You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0).

6) You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.

Now they recommend that you check the MySQL uptime by logging in as root (if you have access to that) and issuing a command like

mysqladmin -u root -p version

That will tell you if the server has actually died or not.

If someone else is hosting the site for you and you do not have access, perhaps you can ask the admin of the site to check to make sure that there isn't a timeout problem or that you are logging in correctly. They might be able to help. However, first thing I would check is to make sure you aren't accidentally closing the connection before issuing a command.
User is offlineProfile CardPM

Go to the top of the page

brainy_creature
post 4 Aug, 2007 - 05:10 AM
Post #3


D.I.C Head

**
Joined: 7 Aug, 2006
Posts: 174



Thanked 1 times
My Contributions


alrite thanks ill try working on it.. i also wanted to know one thing
am working on th db of the hosting web.. its abt 10mb... am just parcting now so the size doesnot matters.. is it otherwise also neccessary that i should install mysql on my comp for easier working??
i dont understand wat went wrong with that

->i am not using any mysql_option() function

->wat is a reconnect flag?? do we need to add it everytime

->where is wait_timeout function present.. with the server??
how do i overcome that??


They might be able to help. However, first thing I would check is to make sure you aren't accidentally closing the connection before issuing a command.

accidentally closing connection?? blink.gif like where??



User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 4 Aug, 2007 - 11:29 PM
Post #4


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 5,062



Thanked 175 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


You can install a copy of mysql on your own pc for development purposes, that is what I do. However, you just got to make sure it is the same version as you are using on the web host or you might run into incompatibilities with your coding when you move it over.

Those options it mentions are on the server side, which if you are hosting with someone else they will know the answers to those questions. Check with them to see what might be the problem.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:07AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month