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

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!