deleting a record from a database

This is a discussion on "deleting a record from a database" within the Databases section. This forum, and the thread "deleting a record from a database are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 13th, 2006, 14:03
Junior Member
Join Date: Feb 2006
Location: West Yorks, UK
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Question deleting a record from a database

My database is coming on leaps and bounds. Now I'm trying to delete a record from it, but what seems to be happening is the record is being blanked, but not deleted. This is the script I have:

PHP: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
   "http://www.w3.org/TR/html4/loose.dtd"> 
<html
    <head> 
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> 
        <meta name="generator" content="Taco HTML Edit"> 
        <link rel="stylesheet" href="styles.css" type="text/css"> 
        <title>Amir&rsquo;s Contacts Database ~ Record Updated</title> 
    </head> 
    <body> 
        <h1>Amir&rsquo;s Contacts Database</h1> 
        <h2>Record Updated</h2> 
<? 
$id
=$_POST['id']; 

$user="user"
$password="password"
$database="database"

mysql_connect(localhost,$user,$password); 
@
mysql_select_db($database) or die( "Unable to select database"); 

$query="DELETE FROM contacts WHERE id='$id'"
mysql_query($query); 
mysql_close(); 
?> 
        <br> 
        <a href="list.php">list</a> 
    </body> 
</html>
Reply With Quote

  #2 (permalink)  
Old Feb 13th, 2006, 16:03
Junior Member
Join Date: Feb 2006
Age: 40
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Re: deleting a record from a database

I just used your code on a different database and table (obviously) and it worked fine. Personally I keep my database details on a separate file and call it on a require_once(), that way you only need to change one page when your database details change. You could even set up a class to connect.
Reply With Quote
  #3 (permalink)  
Old Feb 13th, 2006, 21:43
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Re: deleting a record from a database

I think you mean when you click on the table in phpmyadmin that is meant to be deleted the table needs optimizing?
Reply With Quote
Reply

Tags
deleting, record, database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] display a image record from a database with a set size longstand PHP Forum 8 Oct 19th, 2007 19:18
Add/Delete/Modify Database Record form David Blake Starting Out 6 May 1st, 2007 16:22
display first only part of a database record. Daddyohhh99 Other Programming Languages 0 Feb 3rd, 2006 14:49
newbie simple create database to record web page input jfb130 Databases 3 Aug 28th, 2005 16:37
display the number of record exist in the database Monie Databases 1 Aug 24th, 2004 08:10


All times are GMT. The time now is 05:11.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43