Jump to content

[SOLVED] Deleting Rows from mysql


jaybeeb

Recommended Posts

Hey : Try sumit like this.

 

<?php 
                    // other script stuff

if($_GET['User_ID']) 
{
            $User_ID = $_GET['User_Id'];
            $sql = ""DELETE FROM itsupport WHERE User_ID='{$User_ID}'";  
            mysql_query($sql) or die('error');
		echo " deleted";
} 




<?php
mysql_connect("localhost", "root", "") or die ("Could not connect");
mysql_select_db("itsupport") or die ("Could not connect to DB");
if ($_GET['User_ID']) {
echo $_GET['User_ID'];

    $User_ID = $_GET['User_ID'];
    $query = "DELETE FROM itsupport WHERE User_ID='$User_ID'"; // define the query string
    mysql_query(query) or die(mysql_error());
echo "DELETE FROM itsupport WHERE User_ID='$User_ID'"; 
echo "The Row Number $User_ID has been Successfully Removed";
}
?>

Hey : Try sumit like this.

 

<?php 
                    // other script stuff

if($_GET['User_ID']) 
{
            $User_ID = $_GET['User_Id'];
            $sql = ""DELETE FROM itsupport WHERE User_ID='{$User_ID}'";  
            mysql_query($sql) or die('error');
		echo " deleted";
} 



 

I used a small d in ID try with a uppercase D see if makes a diff

You are STILL saying mysql_query(query) instead of mysql_query($query) like 2 different people have suggested.

 

Do this and see what happens.

<?php
mysql_connect("localhost", "root", "") or die ("Could not connect");
mysql_select_db("itsupport") or die ("Could not connect to DB");
if (isset($_GET['User_ID'])) {
    //echo $_GET['User_ID']."<br />";
    $User_ID = $_GET['User_ID'];
    $query = "DELETE FROM `itsupport` WHERE `User_ID`='$User_ID'"; // define the query string
    //echo $query."<br />";
    $result = mysql_query($query) or die (mysql_error());
    if (mysql_affected_rows($result))
    {
        echo "The Row Number $User_ID has been Successfully Removed.";
    }
    else
    {
        echo "No rows affected."
    }
}
else
{
    echo "User_ID is not set to anything.";
}
?>

Yes I forgot a ; there wasn't an extra } though.

 

And if you're going to post an error message, you need to post the code that is giving it and show what line the error message is referencing.

 

Because I have no idea what code you're using at this point. I assume it's the code I posted, but it could be some variation that you changed.

Got this working , code I ended up using was very similar to my update. Just posting for people who search this in the future. Thanks everybody for your help

 

<?php
require_once 'library/db.php';




if (!($conn = mysql_connect('localhost', 'root', '')))
{
	showError();
}

if (!(mysql_select_db('itsupport', $conn)))
{
	showError();
}

$a = $_GET['id'];

$query=mysql_query("delete FROM itsupport WHERE User_ID='$a'", $conn);
if ($query)
echo "The record was successfully deleted. <br><br>";
else
echo "Failed to delete the record <br><br>";



mysql_close($conn);
include 'currentissues.php';

?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.