gpt4 book ai didi

php - 为什么我的img不显示?

转载 作者:行者123 更新时间:2023-11-27 22:36:58 24 4
gpt4 key购买 nike

如果这一切都与 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。

关于php - 为什么我的img不显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13373891/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com