php变量确实存储了大量的文本内容

时间:2016-08-17 13:29:48

标签: php mysql

我试图使用php,

在mysql中存储一些数据
$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变量有一些限制存储字符串字符? 那我该怎么办?请帮我。 谢谢。

2 个答案:

答案 0 :(得分:2)

  1. 转到phpMyAdmin,转到您的表pet_trainer并查看description列设置(点击phpMyAdmin中的表名,然后点击结构)

    SQL dB Structure setting

    您有几个选择:

    • text
    • varchar(max length of content)

    如果您只想存储原始文本或html文本,我建议您使用文本作为pet_trainer列的类型设置。

  2. 其次,检查第一个变量的值,不再显示 (在你的例子中:$contact)如果这个变量的值有问题(即特殊字符或类似的东西),它可能会阻止SQL查询的进一步索引)

  3. 最后,因为整个问题基本上与SQL系统无关,但只是一个不存储简单字符串全长的php变量可能会让你产生问题。停止寻找SQL查询修复程序,因为您没有SQL问题。

    您显示/解释它的方式,您在长字符串中连接变量时出错,这对PHP来说应该不是问题。 (以上仅在您使用PHP而不是在SQL服务器上打印变量时才计算)

    如果您希望我帮助您或其他任何人,那么(在我上次描述的情况下)向我们展示您如何声明变量以及它们的值是什么......

      

    您更新了问题,我继续更新我的答案:)

  4.   

    编辑:对您的评论说你使用了varchar(10000),如果你想要一个长内容字符串,请不要这样做,使用文本,这就是它的用途:)

答案 1 :(得分:0)

yeahh。

我用单行编写所有参数/值,现在它正常工作。

$ sql =“INSERT INTO pet_trainer(姓名,描述,地址,城市,地区,联系方式,电子邮件,时间,纬度,经度)VALUES('”$ name“','”$ description“','”$地址“','”$ city“','”$ area“','”$ contact“','”$ email“','”$ timing“','$ lat','$ long')” ;