2014-09-02 2 views
0

PHP 스크립트에서 데이터를 표시하는 데 사용되는 mysql 데이터베이스가 있습니다 ... 문제는 임의적으로 발생하여 결과가 누락 된 것으로 보이고 패턴을 볼 수 없습니다. 왜 그 일을하고 있는지 확증 할 수 있습니다 ...mysql 데이터베이스에서 데이터가 누락되었습니다

데이터베이스를 점검 할 때 모든 데이터가 정상적으로 보입니다. 여기

내 결과 페이지 내 초기 검색 페이지

<?php 
include 'connect.php'; 

//set variable 
$option = ''; 

// Get the county names from database - no duplicates - Order A-Z 
$query = "SELECT DISTINCT tradingCounty FROM offers ORDER BY tradingCounty ASC"; 

// execute the query, $result will hold all of the Counties in an array 
$result = mysqli_query($con,$query); 


while($row = mysqli_fetch_array($result)) { 
    $option .="<option>" . $row['tradingCounty'] . "</option>"; 
} 




echo "<html xmlns='http://www.w3.org/1999/xhtml'>"; 
echo "<title>HSB - Latest Offers</title>"; 
echo "<style type='text/css'>; 
body { 
    background-color: #FFF; 
} 
#wrapper { 
    background-color: #FFF; 
    height: auto; 
    width: 1000px; 
    margin-right: auto; 
    margin-left: auto; 
    font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif; 
} 
</style> 
</head> 

<body> 
<div id='wrapper'> 
    <p><img src='images/header.jpg' width='400' height='100' alt='header' /></p> 
    <HR/> 
    Select an area from the menu below to view any offers in that area. 
    <form id='filter' name='filter' method='post' action='resultssimple.php'> 
     <p><label>County</label></p> 
     <select name='result' id='result'>' . $option . '</select> 
     <input name='' type='submit' /> 
     </form> 
</div> 
</body> 
</html>"; 



?> 

이며, 여기

<? 
include 'connect.php'; 

//Get the details from previous page 
$SelectedCounty = $_POST["result"]; 

// Select offers linked to selected county from form 
$result = mysqli_query($con,"SELECT * FROM offers WHERE tradingCounty ='" . $SelectedCounty . "'ORDER BY categoryIdName ASC;"); 

// PREVIOUS ATTEMPTS - ALL WRONG - GGGGRRRRRRRRRRRR !!!!!!!! 
//------------------------------------------------------------ 
//$result = mysqli_query($con,"SELECT * FROM offers WHERE tradingCounty LIKE" . $SelectedCounty); 
//$result = mysql_query("SELECT * FROM pdetails WHERE uid='" . $inputname . "';"); 
//"SELECT * FROM `offers` WHERE `tradingCounty` LIKE 
//$result = mysqli_query($con,"SELECT * FROM offers;"); 
//$result = mysql_query("SELECT * FROM pdetails WHERE uid='" . $inputname . "';"); 
//$result = mysqli_query("SELECT * FROM offers WHERE tradingCounty=" . $SelectedCounty); 


//check to see if results is set - error if not. 
if(!$result) 
{ 
    die("<p>Error in listing tables: ". mysql_error()."</p>"); 
} 

//Show all records for selected county 
echo ("<p><h2>Showing Latest Offers In : " . $SelectedCounty . "</h2></p>"); 
echo ("<p><a href='offers.php' target='_self'>back to search menu</a></p>"); 

/* 
echo ("<table border='1'>"); 
echo ("<tr>"); 
echo ("<td>ID</td><td>Category</td><td>Business Name</td><td>Business Address</td><td>Address2</td><td>Address3</td><td>Town</td><td>County</td><td>Post Code</td><td>Telephone</td><td>URL</td><td>Email</td><td>Discount/Special Offer</td><td>valid from</td>"); 
*/ 

