tags:

views:

57

answers:

4

what is the syntax to execute this statement in php page-

grant file on *.* to kentest@localhost identified by 'kentest1';
+1  A: 

Check your [MySQL?] database vendors documentation - because that's a DBMS statement, not PHP. I'd start here: http://php.net/manual/en/function.mysql-connect.php

EDIT: To clarify, assuming you get your connection working, it would be as simple as wrapping your query in a call to mysql_query(). Example:

mysql_connect(...);
mysql_select_db(...);
mysql_query("grant file on *.* to kentest@localhost identified by 'kentest1';");
Chris
A: 
  1. Check out the GRANT command! http://dev.mysql.com/doc/refman/5.1/en/grant.html
  2. Check out the CREATE USER command! http://dev.mysql.com/doc/refman/5.1/en/account-management-sql.html

Ultimately check out the all section about account management in MySQL: http://dev.mysql.com/doc/refman/5.1/en/account-management-sql.html

Notinlist
A: 

firstly,you check the user of mysql_connect,is a root? this user must have the right to grant.

Sam
A: 

Here's some basic code that will work for many MySQL queries, including GRANT so long as the user is permissioned to do so:

// Credential variables, separated so we can reuse them later
$host = "localhost";
$user = "user";
$pass = "123456notsecure";
$db = "database_to_use";

// Set up the query we're going to run
$query_to_run = "QUERY TO RUN";
// Make the MySQL connection
$mysql_connection = mysql_connect($host, $user, $pass);
// Select the database to use
mysql_select_db($db) or die(mysql_error());
// Run the query
$result_of_query = mysql_query($query_to_run) or die('Running the query failed: ' . mysql_error());
// Close the MySQL connection
mysql_close($mysql_connection);
editor