problem to connect mysql local

Problems with the Windows version of XAMPP, questions, comments, and anything related.

problem to connect mysql local

Postby wduizer » 30. October 2013 15:58

Hy

I'm new in the world of scripting PHP, HTML and local hosting with Xampp, so i,m trying to learn a bit about it all.
I've created a form in php with and made the connection with the local mysql to save the input data in the table i've creted in myphpadmin:

<?php
$con=mysqli_connect("127.0.0.1","wduizer","q4MnayTwatX4yJQA","basic_web_development");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO waardes (naam, telnr, email)
VALUES
('$_POST[naam]','$_POST[telnr]','$_POST[email]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>

And then it won't go as planned.
I'll get the following message:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'wduizer'@'localhost' (using password: YES) in G:\htdocs\vza-academy\basic_web_development\html_form_action.php on line 2
Failed to connect to MySQL: Access denied for user 'wduizer'@'localhost' (using password: YES)
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in G:\htdocs\vza-academy\basic_web_development\html_form_action.php on line 13

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in G:\htdocs\vza-academy\basic_web_development\html_form_action.php on line 15
Error:

please help....
wduizer
 
Posts: 2
Joined: 30. October 2013 15:41
XAMPP Version: 5.5.19
Operating System: windows 8 pro

Re: problem to connect mysql local

Postby wduizer » 30. October 2013 16:19

problem solved... the new user i applied didn't have the right rights.
Next question is now, how to set this right. I've connected with "root" without a password.
wduizer
 
Posts: 2
Joined: 30. October 2013 15:41
XAMPP Version: 5.5.19
Operating System: windows 8 pro

Re: problem to connect mysql local

Postby Altrea » 30. October 2013 18:00

How to create a new user with database specific priviledges

phpmyadmin -> Users -> Add User
fill in a username (wduizer), host dropdown field to local (so that the textfield is set to localhost), and twice times your password. Nothing more at this page (no permission ticks), just click the Go-button at the bottom of this page.

After that click on "edit permissions) of this new user
at the section "Database-specific privileges" select the database the user should get permissions to from the dropdown field.
tick the permissions the user should have (SELECT, INSERT, UPDATE are enough for many purposes) and click on the Go-Button of that specific section.
Thats all.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6475
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64


Return to XAMPP for Windows

Who is online

Users browsing this forum: JJ_Tagy and 45 guests