HI, im trying to make a delete page so, my mom , can delete all her photos or old new of her website as easy as a click, the problem it aint working !

im using this query

<?
include("connection.inc");

$bye=$_GET['id'];


$sql = "DELETE FROM photos WHERE code=$bye";

$result = mysql_query($sql);

echo "DELETED!";

?>

Thanks for your time

    YOur code is in need of some enhancements:

    <?
    include("connection.inc");

    $bye=$_GET['id'];
    /
    echo errors, maybe your connection is not good, wrong db, etc.
    /

    $sql = "DELETE FROM photos WHERE code=$bye";
    $result = mysql_query($sql) or die(mysql_error() . ' for sql query: '.$sql);
    if($x=mysql_affected_rows($result)){
    echo "$x photo(s) deleted";
    }else{
    //means that nothing matched $bye..
    }

    ?>

      Does it output any errors? Make sure that the user you're using to connect to the database has DELETE rights.

      Also, unless your server has this specifically sent up to prevent, the file connection.inc will be displayed as a plaintext file if someone tries to view it. To prevent this from happening (and reading whatever is inside the file, presumably a username and password), you should name the file connection.inc.php, so that it gets run through the php parser.

        thanks so much guys, i got it to work with this query

        DELETE FROM photos WHERE CONVERT(code USING utf8) = '$bye' LIMIT 1;

        it couldnt be possible with out the errors out put ! ! THANKS ! ! 😃

          Write a Reply...