为什么我的图片不显示?

时间:2012-11-14 06:10:46

标签: php sql css html5

这一切都与html一起使用。然后我尝试将它变成html5,然后我编写了一些我的第一个css代码。我现在唯一要处理的是为什么我的图像不显示?我正在使用Google Chrome btw。在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>

2 个答案:

答案 0 :(得分:2)

你有

&yesorno=true%2F

因此$ _GET ['yesorno']将等同于'true /',因为%2f是正斜杠。

这与

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

所以你是对的 - 那条线路失败了所以你不会得到图像。

解决方案:从查询中删除%2F。

答案 1 :(得分:1)

您从网址检索的变量永远不会评估为true,因为'%2F'是正斜杠。检查你的代码。