iT邦幫忙

0

SQL 將資料庫內容匯出成.txt檔

我想將我的資料庫資料匯出成.txt檔案格式
這是我上網看教學的可是他不會跑 請幫幫我

<?php
require_once("SQL_data.php");
$insert_new2=$_POST['date'];
$insert_new1="Y";
$insert_new0=$_POST['id'];
mysql_select_db($database,$GD);   
$sql=sprintf("SELECT * INTO OUTFILE 'htdocs:/image/test.txt' FROM b17_25153459_people.app_shop_for_cart;");
$Result=mysql_query($sql,$GD) or die(mysql_error());
mysql_close();
exit();
?>

SQL_data

<?php
$hostname="";
$username="";
$password="";
$database="b17_25153459_people";
$GD=mysql_pconnect($hostname,$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET NAMES UTF8");
mysql_query("SET CHARACTER_SET_CLIENT='utf8'");
mysql_query("SET CHARACTER_SET_RESULTS='utf8'");
?>

https://ithelp.ithome.com.tw/upload/images/20200309/20109685qqwHP94CbR.png
https://ithelp.ithome.com.tw/upload/images/20200309/20109685XcSEw2bpV9.png
權限
https://ithelp.ithome.com.tw/upload/images/20200309/20109685wupW3jtrtp.png

我的錯誤代碼 檢查過了一次 他沒寫哪裡有問題

 StrictMode policy violation; ~duration=862 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at cz.msebera.android.httpclient.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:259)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:159)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    StrictMode policy violation; ~duration=862 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:198)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:74)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at cz.msebera.android.httpclient.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:259)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:159)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/StrictMode: StrictMode policy violation; ~duration=836 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:389)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
        at java.net.Socket.connect(Socket.java:621)
        at cz.msebera.android.httpclient.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    StrictMode policy violation; ~duration=836 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:135)
        at libcore.io.ForwardingOs.connect(ForwardingOs.java:95)
        at libcore.io.IoBridge.connectErrno(IoBridge.java:157)
        at libcore.io.IoBridge.connect(IoBridge.java:135)
        at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
        at java.net.Socket.connect(Socket.java:621)
        at cz.msebera.android.httpclient.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/StrictMode: StrictMode policy violation; ~duration=475 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:161)
        at cz.msebera.android.httpclient.impl.io.AbstractSessionOutputBuffer.flushBuffer(AbstractSessionOutputBuffer.java:159)
        at cz.msebera.android.httpclient.impl.io.AbstractSessionOutputBuffer.flush(AbstractSessionOutputBuffer.java:166)
        at cz.msebera.android.httpclient.impl.io.ContentLengthOutputStream.flush(ContentLengthOutputStream.java:101)
        at cz.msebera.android.httpclient.entity.StringEntity.writeTo(StringEntity.java:170)
        at cz.msebera.android.httpclient.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:96)
        at cz.msebera.android.httpclient.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:112)
        at cz.msebera.android.httpclient.impl.entity.EntitySerializer.serialize(EntitySerializer.java:117)
        at cz.msebera.android.httpclient.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:265)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:203)
        at cz.msebera.android.httpclient.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:237)
        at cz.msebera.android.httpclient.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:122)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:685)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:487)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
    StrictMode policy violation; ~duration=474 ms: android.os.strictmode.NetworkViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1570)
        at java.net.SocketInputStream.read(SocketInputStream.java:175)
        at java.net.SocketInputStream.read(SocketInputStream.java:144)
        at cz.msebera.android.httpclient.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:160)
        at cz.msebera.android.httpclient.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:84)
        at cz.msebera.android.httpclient.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:273)
        at cz.msebera.android.httpclient.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
        at cz.msebera.android.httpclient.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
        at cz.msebera.android.httpclient.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
        at cz.msebera.android.httpclient.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:283)
        at cz.msebera.android.httpclient.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:251)
        at cz.msebera.android.httpclient.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:197)
        at cz.msebera.android.httpclient.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
        at cz.msebera.android.httpclient.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:685)
        at cz.msebera.android.httpclient.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:487)
        at cz.msebera.android.httpclient.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:879)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
        at cz.msebera.android.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
        at com.example.useweb0204.Upphp_shop_buy.Interting(Upphp_shop_buy.java:29)
        at com.example.useweb0204.tab3$5$1.onClick(tab3.java:240)
        at androidx.appcompat.app.AlertController$ButtonHandler.handleMessage(AlertController.java:167)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
