I have a problem with a query.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EDUARD59
Forum Newbie
Posts: 3
Joined: Wed Oct 14, 2009 9:22 am

I have a problem with a query.

Post by EDUARD59 »

Please help:
I am trying to create a mysql database within a php script without any success.
I have a Linux operating system with an apache web server and a mysql database server
all on the same machine.I can create a database within the linux-mysql console but when I try to create the database by php programming is not possible.There is a
connection with the database server.
There is no message of error, simply the program can t process the query
“create database if not exists gestion”.
The program is the following:
<?php
error_reporting(E_ALL|E_STRICT);
ini_set(‘display_errors’,true);
$conn=@mysql_connect(“localhost”,”eduardo”,”diaz”);
If ($conn){
echo “Connect”;
}else{
echo “There is no connection”;
}
$consult=”CREATE DATABASE IF NOT EXISTS gestion”;
$res=mysql_query($consult,$conn);
If ($res){
echo “Success”;
}else{
echo “Faillure”;
}
?>
How can I grant all privileges to a database with php programming?
I am trying the following command without any success:
$consul=”grant all on * to eduardo identified by ‘diaz’ with grant option”;
$res=mysql_query($consul,$conn);
I wrote the grant command in the linux console with success.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: I have a problem with a query.

Post by Eran »

Make sure the user you are connecting with through PHP has permissions to issue a GRANT statement. Probably the user you are running with from the shell has root privileges.
Post Reply