Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-29-2007, 03:15 PM #1
- Join Date
- Jan 2007
- Thanked 0 Times in 0 Posts
Problem create new mysql user w/ php code
I'm new to every thing and trying to create new mysql user w/ php code as below, but always got error message "Error, insert query failed". Please, point out what I did wrong and how to fix it.
$connect = mysql_pconnect('localhost', $AdminName, $AdminPass)
or die('Error, login db failed');
mysql_select_db(mysql) or die('Error, open db failed');
$query = "INSERT INTO user(Host, User, Password)
VALUES('localhost', '$UserName', '$UserPass')";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, flush query failed');
$query = "INSERT INTO user
(Host, User, Password, Select_priv, Insert_priv, Update_priv)
VALUES ('localhost', $UserName, PASSWORD($UserPass), 'Y', 'Y', 'Y')";
Edit: My info as follows:
Windows XP Pro w/ SP2
Apache 2.0.59 (Win32)
Thanks a million
Last edited by guelphdad; 01-30-2007 at 02:42 PM.
01-30-2007, 02:43 PM #2
- Join Date
- Mar 2006
- St. Catharines, Ontario Canada
- Thanked 147 Times in 138 Posts
die('Error, open db failed');
die('Error, open db failed') . mysql_error();
Also are you running this as the root user to mysql or another user privileged to add new users to your database?