D/EGL_emulation: eglMakeCurrent: 0xd641a0c0: ver 3 0 (tinfo 0xbc6d9f60)
I/Choreographer: Skipped 61 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xd641a0c0: ver 3 0 (tinfo 0xbc6d9f60)
I/OpenGLRenderer: Davey! duration=1198ms; Flags=0, IntendedVsync=8841665064259, Vsync=8842681730885, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=8842696438139, AnimationStart=8842696512439, PerformTraversalsStart=8842696632339, DrawStart=8842773104439, SyncQueued=8842773596139, SyncStart=8842775211639, IssueDrawCommandsStart=8842775523539, SwapBuffers=8842777881239, FrameCompleted=8842864718339, DequeueBufferDuration=112000, QueueBufferDuration=244000, 
看更多先前的討論...收起先前的討論...
froce iT邦大師 1 級 ‧ 2020-03-09 11:25:22 檢舉
你output到server的C槽了。
求關注 iT邦新手 5 級 ‧ 2020-03-09 11:40:45 檢舉
感謝你的回復
他沒有ㄟ
dragonH iT邦超人 5 級 ‧ 2020-03-09 11:49:43 檢舉
或者你遇到權限的問題

把 log 或錯誤訊息拿出來看
求關注 iT邦新手 5 級 ‧ 2020-03-09 13:38:55 檢舉
我有在想是不是權限 可是我全開了理論上因該是可以 android那邊 我確定是可以執行的 因為這個php之前是用來跑$sql=sprintf("UPDATE app_shop_for_cart SET buy='%s',order_date='%s' WHERE user_id='%s' and order_date is null ",$insert_new1,$insert_new2,$insert_new0); 更新資料的 只是現在我想要改成把資料庫資料匯出成.txt
然後就卡關了==
dragonH iT邦超人 5 級 ‧ 2020-03-09 13:41:07 檢舉
>我有在想是不是權限 可是我全開了理論上因該是可以 android那邊

那就先不要透過 android 執行

直接 hardcode 測你的 php

然後你上面說的那個 update 跟你現在想要做的

是完全不同的事
求關注 iT邦新手 5 級 ‧ 2020-03-09 14:17:13 檢舉
我試過直接跑 一樣跑不出來
Access denied for user 'b17_25153459'@'192.168.%' (using password: YES)
他擋住我了 所以是我空間的問題囉??
dragonH iT邦超人 5 級 ‧ 2020-03-09 14:30:07 檢舉
你的 database 是不是用別人的 service

不是自己建的?

例如在某個 ubuntu 自己建一個 mysql server
求關注 iT邦新手 5 級 ‧ 2020-03-09 14:34:43 檢舉
對我是用vistapanel當我的虛擬主機在上面建立的
dragonH iT邦超人 5 級 ‧ 2020-03-09 15:04:21 檢舉
檢查一下你的權限吧 如果可以的話
froce iT邦大師 1 級 ‧ 2020-03-09 15:07:28 檢舉
拜託你先用你的電腦搞個前後端都有的環境,確定都沒問題,然後再丟虛擬主機好嗎?
網路上隨便抓個code,複製貼上,然後根本也看不懂你貼的code...
這行有這好混就好了。

2 個回答

0
小魚
iT邦大師 1 級 ‧ 2020-03-09 13:47:10

為什麼你的錯誤訊息是android?
你是在Android上面執行嗎?
你在電腦上面執行可以嗎?

而且不是應該是

SELECT * FROM `table` INTO OUTFILE '{filename}';

還是說其實都可以?

求關注 iT邦新手 5 級 ‧ 2020-03-09 14:05:20 檢舉

我的意思是我用手機跑php
痾 錯誤 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''app_shop_for_cart' INTO OUTFILE 'test.txt'' at line 1

你的意思是這樣嗎?

$sql=sprintf("SELECT * FROM 'app_shop_for_cart' INTO OUTFILE '{test.txt}' ");
求關注 iT邦新手 5 級 ‧ 2020-03-09 14:08:04 檢舉

我試過直接跑 一樣跑不出來
Access denied for user 'b17_25153459'@'192.168.%' (using password: YES)

小魚 iT邦大師 1 級 ‧ 2020-03-09 16:31:02 檢舉

