Jump to content

Recommended Posts

Ok strange one.  I have an image upload script.  It works fine and the image uploads and puts its name in my database.  I also then post the name to the next page.  Here is the image uploader

<?php
if (isset($_POST['insert_image']))
{
$folder = "../../images/image_box/";
move_uploaded_file($_FILES["photo"]["tmp_name"] , "$folder".$_FILES["photo"]["name"]) or die(mysql_error());
//connect to database
include('../../Connections/database.php'); 
$photo = $_FILES["photo"]["name"];

$qInsert = "INSERT INTO `photos` 
(`photo_name`)
	VALUES                    
	('".$photo."')";
			$rInsert = mysql_query($qInsert) or die(mysql_error()); 
//Tells you if its all ok 
if ($rInsert) {
$url = "add_image_to_album.php?image_name='".$photo."'" or die(mysql_error());        
header("Location: ".$url.""); 
}
else {
$errors = "There was an error inserting the image into the database";
}
}
?>

Notice I then post the image name  to the next page.

 

Now on the next page I have only this

<?php include('../../Connections/database.php'); 
session_start();?>
   <?php echo '".$_GET['image_name']."' ;?>

 

But there is an error at line one but I have tested the connection and its fine so its erroring displaying for example;

 

landscape.png

 

Does it have something to do with the .png in the name? If so how do i solve this?

Link to comment
https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/
Share on other sites

Dunno, but you have several errors.

 

$url = "add_image_to_album.php?image_name='".$photo."'" or die(mysql_error());        
header("Location: ".$url.""); 

 

Should be:

 

$url = "add_image_to_album.php?image_name=$photo";
header("Location: $url");
exit; 

cool that has changed but still nothing echo's in the really annoyingly simple statement

 

Sorry, forgot the third error (why are you putting all kinds of quotes all over the place?):

 

 <?php echo '".$_GET['image_name']."' ;?>

 

Should be:

 

 <?php echo $_GET['image_name'];?>

here the new link and still no echo of the image_name

 

http://www.website.co.uk/manage/gallery/add_image_to_album.php?image_name=events.png

 

I'm just escaping the php so I can see my code correctly with putting those quotes in.  I have never had it effect anything else before

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.