by sv_vanan » 03. September 2009 10:15
Hi,
I'm beginner to Xampp, i've created the database (helpdesk) using localhost\phpMyadmin and can see the database files in MySQL->Data folder. Then i've created the user interface in localhost\index.php, now the problem is i can't save the data from the user interface to the database. Anyone can advice why i can't connect to the database?
Error Message:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in C:\xampp\htdocs\registerprocess.php on line 3
Could not connect: Can't connect to MySQL server on 'localhost' (10061)
The config.php file that i've used is as below:
<?php
$host= "localhost";
$pass="";
$login="";
$db= "helpdesk";
?>
The registerprocess.php is as below:
<?php
include ("config.php");
$con = mysql_connect($host,$login,$pass);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db, $con);
mysql_query("INSERT INTO user (`UName`,`UPass`,`UDName`,`UType`)
VALUES('".$_POST["UName"]."', '".$_POST["UPass"]."', '".$_POST["UDName"]."', '".$_POST["UType"]."')");
mysql_close();
header("Location:default.html")
?>