2012-11-14 3 views
2

이 모든 것이 html로 작업해야합니다. 다음 html5로 만들기 시도하고 일부 내 첫 번째 CSS 코드를 코딩 해요. 지금 당장 달려 들고있는 유일한 이유는 내 이미지가 보이지 않는 이유입니다. Google 크롬 btw를 사용하고 있습니다. URL에 전달 된 코드는 다음과 같습니다. "? fname = raichu & yesorno = true % 2F"생성 된 HTML에는 이미지 태그가 없습니다./if 문이 false와 같다고 가정합니다.내 img가 왜 보이지 않습니까?

<!DOCTYPE HTML> 
<html> 
<head> 

<style type="text/css"> 

td{ 
    text-align: center; 
    padding:15px; 
    background-color:black; 
    color:#00FF00;} 

th{ 
    background-color:black; 
    color:yellow} 

</style> 

     <title>Search Results</title> 

</head> 

    <body style="color:#FFFFFF"> 

<?php 

$dbhost = 'server'; 
$dbname = 'database1'; 
$dbuser = 'me'; 
$dbpass = 'password'; 

$link = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname); 

mysqli_select_db($link,$dbname); 

$naame = $_GET["fname"]; 


if($_GET["yesorno"] == 'true' OR !$_GET["yesorno"]) 
      {$query = sprintf("SELECT image_url, Type 
           FROM Pokemon c 
           WHERE c.name='%s'", mysqli_real_escape_string($link,$naame)); 

    $result = mysqli_fetch_assoc(mysqli_query($link,$query)); 

    echo '<img height="450" width="330" src="'.$result['image_url'].'" alt="blue"/>';} 

$res = mysqli_query($link,"SELECT Name,HP,Type,Pokedex_Number AS 'Pokedex Number',Weakness,Resistance,Retreat AS 'Retreat Cost' 
          FROM Pokemon 
          WHERE Pokedex_Number!=0 AND name='$naame'"); 

if (!$res) { 
    die("Query to show fields from table failed");} 

    $fields_num = mysqli_num_fields($res); 

echo "<h1>Stats</h1>"; 
echo "<table border='1'><tr>"; 

// printing table headers 
for($i=0; $i<$fields_num; $i++) 
{$field = mysqli_fetch_field($res); 
echo "<th>{$field->name}</th>";} 

echo "</tr>\n"; 

// printing table rows 
while($row = mysqli_fetch_row($res)) 
{ 
echo "<tr>"; 

// $row is array... foreach(..) puts every element 
// of $row to $cell variable 
foreach($row as $cell) 
    echo "<td>$cell</td>"; 

echo "</tr>\n"; 
} 

echo "</table>"; 

mysqli_close($link); 

    ?> 

<br /> 
<form method="link" 
action = "http://engr.oregonstate.edu/~bainro/welcome.php" ><input 
type="submit" value="(>O.O)>RETURN<(O.O<)"></form> 
<p></p> 

    </body> 

</html> 
+1

생성 된 HTML – case1352

+0

게시 할 수 있습니다 image_url 값을 붙여 넣을 수 있습니까? – GBD

+0

올바른 주소를 전달 하시겠습니까? – Sibu

답변

2

'% 2F'는 슬래시이기 때문에 URL에서 검색하는 변수는 true로 평가되지 않습니다. 코드를 확인하십시오.

2

당신은 % 2 층 슬래시 그대로

&yesorno=true%2F 

따라서 $ _GET은 [ 'yesorno'] '/ 진정한'로 동일시 할 것이다있다. 이미지를 얻을 수 없기 때문 라인은 실패 -

if($_GET["yesorno"] == 'true' OR !$_GET["yesorno"]) 

그래서 당신이 맞아요 일치하지 않습니다.

해결 방법 : % 2F을 쿼리에서 제거하십시오.

+1

그게 효과가! Robbie에게 감사합니다! –

관련 문제