一个关于php执行mysql语句的有关问题,头都快搞炸,求前辈

WBOY
Release: 2016-06-13 13:31:25
Original
923 people have browsed it

一个关于php执行mysql语句的问题,头都快搞炸,求前辈!
php执行添加用户的mysql语句, 求前辈指点啊,我搞了一晚上没搞好,如下[POST获取的]
向localhost添加$user的用户,密码为$pass,并创建名为$user的数据库,授予读写删权限,哎,
不加变量我会搞,一加就头晕了,老提示语法错误
求前辈啊,各位不要路过牙,你们是我的希望啊!

------解决方案--------------------
$user = '用户';
$pass = '密码';

$sql = "crearte databuse $user";

$sql =grant select, insert, delete
on $user
to $user@localhost identifed by '$pass'
SQL;

以 root 连接数据库,依次执行两个 $sql 即可
如有语法错误请自行修改,有点记不清楚了
------解决方案--------------------
首先

你这里就不对


$user = '用户';
$pass = '密码';

$sql = "crearte databuse $user";


$sql="create database '"+$user+"'";

因为你发到mysql 客户端,他是不能识别解析$user
------解决方案--------------------
楼主的代码呢?

PHP code

$user = '用户';
$pass = '密码';
$sql = "crearte databuse $user";


$sql="create database '".$user."'"; <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!