Click to See Complete Forum and Search --> : Mysql_connect() error???
easy going
03-27-2006, 10:33 PM
[Not a good idea to post database IP addresses and logins here. I've obfuscated them. -MOD]
Warning: mysql_connect(): Lost connection to MySQL server during query in /home/www/figaro.awardspace.com/linkcounter.php on line 2
Lost connection to MySQL server during query
I keep getting that error. I don't know what It means but hopfully someone knows on this forum.
<?
$connection = mysql_connect("xx.xx.xxx.xxx", "db_user", "db_pwd") or die(mysql_error());
$sql = "INSERT INTO linkcount (from, date) VALUES ('$_GET[from]', ' ')";
$result = mysql_query($sql, $connection) or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="refresh" content="1; url=http://www.arcadeground.com/?page=liquid" />
</head>
</html>
Thanks and all help is appreciated.
NogDog
03-27-2006, 10:42 PM
You may need to specify a port number along with the IP address. Check with the web host's sysadmin.
easy going
03-27-2006, 10:52 PM
What's a port number? And how do I check the hosters sysadmin? :blink:
chazzy
03-27-2006, 10:56 PM
I'm inclined to say that it's because you don't select a DB but you try to insert into a table.
$connection = mysql_connect("70.86.229.146", "figaro_figaro", "") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());
$sql = "INSERT INTO linkcount (from, date) VALUES ('$_GET[from]', ' ')";
$result = mysql_query($sql, $connection) or die(mysql_error());
NogDog
03-27-2006, 10:59 PM
The port number would be appended to the host name/address:
mysql_connect("70.86.229.146:1234", blah, blah);
You'll have to contact whoever runs that host (sysadmin = system administrator) and ask them what port number to use. (Note that I'm just guessing this might be the problem, I'm by no means sure.)
easy going
03-27-2006, 11:13 PM
I tried the port thing. Still that error.
I looked in my web hostings FAQ and found:
Question: How I can connect to my MySQL database? What settings should I use for my script/software?
Answer: The correct MySQL database settings are:
• DB Host: see your MySQL Database Manager section under DB Host column
• DB Port: 3306
• DB Name: the database name you have assigned, listed inside Database Manager section of your Control Panel
• DB Username: the database username you have assigned, listed inside Database Manager section of your Control Panel
• DB Password: the database password you have assigned
I think this will explain more of the problem but the fact that I don't quite understand it I place it here for even more. :)
NogDog
03-28-2006, 05:52 AM
(Replace the host address, username, password, and database name with actual values, below):
$connx = mysql_connect("xx.xx.xxx.xxx:3306", "username", "password") or
die("Unable to connect to database.");
mysql_select_db("database_name") or die("Unable to select DB: ".mysql_error());
// now do your query code....