while($row = mysqli_fetch_row($result)) 
{ 
    echo ("<div style=' background-color: #EFF5FF; color: #06C; padding: 5px; float: left; border: 1px dotted #06C; margin: 10px; width: 300px; height: 300px; text-align: center; >"); 
    // echo ("" . $row[0] . ""); 
    // echo ("</br>"); 
    echo ("<strong>" . $row[1] . "</strong>"); 
    echo ("<hr/>"); 
    // echo ("</br>"); 
    echo ("" . $row[2] . ""); 
    echo ("</br>"); 
    echo ("" . $row[3] . ""); 
    echo ("</br>"); 
    // echo ("" . $row[4] . ""); 
    // echo ("</br>"); 
    // echo ("" . $row[5] . ""); 
    // echo ("</br>"); 
    echo ("" . $row[6] . ""); 
    echo ("</br>"); 
    echo ("" . $row[7] . ""); 
    echo ("</br>"); 
    echo ("" . $row[8] . ""); 
    echo ("</br>"); 
    echo ("" . $row[9] . ""); 
    echo ("</br>"); 
    // echo ("" . $row[10] . ""); 
    // echo ("</br>"); 
    echo ("" . $row[11] . ""); 
    echo ("</br>"); 
    echo ("<hr/>"); 
    echo ("<strong>" . $row[12] . "</strong>"); 
    echo ("</br>"); 
    echo ("</div>"); 

/* echo("<tr>"); 
    echo("<td>" . $row[0] . "</td>" . "<td>" . $row[1] . "</td>" . "<td>" . $row[2] . "</td>" . "<td>" . $row[3] . "</td>" . "<td>" . $row[4] . "</td>" . "<td>" . $row[5] . "</td>" . "<td>" . $row[6] . "</td>" . "<td>" . $row[7] . "</td>" . "<td>" . $row[8] . "</td>" . "<td>" . $row[9] . "</td>" . "<td>" . $row[10] . "</td>" . "<td>" . $row[11] . "</td>" . "<td>" . $row[12] . "</td>" . "<td>" . $row[13] . "</td>"); 
    echo("</tr>"); 
*/ 
} 
// echo("</table>"); 
?> 

나는 어쩌면 그들이 그들이 누락

+0

조금 명확합니다 ... 어떤 결과가 비즈니스 유형, 회사 이름 및 – sturobinson81

+0

그냥 여기 하찮은 일에 속 태우고 주소의 일부를 누락,하지만 모든'SELECT' 문에서 나는 당신이 명시 적으로 할 열 이름을 추천합니다 'SELECT * ... '를 사용하는 것과 반대로 선택하십시오. – kevin628

+0

:) Kevin이 언급했습니다 ... 아마추어/내 관점에서 선택 *이 더 빨랐다 고 생각합니다. 그리고 난 단지 내가 보여주고 싶지 않았던 라인을 주석 처리해야했습니다 ... – sturobinson81

답변

0

here를 보거나 할 수 있습니다 얻고 무엇을 이스케이프 처리되지 않은 html 문자로 가려집니다. 브라우저의 소스보기 옵션을 확인하여 브라우저가 실제로 있는지 확인하십시오. 특히 HTML보다 낮은 문자와 같은 데이터의 문자는 브라우저에서 HTML 문자를 잘못 입력 한 것으로 보입니다.

브라우저가 렌더링을 시도하지 않습니다 그래서 당신은 당신의 출력을 탈출해야 할 수 있습니다

: 또한

echo ("" . htmlspecialchars($row[2]) . ""); 

을 당신이 사용자로부터 직접 입력을하지 제안 및 탈출하지 않고 SQL 쿼리에 넣어 것입니다, 먼저. 당신은 SQL Injection 공격을 위해 스스로를 개방하고 있습니다.

은 다음을 참조하십시오

http://php.net/manual/en/mysqli.real-escape-string.php

+0

안녕하세요, WDS, SQL 주입을 드롭 다운 메뉴에서 수행 할 수 있습니까? 미안 해요 예쁜 PHP에 새로운. – sturobinson81

+0

나는 출처를 보았으며 누락 된 세부 사항이 있습니다 ... 왜 그런 일이 일어 났습니까? – sturobinson81

+0

브라우저에서 HTML 문자로 보았 기 때문일 수 있습니다. 그들은 <> 문자를 포함합니까? –

0

가 도움이 있을지 모르겠지만이 줄 :

$result = mysqli_query($con,"SELECT * FROM offers WHERE tradingCounty ='" . $SelectedCounty . "'ORDER BY categoryIdName ASC;"); 

보이는 당신이 여분의 세미콜론 (가지고있는 것처럼;) 마지막 큰 따옴표 바로 앞에. 나는 거기에 있어야한다고 생각하지 않는다.

또한 배열에 반환 된 모든 내용을 저장할 수 있으며 반환되는 내용을 확인하기 위해 반복 할 때마다 모든 내용을 표시 할 수 있습니다. 그런 다음 누락 된 것이 있으면 데이터베이스로 이동하여 해당 행을 살펴보십시오.

$tempArray = array(); 
while($row = mysqli_fetch_row($result)) { 
    $tempArray = $row; 
} 

foreach($tempArray as $value) { 
    echo $value . '<br>'; 
} 
관련 문제