mysql querry error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

mysql querry error

Post by method_man »

for some reason when i connect i get this error

Connected successfully
Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/twarowsk.freeownhost.com/StreetLife/process.php on line 7

Warning: mysql_query(): A link to the server could not be established in /home/www/twarowsk.freeownhost.com/StreetLife/process.php on line 7

this is my code:

Code: Select all

<?PHP

require('dblink.php');

//mysql query
$query = 'INSERT INTO member (username, password, email address) VALUES ("'.$_POST[loginName].'", "'.$_POST[password].'", "'.$_POST[email].'")';
$db_query = mysql_query($query);
$to = $_POST['Email'];//the email address the user submitted
$subject = 'You Registered!';
$message = 'You have just registered to play on The Streets. To log in go to the main page and use your username and password to sign in.';//the body of the email you are sending

mail($to, $subject, $message);//mail sent

?>
and this is dblink.php:

Code: Select all

<?php
$link = mysql_connect('127.0.0.1', 'twarowsk_newdata@freeownhost.com', '********');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
thanks,

matt
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Connected successfully???
Connected successfully
Warning: mysql_query(): Can't connect to local MySQL server through socket
Mods please remove username from this person's connection string....

A couple notes. Try replacing the IP address with the sting "localhost"

Also put the die() after the mysql_connect();
wyred
Forum Commoner
Posts: 86
Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore

Post by wyred »

Take a close look at line 7 of your dblink.php.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

wyred wrote:Take a close look at line 7 of your dblink.php.
Holy Cats! I missed that....lol
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

Post by method_man »

i still cant figure out what the problem is
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Re: mysql querry error

Post by hawleyjr »

method_man wrote:
and this is dblink.php:

Code: Select all

<?php
$link = mysql_connect('127.0.0.1', 'twarowsk_newdata@freeownhost.com', '********');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
Remove:

Code: Select all

mysql_close($link);
Post Reply