dev99 Posted April 14, 2006 Share Posted April 14, 2006 my script is to create a database with NO root priviliges... and i keep getting errors when i try to create one...<?phpif (empty($_GET['mode'])) { echo "<form action='/create_db.php?mode=process' method='post'> <table border='0' cellpadding='2' cellspacing='0' width='100%'> <tr> <td valign='top' align='left'><b><u><font face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular' size='-1'>Database Name:</font></u></b><br> <td valign='top' align='left'><input name='dbname' value=''></td> </tr> <tr> <td valign='top' align='left'><b><u><font face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular' size='-1'>Login to Database:</font></u></b><br> <td valign='top' align='left'><input name='username' value=''></td> </tr> <tr> <td valign='top' align='left'><b><u><font face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular' size='-1'>Password:</font></u></b><br> <td valign='top' align='left'><input type='password' name='pass'></td> </tr> <tr> <td valign='top' align='left'><b><u><font face='Arial,Helvetica,Geneva,Swiss,SunSans-Regular' size='-1'>Re-enter Password:</font></u></b><br> <td valign='top' align='left'><input type='password' name='pass2'></td> </tr> <tr> <td valign='top' align='middle' colspan='2'><br><input type='hidden' name='createdb' value='1'><input type='submit' value='Create Database'></td> </tr> </table> </form>";}elseif ($_GET["mode"] == "process") {extract($_POST);if ($pass == $pass2) { mysql_connect("localhost","root","mypass"); $sql = "GRANT ALL PRIVILEGES ON $dbname.* TO '$username'@'localhost' IDENTIFIED BY 'pass'"; echo $sql; if (mysql_query($sql)) { echo "Successfully created user account $username <p>"; } else { echo mysql_error(); } mysql_close(); mysql_connect("localhost",$username,$pass); $sql = "CREATE DATABASE $dbname"; if (mysql_query($sql)) { echo "Database $dbname created successfully!"; } else { echo mysql_error(); }} else { echo "Your passwords do not match! Try again!"; }}?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.