簡體   English   中英

為什么我的img不顯示?

[英]Why won't my img show?

讓這一切都與 html 一起工作。 然后我試着把它變成 html5,我正在編寫我的第一個 css 代碼。 我現在唯一要解決的問題是為什么我的圖像不顯示? 順便說一句,我正在使用谷歌瀏覽器。 在 url 中傳遞的代碼是這樣的:“?fname=raichu&yesorno=true%2F”而且我生成的 html 中沒有圖像標簽:/我假設 if 語句等於 false??

<!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>

你有

&yesorno=true%2F

因此 $_GET['yesorno'] 將等同於 'true/' 因為 %2f 是一個正斜杠。

這不匹配

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

所以你是對的 - 那條線失敗了,所以你不會得到圖像。

解決方案:從查詢中刪除 %2F。

您從 url 檢索的變量永遠不會評估為真,因為 '%2F' 是一個正斜杠。 檢查您的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM