Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 22nd, 2010, 06: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.
Reply With Quote
  #2 (permalink)  
Old December 22nd, 2010, 08: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!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 05: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



All times are GMT -4. The time now is 02:18 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.