/    Sign up×
Community /Pin to ProfileBookmark

Displaying datattype ‘Text’

Hello,

I’m completely new to PHP. I’ve created a form which uses can succesfully submit. The data is stored into a MYSQL database.

I’ve created another form to display stored data. This is the code:

<?
$db_server= ‘localhost’;
$database= ‘xxxx’;
$db_user = ‘xxxx’;
$db_passwd = ‘xxxx’;

$db = mysql_connect($db_server,$db_user,$db_passwd) or die(“error :: could not connect to $host MySql Error:”.mysql_error());
$db=mysql_select_db($database) or die(“error :: could not connect to database. MySql Error:”.mysql_error());
$ID=$_GET[“ID”];
$query=”SELECT * FROM HR_applications WHERE ID=$ID”;
$result = mysql_query($query) or die(mysql_error());

$entry = mysql_fetch_object($result);
mysql_free_result($result);

echo “$entry->name”;
echo “$entry->body”;

mysql_close();
?>

This works fine aslong as i set the datatype to varchar(255) in the database. However i want to use the datatype ‘Text’ so i can use larger pieces of text. If i change the data type from varchar to text, create a new record and display it, the body shows empty. When i look into phpmyadmin i can see the actual data.

My question, how do i show data of the type ‘text’?

ty?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 20.2006 — never heard of such a problem, text data type is outputted in the same manner, at least for me ?! weird

so, your $entry->name contains something, but, $entry->body is empty?
Copy linkTweet thisAlerts:
@jvanhalderenauthorMar 20.2006 — Exactly, tho the database itself does contain the data, it wont display this way.

Could it be that i still have other records that use VARCHAR type for that field?
Copy linkTweet thisAlerts:
@NogDogMar 20.2006 — Might be worth doing a [b]print_r($entry)[/b] after the query to see what data was/wasn't retrieved, in case that provides any enlightening information.
×

Success!

Help @jvanhalderen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...