2016-08-17 118 views
-3

我嘗試使用PHP來存儲在MySQL的一些數據,PHP變量不存儲大量的文本內容

$description="Hi, My Name is Nilesh C. Narvekar, I am a Dog Trainer since last 12 years experience in this field. also I am participate my trained dogs in DOG SHOWS (in Obedience class as well as Breed Shows) So Please Contact me on My Cell no. 9920 338835 I teach HEEL (walk), STAY, SIT, SHAKE HAND (Right/Left), DOWN, RECALL, Retrieve (Ball/Any Article) SALUTE, REST, SLEEP, ROLL, SPEAK, ATTACK, SEARCHING, PERSONAL PROTECTION, GUARD AND Much & More I use Positive Reinforcement training System i.e. (first I give more Exercise for reducing Dogs energy level then doing more practice with dogs and then after I use some treats for giving Dogs attention and concentration to me in training session)"; 

$sql = "INSERT INTO pet_trainer(name, description, address, city, area, contact, email, timing, latitude, longitude) 
          VALUES 
          (
          '"$name"', 
          '"$description"', 
          '"$address"', 
          '"$city"',      
          '"$area"', 
          '"$contact"', 
          '"$email"', 
          '"$timing"', 
          '$lat', 
          '$long' 
          )"; 

當我試圖執行這個$ SQL變量不把它這樣表示,因爲所有細節大描述。

INSERT INTO pet_trainer(image, name, description, address, city, area, contact, email, timing, latitude, longitude) 
          VALUES 
          ('', 
          'Nilesh C. Narvekar', 
          '\'Hi, My Name is Nilesh C. Narvekar, I am a Dog Trainer since last 12 years experience in this field. also I am participate my trained dogs in DOG SHOWS (in Obedience class as well as Breed Shows) So Please Contact me on My Cell no. 9920 338835 I teach HEEL (walk), STAY, SIT, SHAKE HAND (Right/Left), DOWN, RECALL, Retrieve (Ball/Any Article) SALUTE, REST, SLEEP, ROLL, SPEAK, ATTACK, SEARCHING, PERSONAL PROTECTION, GUARD AND Much & More I use Positive Reinforcement training System i.e. (first I give more Exercise for reducing Dogs energy level then doing more practice with dogs and then after I use some treats for giving Dogs attention and concentration to me in training session)\'', 
          'Andheri Mumbai', 
          'Mumbai', 

當我減小$ description的大小時,$ sql取所有數據。 是php變量對存儲字符串字符有一些限制嗎? 那我該怎麼辦?請幫幫我。 謝謝。

+3

數據庫中的描述列的類型是什麼? –

+2

什麼字段類型和長度是你的數據庫中的描述? – RamRaider

+0

@RahulPatel不再使用mysql _ * - 函數。舉個例子,如果他使用'mysqli_real_escape_string()',而不是mysql,那會更好。 – Bobby

回答

2
  1. 去phpMyAdmin的,去你的表pet_trainer並期待在description列設置(單擊phpMyAdmin的表名,然後單擊結構)

    SQL dB Structure setting

    你有一對夫婦的選擇:

    • text
    • varchar(max length of content)

    如果你只是想保存原始文本或HTML文本,那麼我建議你使用文字作爲列pet_trainer的類型設置。

  2. 其次,檢查是否已不再顯示 (在你的榜樣:$contact)的第一個變量的值,如果這個變量有一些錯誤的值(即特殊字符或類似的東西),這可能會阻止進一步sotrage的SQL查詢)

  3. 最後,由於這整個問題基本上與SQL系統無關,但只是一個PHP變量,將不會存儲一個簡單的字符串的全長可能讓你問題。停止查找SQL查詢修復程序,因爲您沒有SQL問題。

    你正在顯示/解釋它的方式,你有一個錯誤連接長字符串中的變量,這不應該是一個PHP的問題.. (以上只是計數,如果你打印變量在PHP和不在SQL服務器上)

    如果您希望我幫助您或其他人解決這個問題,那麼(在我最後一次描述的情況下)告訴我們您如何聲明變量以及它們的值是什麼...

    你更新你的問題,我繼續更新我的答案:)

編輯:反應,您的評論說你使用VARCHAR(10000),不這樣做,如果你想長期的內容字符串,用文字,這就是它是:)

+0

從技術上說,鏈接是爲SQL Server,但總體思路是正確的。 – tadman

0

yeahh。

我寫所有參數/價值在單行,現在它的工作正常。(名稱,描述,地址,城市,地區,聯繫人,電子郵件,時間,緯度,經度)VALUES(''$ name''',''$ description'','''''''$''''''' $ address'',''$ city'',''$ area'',''$ contact'',''$ email'',''$ timing'','$ lat','$ long') 「;