Retrieving MySQL LONGTEXT data using mysqli

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Captaffy
Forum Newbie
Posts: 4
Joined: Sun Dec 10, 2006 2:02 pm

Retrieving MySQL LONGTEXT data using mysqli

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What did you stick into the field?
Captaffy
Forum Newbie
Posts: 4
Joined: Sun Dec 10, 2006 2:02 pm

Post 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.
Captaffy
Forum Newbie
Posts: 4
Joined: Sun Dec 10, 2006 2:02 pm

Post by Captaffy »

It should also be noted that the the actual query works in phpmyadmin as well.
Captaffy
Forum Newbie
Posts: 4
Joined: Sun Dec 10, 2006 2:02 pm

Post 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]);
Post Reply