yfastud
01-29-2007, 04:15 PM
Hi,
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.
<?php
$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');
?>
And even tried it w/ this code
[
$query = "INSERT INTO user
(Host, User, Password, Select_priv, Insert_priv, Update_priv)
VALUES ('localhost', $UserName, PASSWORD($UserPass), 'Y', 'Y', 'Y')";
Already searched but not successful, so if this problem was posted here, please post the link here
Edit: My info as follows:
Windows XP Pro w/ SP2
Apache 2.0.59 (Win32)
PHP 5.1.6
MySQL 5.1.12-bt
Thanks a million
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.
<?php
$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');
?>
And even tried it w/ this code
[
$query = "INSERT INTO user
(Host, User, Password, Select_priv, Insert_priv, Update_priv)
VALUES ('localhost', $UserName, PASSWORD($UserPass), 'Y', 'Y', 'Y')";
Already searched but not successful, so if this problem was posted here, please post the link here
Edit: My info as follows:
Windows XP Pro w/ SP2
Apache 2.0.59 (Win32)
PHP 5.1.6
MySQL 5.1.12-bt
Thanks a million