Wrox Programmer Forums
|
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2010, 07:55 AM
Registered User
 
Join Date: Oct 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why izn't the image showing?

I'm on chapter 7 and the file iz check_image.php. The image won't show.
I realised that there's an error in check_image-rev01.php because the code is
PHP Code:
<strong><?php echo $image_name?></strong>
(line 64) whereas it should be
PHP Code:
$image_caption 
.

I only edited check_image-rev01.php by changing the image folder path.

Here's the code:

PHP Code:
<?php
require('../includez/config.php');

//make variables available
$image_caption $_POST['image_caption'];
$image_username $_POST['image_username'];
$image_tempname $_FILES['image_filename']['name'];
$today date("Y-m-d");

//upload image and check for image type
//make sure to change your path to match your images directory
$ImageDir ="c:/wamp/www/Beginning PHP5, Apache, MySQL Web Development/chapter 07/images";
$ImageName $ImageDir $image_tempname;

if (
move_uploaded_file($_FILES['image_filename']['tmp_name'], 
                       
$ImageName)) {

  
//get info about the image being uploaded
  
list($width$height$type$attr) = getimagesize($ImageName);

  switch (
$type) {
    case 
1:
      
$ext ".gif";
      break;
    case 
2:
      
$ext ".jpg";
      break;
    case 
3:
      
$ext ".png";
      break;
    default:
      echo 
"Sorry, but the file you uploaded was not a GIF, JPG, or " .
           
"PNG file.<br>";
      echo 
"Please hit your browser's 'back' button and try again.";
  }

   
//insert info into image table

  
$insert "INSERT INTO images
            (image_caption, image_username, image_date)
            VALUES
            ('
$image_caption', '$image_username', '$today')";
  
$insertresults mysql_query($insert)
    or die(
mysql_error());

  
$lastpicid mysql_insert_id();

  
$newfilename $ImageDir $lastpicid $ext;

  
rename($ImageName$newfilename);

}

?>

<html>
<head>
<title>Here is your pic!</title>
</head>
<body>
<h1>So how does it feel to be famous?</h1><br><br>
<p>Here is the picture you just uploaded to our servers:</p>
<img src="images/<?php echo $lastpicid $ext?>" align="left">
<strong><?php echo $image_name?></strong><br>
This image is a <?php echo $ext?> image.<br>
It is <?php echo $width?> pixels wide 
and <?php echo $height?> pixels high.<br>
It was uploaded on <?php echo $today?>.
</body>
</html>
Please help.
 
Old December 22nd, 2010, 09:35 AM
Registered User
 
Join Date: Oct 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

figured it out!

Had to add a forward slash at the end of $ImageDir.

Itz alwayz in the detailz!

I'll remember that!





Similar Threads
Thread Thread Starter Forum Replies Last Post
RatingDisplay image not showing iguta BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 February 3rd, 2009 06:27 PM
Pie chart image is not showing pandujanam Crystal Reports 0 October 15th, 2008 06:26 AM
Image is not showing .. when handling themes. manoj.aggarwal ASP.NET 2.0 Professional 0 August 7th, 2007 03:22 AM
showing an image till a page gets loaded harshaghanta ASP.NET 2.0 Basics 0 May 10th, 2006 01:37 PM
Showing menu over flash image arnabghosh Classic ASP Basics 1 June 14th, 2005 08:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.