doukeng1922 2014-08-06 14:47
浏览 30
已采纳

连接到Google云端硬盘中的数据库

In my Google Drive Storrage I have a database (SQL file) which I want to read out from a PHP file on my webserver. The database looks like this:

DB_Name:  Test
TBL_Name: Namen

| id | Vorname |  Nachname  |
-----------------------------
|  1 | Max     | Mustermann |
|  2 | Hanz    | Peter      |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now I tried to connect to the SQL file with this basic PHP code:

$verbindung = mysql_connect($driveLink, "", "")
or die("Failed to create connection.");

mysql_select_db("Test")
or die ("The database does not exists.");

$abfrage = "SELECT Vorname FROM Namen";
$ergebnis = mysql_query($abfrage);

while($row = mysql_fetch_object($ergebnis))
{
    echo "$row->Vorname";
}

But I can't get a connection to the file. Why is that? I have not set a username or password for the database so I pass empty strings to it, right? Also I gave the file access to everyone so I can reach the file from my code.

Is that because there is no underlying system like PhpMyAdmin or something else? How can I connect to the database from PHP?

  • 写回答

2条回答 默认 最新

  • dpoxk64080 2014-08-06 14:53
    关注

    An SQL file only contains raw SQL commands, which you can run on a database server.

    When you use mysql_connect, you have to connect to a database server (specifically a MySQL database server). Then you can use other SQL commands via mysql_query.

    Is that because there is no underlying system

    Yes

    like PhpMyAdmin

    No. PHPMyAdmin is an SQL client, not a server. It also has to connect to a MySQL server.


    NB: mysql_ is an obsolete database API and should use a modern replacement.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退