doupike2351 2013-05-08 17:08
浏览 62
已采纳

PHP和MySql使用PDO'字符串数据,右截断'在PHPMyAdmin中插入图像后出错

I am pretty new to PHP and MySql and am having trouble with I think a LongBlob column in my DB. the entire error is here

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01004]: String data, right truncated' in Client.php:110 Stack trace: #0 Client.php(110): Client::FindByOwnerID() #1 User.php(91): Client->FindByOwnerID('2') #2 UserController.php(26): User->FindByID('2') #3 {main} thrown in Client.php on line 110

I only seem to get this error if I upload an image to a LongBlob column. If I delete the row with the image everything works great.

I am using PDO to connect to to my database, I have searched for a solution but have only found similar problems that do not seem to mention anything about Images...

Is this a SQL Config issue, am I missing a PDO attribute?

Here is my PDO code

$dbConnString = "mysql:host=" . DB_SERVER . ";port=".DB_PORT."; dbname=" . DB_DATABASE;
$this->dbConnection = new PDO($dbConnString, DB_USERNAME, DB_PASSWORD);        
$this->dbConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);   
  • 写回答

1条回答 默认 最新

  • doushi7805 2013-05-08 17:20
    关注

    I personaly prefer not to store images in database but if you need to : check the image size it if it exceeds 1MB you have to increase the max_allowed_packet option in the server configuration file. You can change that in the Startup Variables section in the MySQL Administrator on the Networking page.

    Check this link

    http://dev.mysql.com/doc/refman/5.0/en/program-variables.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