這個錯誤訊息是你連不上MySql,
有可能是帳號密碼錯誤或設定錯誤之類的,
可能要先從MySql權限上去解決.

0
神威
iT邦新手 1 級 ‧ 2020-03-10 09:19:02

那個

$Result=mysql_query($sql,$GD) or die(mysql_error());

改成

$Result=mysql_query($GD,$sql) or die(mysql_error());

試試,這樣應該能連到資料庫
現在看來你連資料庫都沒連到

看更多先前的回應...收起先前的回應...
求關注 iT邦新手 5 級 ‧ 2020-03-10 09:45:25 檢舉

感謝回覆這段"Access denied for user 'b17_25153459'@'192.168.%' (using password: YES)"消失了
可是我看ftp 檔案沒出現

<?php
require_once("SQL_data.php");
//$insert_new2=$_POST['date'];
//$insert_new1="Y";
//$insert_new0=$_POST['id'];
mysql_select_db($database,$GD);   
//$sql=sprintf("UPDATE app_shop_for_cart SET buy='%s',order_date='%s' WHERE user_id='%s' and order_date is null ",$insert_new1,$insert_new2,$insert_new0);
$sql=sprintf("SELECT * FROM 'app_shop_for_cart' INTO OUTFILE '{history.txt}' ");
$Result=mysql_query($GD,$sql) or die(mysql_error());
mysql_close();
exit();
?>
SELECT * FROM 'app_shop_for_cart' INTO OUTFILE '/htdocs/image/history.txt'
求關注 iT邦新手 5 級 ‧ 2020-03-10 10:19:20 檢舉

這行我試過了 也不行:(

SELECT * FROM 'app_shop_for_cart' INTO OUTFILE '/htdocs/image/history.txt'
神威 iT邦新手 1 級 ‧ 2020-03-10 10:35:24 檢舉

你現在是要把sql轉txt檔並且存到手機沒錯吧?
如果試不起來,可以換個方式
你把資料讀到手機,再寫成TXT這樣應該也OK吧?
可以試試看

我覺得你要先學會釐清問題

感謝回覆這段"Access denied for user 'b17_25153459'@'192.168.%' (using password: YES)"消失了

所以 你的 mysql_select_db($database,$GD); return 是 true?
如果是 再來下個步驟

我看 mysql_query 的函數是這樣用的 mysql_query( $sql,$connect );
你的 sql 跟 connect 是確定的?

$Result=mysql_query($GD,$sql) or die(mysql_error());

$Result 是 true false 還是 error?

求關注 iT邦新手 5 級 ‧ 2020-03-10 11:32:56 檢舉

我是要把資料轉成TXT檔 在丟到我要的空間
我試過兩種方式
一、是直接整個資料庫轉TXT再放入網路空間(目前問題所在)
二、將裡面資料輸入到手機的一個STRING裡在讓手機開一個TXT檔案在塞進去(目前問題是沒辦法上傳到空間)

神威 iT邦新手 1 級 ‧ 2020-03-10 11:50:15 檢舉
SELECT * INTO OUTFILE 'C:/Users/ASUS/Documents/XXX.txt' FROM test.tes

test=>資料庫名
tes=>資料表

試試看,我再localhost試OK

求關注 iT邦新手 5 級 ‧ 2020-03-10 14:42:30 檢舉

因為目前試都失敗 我在想是不是這個免費空間有問題
請問如果改放在google雲端可以嗎?
就是改方法二這樣的 先創建一個.txt的檔案 在將檔案存到雲端去

神威 iT邦新手 1 級 ‧ 2020-03-10 15:15:30 檢舉

根據我的實驗,無法
他拒絕讓我寫入....

Can't create/write to file 'https:\\drive.google......' (Errcode: 13 "Permission denied")
開啟新 phpMyAdmin 視窗
求關注 iT邦新手 5 級 ‧ 2020-03-10 16:09:02 檢舉

抱歉 我的意思是因該是 手機的一個TXT檔案放入雲端的這樣

神威 iT邦新手 1 級 ‧ 2020-03-10 16:42:48 檢舉
求關注 iT邦新手 5 級 ‧ 2020-03-12 11:14:50 檢舉

是要存google雲端沒打好 目前在看
"dragonH"提供的方法 好難頭痛
[https://developers.google.com/drive/api/v3/quickstart/java]

我要發表回答

立即登入回答