현재 항목에 specefic ID (EventCode)가 저장된 데이터베이스가 있습니다. 고유 한 ID로 내 웹 사이트에 표시하려고하면 모두 엉망입니다. 일부 항목은 정상이며 A, B, C 및 D가 올바르게 표시됩니다. 다른 일부 항목은 다른 이벤트의 동일한 A, B, C 및 D를 표시합니다. 각 항목의 EventCode를 보면, 그것은 다른 코드입니다 ... 아래의 코드와 관련하여, 제 문제는 무엇입니까? 왜 어떤 제품은 그들이 쇼인 것으로 보이는 것을 완벽하게 보여 주며, 다른 제품은 알레시가 만든 제품과 동일한 것을 보여줍니까? $EventCode
이 고유하지 않으면 당신은 당신의 결과 집합 반복하지 않을 때문에특정 ID가있는 MySQL 항목 복구
<?php
include('base.php');
?>
<?php
if(isset($_GET['EventCode']))
{
$EventCode = intval($_GET['EventCode']);
$dn = mysql_query("select A, B, C, D from users_event where EventCode=$EventCode ");
if(mysql_num_rows($dn)>0)
{
$dnn = mysql_fetch_array($dn);
?>
This is the profile of "<?php echo htmlentities($dnn['A']); ?>" :
<table style="width:500px;">
<tr>
<td><?php
if($dnn['B']!='')
{
echo '<img src="'.htmlentities($dnn['B']).'" alt="B" style="max-width:100px;max-height:100px;" />';
}
else
{
echo 'B is not existing.';
}
?>
</td>
<td class="left"><h1><?php echo htmlentities($dnn['C']); ?></h1>
Field: <?php echo htmlentities($dnn['D']); ?><br />
</tr>
</table>
<?php
}
else
{
echo 'Sorry, no record found.';
}
}
else
{
echo 'No item found';
}
?>
</body>
</html>
mysql_ * ._을 멀리하십시오. http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php –
http://yoursite.com?EventCode=1;CREATE%20TABLE%0sql_injection(yes%20INT) - – Sammitch
@sammit : 작동하지 않습니다. '(intval)'은 값을 단지 int로 강제 할 것이다. 하지만 그렇지 않으면 주입 취약점이있을 수 있습니다. –