SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict stu567blue's Avatar
    Join Date
    Aug 2007
    Posts
    316
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete from MYSQL

    Hi All

    I'm having a spot of bother with a delete statement, it works, as in there are no errors, but there is something wrong as it won't delete the record in the MYSQL database, shown below is the form:

    HTML Code:
    		<form action=co_delete.php method=post/>
    				<input name=photo_id type=text value=" .  $pid['photo_id'] . ">
    				<input type=submit name=delete value=Delete />
    					</form>
    $pid is the assigned variable for dealing with the file id

    PHP Code:
    <?php 
    // Get the configuration data
        
    $connect = require_once('../Connections/ilikeyours.php'); 
            
        
        
    //Connect to mysql server
        
    $link mysql_connect($hostname_ilikeyours$username_ilikeyours$password_ilikeyours);
        if(!
    $link) {
            die(
    'Failed to connect to server: ' mysql_error());
        }
        
        
    //Select database
        
    $db mysql_select_db($database_ilikeyours);
        if(!
    $db) {
            die(
    "Unable to select database");
        }    
        
        
    $pid $_POST['photo_id'];
        
    $remove_pic = ("DELETE FROM gallery_photos WHERE photo_id = '$pid'");
    mysql_query($remove_pic) or die(mysql_error());

    echo 
    "Picture Deleted

            <a href=co_recentpics.php> Click here</a> to go back to the pictures"
    ;
    ?>
    As already mention this does not work for some reason any ideas?

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure that $pid has expected value in your query? Did you try to echo the query and run it outside php like in phpmyadmin or any mysql clients? BTW what is the error message?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •