2016-08-17 50 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') “;