Hi everyone,

Ok so let me start by saying I am COMPLETELY new with MySQL, I have only tried to use it for the first time hours ago. This might be an easy one for you guys...

Here's my code:

<?php

// Grab User submitted information
$email = $_POST['users_email'];
$pass = $_POST['users_pass'];

// Connect to the database
$con = mysql_connect('localhost','root','');
// Make sure we connected succesfully
if(! $con)
{
    die('Connection Failed'.mysql_error());
}

// Select the database to use
mysql_select_db('riseguin_clients',$con);

$result = mysql_query('SELECT users_email, users_pass FROM users WHERE users_email = $email');

$row = mysql_fetch_array($result);

if($row['users_email']==$email && $row['users_pass']==$pass)
    echo'You are a validated user.';
else
    echo'Sorry, your credentials are not valid, Please try again.';
?>

When I run it, it says the following:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /hermes/bosweb/web183/b1836/ipg.mywebsite/validate_login.php on line 8
Connection FailedCan't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Thanks for your help,
Richard

I'm pretty sure it is!

Do you have a way of connecting into an admin mysql like phpmyadmin or by logging into the server?

the mysql_connect() details must be incorrect $con = mysql_connect('localhost','root','');

mysql_connect($host,$user,$pass);

also i suggest using mysqli instead

mysqli_connect($host,$user,$pass,$db);

mysql_ is being phased out sometime in the future so may as well start your project with mysqli(mysql improved)

Heres the code to create a new user on mysql when you get onto the admin:

CREATE USER 'test'@'%' IDENTIFIED BY 'pass123'; 
FLUSH PRIVILEGES; 
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TABLESPACE, CREATE TEMPORARY TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, FILE, INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOW VIEW, SHUTDOWN, SUPER, TRIGGER, UPDATE ON *.* TO 'test'@'%' WITH GRANT OPTION; 

and suggest using sql yog community for mysql work, I personally love it, we have it on every server

hi I need same problem My MySQL Please give me Best Solutaion

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.