/    Sign up×
Community /Pin to ProfileBookmark

Mysql_connect() error???

[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.

[code=php]<?
$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>[/code]

Thanks and all help is appreciated.

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 28.2006 — You may need to specify a port number along with the IP address. Check with the web host's sysadmin.
Copy linkTweet thisAlerts:
@easy_goingauthorMar 28.2006 — What's a port number? And how do I check the hosters sysadmin? :blink:
Copy linkTweet thisAlerts:
@chazzyMar 28.2006 — I'm inclined to say that it's because you don't select a DB but you try to insert into a table.

[code=php]
$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());[/code]
Copy linkTweet thisAlerts:
@NogDogMar 28.2006 — The port number would be appended to the host name/address:
<i>
</i>mysql_connect("70.86.229.146[color=red]:1234[/color]", 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.)
Copy linkTweet thisAlerts:
@easy_goingauthorMar 28.2006 — 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. ?
Copy linkTweet thisAlerts:
@NogDogMar 28.2006 — (Replace the host address, username, password, and database name with actual values, below):
[code=php]
$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....
[/code]
×

Success!

Help @easy_going spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...