Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
Connect to Mysql database using php Fail

Hi so i am trying to make a login system using mysql and php but i constantly get the error

Warning: mysql_connect(): Access denied for user 'testuser'@'localhost' (using password: YES) in E:\PHP_Runner\php\root\process.php on line 10

The user is created as seen in the picture Any suggestions/help?

<?php
$username = $_POST['user'];
$password = $_POST['pass'];

$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

mysql_connect("localhost",$username, $password) or die("Could not connect to database");
mysql_select_db("users");

$result = mysql_query("select * from users where username = '$username' and password = '$password'")
        or die("Failed to query database" .mysql_error());

$row = mysql_fetch_array($result);
if($row['username'] == $username && $row['password'] == $password){
echo "Login success !! welcome".$row['username'];
}else{
    echo "Failed to login";
}

?>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

To connect to mysql db phpmyadmin or any interface you will need to have mysql login credentials which is not a user login credentials this is usually set at the installation of mysql or you will be using the default. Now this set credentials will replace mysql_connect("localhost", $TheSetUserNameForMysqlDb, $TheSetPasswordForMysqlDb) I hope this help

Which I don't recommend using the default

over 4 years ago · Santiago Trujillo Report

0

mysql connect should be something like

mysql_connect("localhost","root", ""); // if you use phpmyadmin in localhost. here root is the defualt admin username of mysql and default password is empty.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!