It is currently Sat Feb 04, 2012 3:47 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problems with Delete Row Function
PostPosted: Sat Feb 09, 2008 11:59 pm 
Offline

Joined: Sat Feb 09, 2008 11:57 pm
Posts: 1
<?php /* Created on: 2/9/2008 */

//the code starts here

// we then will connect to the database as the user specified
mysql_connect("$nil","$nil","$nil")
// now if we cannot connect to the database then this message will be displayed followed by the error message
or die ('I cannot connect to the database because: ' . mysql_error());

// here we are choosing which database we really want to edit. For us this database happens to be "sqlslave"
mysql_select_db("sqlslave")
// if it doesn't select the database the connection will die
or die(mysql_error());
//If cmd has not been initialized
if(!isset($cmd))
{

// get all committee names from the database
$result = MYSQL_QUERY("select * from COMMITTEE order by Committee");
while ($row = mysql_fetch_array($result))
{
// grabbing the title of the committee names
$title = $row['Committee'];
$committee = $row['Committee'];
//make the title a link
echo "<a rel="nofollow" href='delete.php?cmd=delete&$tablename=$committee'>$title - Delete</a>";
echo "<br>";
}
}
?>

<?
if($_GET['cmd']=="delete")
{
$dbh=mysql_connect ("$nil", "$nil", "$nil")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sqlslave");
// delete table
$sql = "DELETE FROM COMMITTEE WHERE Committee=$committee LIMIT 1";
mysql_query($sql,$dbh);
echo "The committee has been deleted.";
}
?>

-------------------------------------------------------------------------------------
Okay so my problem here is that everything is showing properly up to the display but when I click one of the links meant to delete the row from the table it refuses to delete the row, yet the end echo still shows that it was deleted. Upon hitting the back button in my browser and logging into the DB the row that was supposed to be deleted is still there.
Someone please help!!! =)
thanks a bunch,

P.S- Please note that $nil is just a variable that was used to edit out my host/user/pw

Thank you all very much in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 13, 2008 4:50 am 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6498
Location: toronto, canada
have you echoed out the queries for the delete and any errors to see if there is problem with any code?

_________________
Lostboy

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron