Page 1 of 1

Retrieving MySQL LONGTEXT data using mysqli

Posted: Sun Dec 10, 2006 2:05 pm
by Captaffy
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have some code, along the lines of the following, where the column it is selecting is of the type LONGTEXT, from a MySQL database.

Code: Select all

$stmt = $mysqli->prepare(... LIMIT 1);
$stmt->bind_param(...);
$stmt->execute();
$stmt->bind_result($longtext_value);
$stmt->fetch();
The $longtext_value variable just contains garbage however (i.e. random symbols).

Am I doing something wrong? If I use the exact same query, but select a different column such as an INT, it works fine.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Dec 10, 2006 2:08 pm
by feyd
What did you stick into the field?

Posted: Sun Dec 10, 2006 2:46 pm
by Captaffy
feyd wrote:What did you stick into the field?
Do you mean, what is the value in the column? They are strings, consisting of about 50 characters. The DB is part of another application, and I am using data from it.

Posted: Sun Dec 10, 2006 2:54 pm
by Captaffy
It should also be noted that the the actual query works in phpmyadmin as well.

Posted: Sun Dec 10, 2006 3:11 pm
by Captaffy
I used mysqli_stmt_query instead of mysqli_stmt_prepare/execute, and it works...

Code: Select all

$stmt = $mysqli->query("SELECT ... LIMIT 1");
$row = $stmt->fetch_row();
print($row[0]);