0

okay so i am doing a program that lets you type a name of a friend in and submit and it will display a picture of that friend but my output wont show the picture, it will have some type of error.

if you look at the picture attached that's my output, i don't know what kind of error to call it.

let me know if you need to see code or not.

Attachments output.jpg 56.78 KB
2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Atli
0

Hey.

What is the actual URL of the image (not) being shown there?
Is it what you would expect it to be?

Could you explain exactly how you are displaying the image, and where the image is coming from?
It would also help to see the code for this.

P.S.
http://getfirefox.com
Designing a web-page in IE is like trying to draw with you good arm tied behind your back.

Edited by Atli: n/a

0

well im using img src

than i have a switch to print it,

i expect to see the pic come up but it doesnt.

PHP code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Your Output</title>
</head>
<body>
<div style = "text-align: center">
<?php
//retrieve all the variables

friend_function();



function friend_function(){
	$friends = filter_input(INPUT_POST, "friends");
$noel = <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/noel.jpg">
HERE;
$josh= <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/josh.jpg">
HERE;
$kris = <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/kris.jpg">
HERE;
$sam = <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/sam.jpg">
HERE;
$pete = <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/pete.jpg">
HERE;
$sherri = <<<HERE
<img scr = "http://131.118.95.214/users/jmdrenning0/images/sherri.jpg">
HERE;
	switch ($friends){
		case 'noel':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $noel;
				print "<br/><font size=5>Noel</font>";
			break;
		case 'josh':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $josh;
				print "<br/><font size=5>Josh</font>";
			break;
		case 'kris':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $kris;
				print "<br/><font size=5>Kris</font>";
			break;
		case 'sam':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $sam;
				print "<br/><font size=5>Sam</font>";
			break;
		case 'pete':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $pete;
				print "<br/><font size=5>Pete</font>";
			break;
		case 'sherri':
				print "<br/><font size=5>Here is this friend</font><br/>";
				print $sherri;
				print "<br/><font size=5>Sherri</font>";
			break;
		default:
			print "<font size=5>You have enter the name in wrong,<br/> Try again.</font>";

	}
}



?>
</div>

</body>
</html>

html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Friend Program</title>
<style type = "text/css">
h1, h2, h3 {
text-align:center;
}
textarea, button {
   display: block;
   margin-left: auto;
   margin-right: auto;
   margin-bottom: lem;
}

table {
  margin-left: auto;
  margin-right: auto
  }

</style>
</head>
<body>

<h1>Friend Program</h1>

<form method = "post" 
	action = "friend.php">
<fieldset>
<h3>
<select name = "friends">
	<option value = "noel">Noel</option>
	<option value = "josh">Josh</option>
	<option value = "kris">Kris</option>
	<option value = "sam">Sam</option>
	<option value = "pete">Pete</option>
	<option value = "sherri">Sherri</option>
</select>

<button type = "submit">
 See my friend
</button>
</h3>
</fieldset>


</form>

</body>
</html>
0

Ahh ok.

The problem is that <img scr ... should be <img src ... .
A spelling error ;-]

I have to say, tho. You have a lot of redundant code there. Repeating the same HTML over and over.

You could/should have PHP do all the heavy lifting :-)

<!DOCTYPE html>
<html>
<head>
    <title>Your Output</title>
</head>
<body>
    <div style="text-align: center">
    <br/><font size=5>Here is this friend</font><br/>
    <?php
    // Create a list of allowed names
    $allowedFriends = array('noel', 'kris', 'sam', 'pete', 'sherri');

    // Get the friend name.
    $friendName = trim($_POST['friends']);

    // Check if the name is allowed
    if(!in_array($friendName, $allowedFriends))
    {
        // Name not allowed.
        echo "Invalid friend name.";
    }
    else
    {
        // Name is allowed. Print the image.
        $friendNameUpper = ucfirst($friendName);
        echo <<<HTML
<img src="http://131.118.95.214/users/jmdrenning0/images/{$friendName}.jpg" alt="Image not found" />
<br/><font size=5>{$friendNameUpper}</font>
HTML;
    }
    ?>
    </div>

</body>
</html>

Edited by Atli: Minor alteration to the code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.