A question about PHP to execute MySQL statement, the head is quick to blow up, beg seniors

Source: Internet
Author: User
A question about PHP to execute the MySQL statement, the head is quick to blow up, beg predecessors!
PHP to add the user's MySQL statement, ask the elder pointing ah, I did not do a good night, as follows [post acquisition]
Add $user user to localhost, password is $pass, and create a database named $user, grant read-write delete permission, hey,
Do not add variable I will make, a plus on the dizzy, old hints syntax error
For seniors, please don't pass the tooth, you are my hope Ah!

------Solution--------------------
$user = ' user ';
$pass = ' password ';

$sql = "Crearte databuse $user";

$sql =<<< SQL
Grant SELECT, INSERT, delete
On $user
to [e-mail protected] identifed by ' $pass '
SQL;

Connect to the database as root, execute two $sql in turn
If there are grammatical errors, please modify them, a bit unclear
------Solution--------------------
First of all

You're not right here.


$user = ' user ';
$pass = ' password ';

$sql = "Crearte databuse $user";


$sql = "CREATE DATABASE" + $user + "'";

Because you sent to the MySQL client, he was unable to identify the parsing $user
------Solution--------------------
The code of the landlord?
PHP Code
$user = ' user '; $pass = ' password '; $sql = "Crearte databuse $user"; $sql = "CREATE DATABASE". $user. "";
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.