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

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度