I want to ask about create user and database from PHP Code.
I have cpanel at server. At my application, I want my app create a database to backup something. But I always get error "access denied"
So, how to create a database and assign user to that database so this user can access it.
My code right now is:
<?php
$con = mysql_connect("localhost","k3516438_disp","secret");
mysql_query("GRANT ALL PRIVILEGES ON *.* TO 'k3516438_disp'@'localhost' IDENTIFIED BY PASSWORD 'secret' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE DATABASE IF NOT EXISTS k3516438_dispatcher_backup",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_select_db("universal_backup", $con);
$sql = "CREATE TABLE order_backup
(
order_id varchar(15),
request_id varchar(15)
)";
mysql_query($sql);
?>
And it still not works, that code I have write is from this: problem. But it doesn't work for me, I thought. Sorry for my Bad English.