im trying to get a data from database into a text field:

$fothersq=("SELECT others FROM january");
$fothers=mysql_query($fothersq);

<input type="text" placeholder="0" name="febothers" size="11" value="<?php if(@$fothers){echo htmlentities(@$fothers);} ?>">

but i got this error in the text field instead.

<br /><b>Warning</b>:  htmlentities() expects parameter 1 to be string, resource given in <b>C:\xampp\htdocs\CashFlow\febprev.php</b> on line <b>116</b><br />

also in another text field i use this coding just to test:

<input type="text" name="febbonus" size="11" placeholder="0" value="<?php if(@$fbonus){echo (@$fbonus);} ?>">

and i got this error:

Resource id #7

any ideas?

After:

$fothers = mysql_query($fothersq);

There should be:

$row = mysql_fetch_array($fothers);

and then use $row instead of $fothers

i added what u suggested :

$fothersq=("SELECT others FROM january");
$fothers=mysql_query($fothersq);
$row=mysql_fetch_array($fothers);

<input type="text" placeholder="0" name="febothers" size="11" value="<?php if(@$row){echo htmlentities(@$row);} ?>">

i got this error:

<br /><b>Warning</b>:  htmlentities() expects parameter 1 to be string, array given in <b>C:\xampp\htdocs\CashFlow\febprev.php</b> on line <b>117</b><br />
<input type="text" placeholder="0" name="febothers" size="11" value="<?php if(@$row){echo htmlentities(@$row['others']);} 

oh.. right. hehe thank you so much! you've been helping me alot thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.