PHP MySQLi returns empty variables from longtext column

The problem is that when using the PHPMySQLi extension with prepared statements, I was getting an empty value in one of my bound variables after using $mysqli->execute(), $stmt->bind_param(), and $stmt->fetch(). If I executed the exact same query using $mysqli->query() and subsequently using $result->fetch_object() I would get the values I was looking for.

…In any event, we’ll be able to work with a TEXT column instead of using a LONGTEXTcolumn in this application.

Develobert: PHP MySQLi bind_result Empty LONGTEXT.

Good to know I’m not alone. Switching the column to text instead of longtext may be low tech, but if it’s good enough for Joe Kovar it’s good enough for me.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

  • Peter Stacey

    I was having this problem on a database that was used by existing application and so couldn't change the column type. After much searching I discovered that if you store the result of the query with $stmt->store_result(); before $stmt->bind_result($var) it works!


    • beezeee

      Awesome find Peter, thanks so much for sharing! This is definitely the more sophisticated approach.