Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我不想在mysql中的每个表之前都保留dbname_Php_Mysql_Database - Fatal编程技术网

Php 我不想在mysql中的每个表之前都保留dbname

Php 我不想在mysql中的每个表之前都保留dbname,php,mysql,database,Php,Mysql,Database,我已经在IIS、windows 2012中安装了带有数据库的php网站,问题是,如果我在网站中的每个查询的表名之前提到db名称,这是可以接受的。下面的例子 select userid,profile_id,email,first_name,last_name,password,login_flag,usertype from reqsbook.user where email='$email' and password='$password' and usertype='$user

我已经在IIS、windows 2012中安装了带有数据库的php网站,问题是,如果我在网站中的每个查询的表名之前提到db名称,这是可以接受的。下面的例子

select userid,profile_id,email,first_name,last_name,password,login_flag,usertype 
from reqsbook.user 
where email='$email'
  and password='$password' 
  and usertype='$usertype'
实际上,我曾经在LinuxWeb服务器上运行过这个网站,但根据我的客户端要求,我已经在iis服务器上安装了它。
请让我知道,在我的项目中的所有查询中,是否有可能在表之前删除db名称,或者我是否可以将db名称保留在一个位置,以便universal执行此操作,假设您的数据库名称为
reqsbook

  • 给出SQL命令
    USE reqsbook从php连接到dbms后,在给出任何
    选择
    或其他查询之前立即执行

  • 如果您正在使用类似以下内容:

    $mysqli=newmysqli('hostname','username','REDACTED_PASSWORD','reqsbook')

  • 如果你想试试这样的东西

    $db=newpdo('mysql:host=hosthame;dbname=reqsbook','username','redact_PASSWORD')


  • 如果您使用的是
    mysql\uuu
    ,那么,除非您希望您客户的应用程序被网络犯罪分子攻击,否则请停止这样做。

    您需要在连接上设置活动数据库。您存在SQL注入漏洞。不要以纯文本形式存储密码!调用
    mysqli_connect
    new PDO
    打开连接时,可以指定默认数据库。那么你就不必在查询中输入数据库名了。非常感谢你的回答,这对我很有用