오류가 문제가 정확히 무엇을 말하고있다 :
Warning: htmlentities() expects parameter 1 to be string, resource given in C:\xampp\htdocs\CashFlow\febprev.php on line 116
그리고이 : 이러한 오류의
Resource id #7
둘은 mysql_query
가 리소스를 반환 함을 말하고있다. 이 시점에서는 문자열이 아닙니다. 해당 리소스 &을 처리하려면 이 필요합니다. 이 시도.
$fothersq=("SELECT others FROM january");
$fothers=mysql_query($fothersq);
while ($row = mysql_fetch_assoc($fothers)) {
echo sprintf('<input type="text" placeholder="0" name="febothers" size="11" value="%s">', (!empty($row['others'] ? htmlentities($row['others']) : '')));
}
또한 제시 한 코드가 바로 PHP 또는 HTML 또는 두 가지의 혼합으로 거의 의미가 있기 때문에 내가 echo
에 <input type="text">
HTML 요소를 배치 있습니다.
편집 :
$fothersq=("SELECT others FROM january");
$result=mysql_query($fothersq);
while ($row = mysql_fetch_assoc($result)) {
$fothers = '';
if (!empty($row['others']) {
$fothers = htmlentities($row['others']);
}
echo '<input type="text" placeholder="0" name="febothers" size="11" value="' . $fothers . '">';
}
: 원래 포스터가 삼항 연산자에 의해 혼동 될 수 있다는 의견을 바탕으로, 여기에 있지만 약간 간단한 방법으로, 같은 목표를 달성 할 내 대답의 수정 된 버전입니다
하십시오 [RTFM을'mysql_query' 위해 (http://php.net/mysql_query)과 그 예. – deceze
'@'기호를 사용하지 않는 것이 좋습니다. 그것은 당신을 이미 혼란스럽게합니다. –