fife Posted January 20, 2011 Share Posted January 20, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/ Share on other sites More sharing options...
AbraCadaver Posted January 20, 2011 Share Posted January 20, 2011 What is the error and what do you expect to be displayed? Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162642 Share on other sites More sharing options...
fife Posted January 20, 2011 Author Share Posted January 20, 2011 no sorry i explained that wrong. There is no error here is what the link looks like....... http://www.website.co.uk/manage/gallery/add_image_to_album.php?image_name='landscapes.png' Im asking it to echo the image_name but it echos nothing Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162645 Share on other sites More sharing options...
fife Posted January 20, 2011 Author Share Posted January 20, 2011 http://www.website.uk/manage/gallery/add_image_to_album.php?image_name='landscapes.png' Im asking it to echo image_name but nothing is displayed Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162646 Share on other sites More sharing options...
Maq Posted January 20, 2011 Share Posted January 20, 2011 EDIT: Sorry read the post wrong. EDIT2: Don't put single quotes around the image_name value in the url. Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162647 Share on other sites More sharing options...
xjasonx Posted January 20, 2011 Share Posted January 20, 2011 Why is their single quotes in the url? Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162648 Share on other sites More sharing options...
fife Posted January 20, 2011 Author Share Posted January 20, 2011 what do you mean I don,t understand. I don,t want to display the image. Just the name Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162649 Share on other sites More sharing options...
AbraCadaver Posted January 20, 2011 Share Posted January 20, 2011 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; Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162650 Share on other sites More sharing options...
fife Posted January 20, 2011 Author Share Posted January 20, 2011 cool that has changed but still nothing echo's in the really annoyingly simple statement Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162651 Share on other sites More sharing options...
AbraCadaver Posted January 20, 2011 Share Posted January 20, 2011 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'];?> Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162653 Share on other sites More sharing options...
fife Posted January 20, 2011 Author Share Posted January 20, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162654 Share on other sites More sharing options...
AbraCadaver Posted January 20, 2011 Share Posted January 20, 2011 Well crap, sorry I was on a conference call and only half thinking. Try this: $url = "add_image_to_album.php?image_name=" . urlencode($photo); Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162655 Share on other sites More sharing options...
parino_esquilado Posted January 20, 2011 Share Posted January 20, 2011 $qInsert = "INSERT INTO `photos` (`photo_name`) VALUES ('".$photo."')"; $qInsert = "INSERT INTO photos (photo_name) VALUES ('$photo')"; That probably won't fix it, but the way you wrote it annoyed me lol Quote Link to comment https://forums.phpfreaks.com/topic/225101-how-does-this-not-work/#findComment-1162663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.