It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Code not running all the way through

Moderator: Malcolm

Code not running all the way through

Postby dflynn on Mon Apr 06, 2009 8:39 pm

Hey there,
so here's my code:
Code: Select all
<?php
echo "Removing: " . $_ GET['delete'] ."".$_ GET['type'] "<br />";
echo "Located: " . $_ GET['path'] . "<br /><br />";

   $delete = $_ GET['delete'];
   $type = $_ GET['type'];
   $path = $_ GET['path'];
   echo "Removing content from media database...<br />";
   $sql = "DELETE FROM media WHERE name='$delete' AND type='$type'" ;
   if($result= mysql_query($sql)){
   return unlink($path);
   echo "Image removed from server...<br />";
   echo "The File: " . $delete . " has been successfully removed";   
   }
   
   
   #return unlink($path);
   echo "Image removed from server...<br />";
   echo "The File: " . $delete . " has been successfully removed";

?>


It gets to echoing out "Removing content from media database..."
and it does remove it like it is supposed to. It removes the database entry and the image from the server.
But it stops there and doesn't echo out the confirmation at the end.
Any ideas as to why that happens?

Thanks.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Code not running all the way through

Postby rangana on Wed Apr 08, 2009 6:48 am

...it's because you are ending the script when you add the "return" keyword.

Try to remove it and see what happens.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Code not running all the way through

Postby Suffer on Wed Apr 08, 2009 7:06 am

i agree with rangana.
Suffer
100+ Club
 
Posts: 236
Joined: Tue Jan 20, 2009 6:34 am

Re: Code not running all the way through

Postby dflynn on Wed Apr 08, 2009 1:57 pm

Works fine now.
Thanks guys :D
I didn't realize return stops the code. I guess I should have looked that one up.
Ohwell, now I know.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada


Who is online

Users browsing this forum: No registered users and 1 guest