unable to connect php to mysql using xampp

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

unable to connect php to mysql using xampp

Postby sprouts11 » 20. March 2013 19:25

I am having trouble connecting to mysql database. The page loads fine with my 3 text boxes. When I populate the text boxes and click 'register' nothing happens. What I'm expecting to see is '1 row inserted' and for the data to be populated in mysql.

Can anybody HELP! Thanks!

Here is my code below...
<form method="POST" action="insert.php">
Name: <input type="text" name="name" /> <br />
Email: <input type="text" name="email" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="submit" value="register" /><br />

$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];

if($name && $email && $password){

mysql_connect("localhost", "root", "") or die("We could not connect!");


mysql_query("INSERT INTO accounts(name,email,password) VALUES('$name','$email','$password')");

$registered = mysql_affected_rows();

echo "$registered was inserted";


echo "you have to complete the form!";


Posts: 1
Joined: 20. March 2013 19:17
XAMPP Version: 5.6.3
Operating System: windows vista home

Re: unable to connect php to mysql using xampp

Postby Altrea » 20. March 2013 19:39

sprouts11 wrote:<form>
<form method="POST" action="insert.php">

And you should learn how to debug your code.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
AF Moderator
Posts: 7051
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: Windows 10 Pro x64

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 44 guests