Abarrow Posted September 10, 2008 Share Posted September 10, 2008 Hi, I have an account off a server (I don't own the server) and it's mysql enabled. Here's my code for connecting to the server: <?php$con = mysql_connect("server:port","username","password");if (!$con) { die('Could not connect: ' . mysql_error()); }?> (When I refer to a generic title such as port or user name I'm right the proper one in my code but not here)Unfortunately I get a warning and die excecutes:Warning: mysql_connect(): Lost connection to MySQL server during query in (page location on server) on line2 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 10, 2008 Share Posted September 10, 2008 That's a new error message. Do you get the same error every time you run the page, or rarely? It seems like MySQL is being restarted while you're trying to run your page. If the error keeps happening contact your host about it and see what they say. You also might want to remove the port from the address, if the port is 3306 then that is the default port and you can leave it out (although I don't see how that would cause an error like that). Link to comment Share on other sites More sharing options...
Abarrow Posted September 13, 2008 Author Share Posted September 13, 2008 Yes, every time I run the code I get that error. Link to comment Share on other sites More sharing options...
count_10ants Posted September 14, 2008 Share Posted September 14, 2008 Hi, I have an account off a server (I don't own the server) and it's mysql enabled. Here's my code for connecting to the server:<?php$con = mysql_connect("server:port","username","password");if (!$con) { die('Could not connect: ' . mysql_error()); }?> (When I refer to a generic title such as port or user name I'm right the proper one in my code but not here)Unfortunately I get a warning and die excecutes:Warning: mysql_connect(): Lost connection to MySQL server during query in (page location on server) on line2 Should you be using single (') quotes for all parameters? Worth a try. Suggest also try 'localhost' instead of "server:port". Link to comment Share on other sites More sharing options...
Abarrow Posted September 17, 2008 Author Share Posted September 17, 2008 No when I run the code I put in port 22 and actual my username and actual my password and actual my server. When I tried using single quotes, I still get all ther errors. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2008 Share Posted September 17, 2008 Is MySQL really running on port 22? Port 22 is reserved for SSH. Link to comment Share on other sites More sharing options...
smartalco Posted September 17, 2008 Share Posted September 17, 2008 err ya, port 22 is SSH, just try leaving the port off of the connection statement completely, unless your server is set up weird it'll just use the default port and go through (no, I don't have any idea what the default port is) Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2008 Share Posted September 17, 2008 For MySQL the default port is 3306. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.