簡體   English   中英

如何運行PHP中有多行的MySQL Query?

[英]How to run MySQL Query which has multiple lines in PHP?

如何在PHP中運行如下查詢:

INSERT INTO table VALUES ('example name', 'thisisfirstline
           thisissecondline
           thisisthirdline')

我已將文字設置為文本。

當我與Navicat一起運行時,我一點都沒有問題。 我嘗試在PHP中運行它:

mysql_query("INSERT INTO table VALUES ('example name', 'thisisfirstline
           thisissecondline
           thisisthirdline') 
           OR die('ERROR');

輸出以下內容:

thisisfirstlinethisissecondlinethisisthirdline

如何插入值而不將其全部粘貼在一起?

\\n用於在MySQL表中插入換行符:

INSERT INTO table VALUES ('example name', 'thisisfirstline\n
    thisissecondline\n
    thisisthirdline')

將類型設置為varchar而不是表中的text

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM