PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Problems with Delete Row Function

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> MySQL General
View previous topic :: View next topic  
Author Message
rewynd



Joined: 09 Feb 2008
Posts: 1

PostPosted: Sat Feb 09, 2008 10:59 pm    Post subject: Problems with Delete Row Function Reply with quote

<?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 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
Back to top
View user's profile Send private message
lostboy



Joined: 02 May 2004
Posts: 5128
Location: toronto, canada

PostPosted: Wed Feb 13, 2008 3:50 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



Post new topic   Reply to topic    WeberForums.com Forum Index -> MySQL General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum






Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum