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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序