Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member ThePhoenix2006's Avatar
    Join Date
    Mar 2005
    Location
    Michigan
    Posts
    88
    Member #
    9431
    OK, heres my dealio. First off I am still new to this PHP stuff so I know what needs to be done but am unable to make it work for me.

    I need to get the information $song_url from la_song into this code. Then "unlink()" the file using the $song_url.

    Heres my code:

    PHP Code:
    <?php

    // check if id is set

    if (isset($_GET['song_id'])) {
        
    $song_id $_GET['song_id'];
    }
    else { 
        
    $song_id 0;
        exit;}

    // now we have the id, lets get the image name

    define("IN_LOCALAMP",true);
    $root_path "./";

    require(
    $root_path.'includes/common.php');

    // now delete
        
        
    $delete "DELETE FROM la_song WHERE song_id='$song_id' LIMIT 1";
        
    $res mysql_query($delete) or die(mysql_error());
        if (
    mysql_affected_rows() > 0) {
            echo 
    "Successfully Deleted";
        }
        else {
            echo 
    "query failed - " $delete;
            }

    ?>
    Can anyone help me with this?

    Thanks!
    "Make sure the juice is worth the squeeze" ~The Girl Next Door

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    the [minicode]exit;[/minicode] shouldn't be needed.

    did you write this code or did someone else? Is la_song a database? If so, do you know the structure of the database? If so, could you post it? FYI, none of that code has anything to do with song_url.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yeah, this code isn't deleting any files...

  5. #4
    Member ThePhoenix2006's Avatar
    Join Date
    Mar 2005
    Location
    Michigan
    Posts
    88
    Member #
    9431
    I know its not deleting any files. As of right now all it does is remove the entry in the database, making the file they uploaded dead in the water and taking up disk space. Someone else wrote this code but I am just not sure on how to place the unlink() function in it. Song_url is a column name under la_song (which is a table under my database) The database is called member_directory.

    Hope this helps.
    "Make sure the juice is worth the squeeze" ~The Girl Next Door

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You want to select the column from the database, and then call unlink on the resulting string, right?

  7. #6
    Member ThePhoenix2006's Avatar
    Join Date
    Mar 2005
    Location
    Michigan
    Posts
    88
    Member #
    9431
    Quote Originally Posted by Shadowfiend
    You want to select the column from the database, and then call unlink on the resulting string, right?
    Yes, column "song_url".

    Can you help me out on that?

    Thanks!
    "Make sure the juice is worth the squeeze" ~The Girl Next Door

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, nabbing the column should be fairly easy. The query you will need is:
    Code:
    SELECT song_url FROM la_song WHERE song_id = $song_id LIMIT 1
    Then you can use [minicode]mysql_fetch_assoc[/minicode] to grab it.

    Once you've done that, say in the database you have `myFile.html' and your PHP file is `/php/magic.php' but the file is in `/files/myFile.html', you can simply do a:
    PHP Code:
    unlink'../files/' $song_url ); 
    Assuming you've extracted the song url into the $song_url variable.

    Does that make sense? I know I didn't write all the code for you, but I find that makes for better learning :-)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:29 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com