473,769 Members | 3,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delete Script

Hi everyone,

I appreciate all of your help with me and the problems I have been
having. I'm new to PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement works when I insert hard values in it. Any thoughts would be
greatly appreciated. Thanks in advance.

<form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>">
<table>

<tr><td colspan="2" align="center"> Yes <?php
input_radiochec k('radio','yes_ no', $defaults, 'yes'); ?No <?php
input_radiochec k('radio','yes_ no', $defaults, 'no'); ?>
</td></tr>

<tr><td colspan="2" align="center"> <?php input_submit('s ave','Add'); ?>
</td></tr>

</table>
<input type="hidden" name="_submit_c heck" value="1"/>
</form>

<?php

function process_form() {

// Access the global variable $db inside this function
global $db;

$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];

if ($_POST['yes_no'] == 'yes') {

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
\'$artist_name\ ' AND album_title = \'$album_title\ '";
// Delete the record
$db->query($delete_ sql);
print "The record was deleted";
} else {
print "The record was not deleted";
}
}

?>

Aug 11 '06 #1
17 1755
mp*****@gmail.c om wrote:
Hi everyone,

I appreciate all of your help with me and the problems I have been
having. I'm new to PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement works when I insert hard values in it. Any thoughts would be
greatly appreciated. Thanks in advance.
<form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>">
$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];
The form method is POST, then
$_GET['isbn']=$_GET['artist_name']=$_GET['album_title']=NULL
use $_POST['isbn'], $_POST['artist_name'] and $_POST['album_title'].

You can simplify your form tag, action="" is the same as calling itself, less
code and less work for PHP if you use:

<form method="POST" action="">

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
\'$artist_name\ ' AND album_title = \'$album_title\ '";
$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
'$artist_name' AND album_title = '$album_title'" ;

Remember that the column isbn has to be INT.

//Aho
Aug 11 '06 #2

J.O. Aho wrote:
mp*****@gmail.c om wrote:
Hi everyone,

I appreciate all of your help with me and the problems I have been
having. I'm new to PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement works when I insert hard values in it. Any thoughts would be
greatly appreciated. Thanks in advance.

<form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>">
$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];

The form method is POST, then
$_GET['isbn']=$_GET['artist_name']=$_GET['album_title']=NULL
use $_POST['isbn'], $_POST['artist_name'] and $_POST['album_title'].

You can simplify your form tag, action="" is the same as calling itself, less
code and less work for PHP if you use:

<form method="POST" action="">

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
\'$artist_name\ ' AND album_title = \'$album_title\ '";

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
'$artist_name' AND album_title = '$album_title'" ;

Remember that the column isbn has to be INT.

//Aho
Thanks! I should have mentioned that the following is required because
they are being pulled form the url
http://www.domain.com/delete_record....&album_title=:
$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];
I shouldn't use $_POST should I?

Thanks!

Aug 11 '06 #3
mpar612 wrote:
Thanks! I should have mentioned that the following is required because
they are being pulled form the url
http://www.domain.com/delete_record....&album_title=:
When looking at your example you don't provide this data at all and to make
things a lot easier I would include them into the form as hidden input-tags.
Things gets a lot easier if you keep on sending data in the same way and not
try to mix.
//Aho
Aug 11 '06 #4

J.O. Aho wrote:
mpar612 wrote:
Thanks! I should have mentioned that the following is required because
they are being pulled form the url
http://www.domain.com/delete_record....&album_title=:

When looking at your example you don't provide this data at all and to make
things a lot easier I would include them into the form as hidden input-tags.
Things gets a lot easier if you keep on sending data in the same way and not
try to mix.
//Aho
Thanks! Could you please elaborate a little bit more, I'm a beginner
and I don't really understand what you are saying. I don't see how I
am trying to mix the way that I am sending data.

Thanks!

Aug 12 '06 #5
mpar612 wrote:
J.O. Aho wrote:
>mpar612 wrote:
>>Thanks! I should have mentioned that the following is required because
they are being pulled form the url
http://www.domain.com/delete_record....&album_title=:
When looking at your example you don't provide this data at all and to make
things a lot easier I would include them into the form as hidden input-tags.
Things gets a lot easier if you keep on sending data in the same way and not
try to mix.
//Aho

Thanks! Could you please elaborate a little bit more, I'm a beginner
and I don't really understand what you are saying. I don't see how I
am trying to mix the way that I am sending data.

Thanks!
You claim you are trying to use data sent as POST and GET at the same time,
thats a try in mixing, in your example you don't send anything that could be
fetched with $_GET.
--- send all as post ---
<form method="POST" action="">
<table>

<tr><td colspan="2" align="center"> Yes <?php
input_radiochec k('radio','yes_ no', $defaults, 'yes'); ?No <?php
input_radiochec k('radio','yes_ no', $defaults, 'no'); ?>
</td></tr>

<tr><td colspan="2" align="center"> <?php input_submit('s ave','Add'); ?>
</td></tr>

</table>
<input type="hidden" name="isbn" value="<?PHP echo $isbn; ?>" />
<input type="hidden" name="artist_na me" value="<?PHP echo $artist_name; ?>" />
<input type="hidden" name="album_tit le" value="<?PHP echo $album_title; ?>" />
<input type="hidden" name="_submit_c heck" value="1"/>
</form>
--- end of example ---

There you get all the data you needed to send, all sent as post.
//Aho
Aug 12 '06 #6
You need to start paying people here buddy. Or just give up on PHP SQL!!!
<mp*****@gmail. comwrote in message
news:11******** **************@ 74g2000cwt.goog legroups.com...
Hi everyone,

I appreciate all of your help with me and the problems I have been
having. I'm new to PHP and MySQL and I'm having some problems getting
this script to work. I can't get this to work and I don't understand
why. I don't get an error or anything, it almost seems like the page
refreshes. I went to the phpmyadmin and the row is still in the
database. The $_GET parts work perfectly in another script and the SQL
statement works when I insert hard values in it. Any thoughts would be
greatly appreciated. Thanks in advance.

<form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>">
<table>

<tr><td colspan="2" align="center"> Yes <?php
input_radiochec k('radio','yes_ no', $defaults, 'yes'); ?No <?php
input_radiochec k('radio','yes_ no', $defaults, 'no'); ?>
</td></tr>

<tr><td colspan="2" align="center"> <?php input_submit('s ave','Add'); ?>
</td></tr>

</table>
<input type="hidden" name="_submit_c heck" value="1"/>
</form>

<?php

function process_form() {

// Access the global variable $db inside this function
global $db;

$isbn = $_GET['isbn'];
$artist_name = $_GET['artist_name'];
$album_title = $_GET['album_title'];

if ($_POST['yes_no'] == 'yes') {

$delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name =
\'$artist_name\ ' AND album_title = \'$album_title\ '";
// Delete the record
$db->query($delete_ sql);
print "The record was deleted";
} else {
print "The record was not deleted";
}
}

?>

Aug 12 '06 #7
Webwasp wrote:
You need to start paying people here buddy. Or just give up on PHP SQL!!!
These are forums and responses are voluntary. If you don't want to
respond, then don't. Responding with comments like yours is not only
unnecessary, but also a waste of resources and everyone's time.

Aug 12 '06 #8
Webwasp schrieb:
You need to start paying people here buddy. Or just give up on PHP SQL!!!
Before teaching people how to behave in usenet you might want to learn
it yourself:
http://www.google.com/search?q=top-posting
http://www.google.com/search?q=netiquette

--
Markus
Aug 13 '06 #9

"Markus Ernst" <derernst@NO#SP #AMgmx.chwrote in message
news:44******** **@news.cyberci ty.ch...
Webwasp schrieb:
>You need to start paying people here buddy. Or just give up on PHP SQL!!!

Before teaching people how to behave in usenet you might want to learn it
yourself:
I agree. The original question was so basic that it was obvious that the
writer had done no homework and didn't even know SQL. However, Markus'
reply was somewhat over the top. A simple, "You need to learn the basics of
SQL first. It is common to all relational databases. Google 'SQL tutorial'
online or pick up a book." would have been much more polite.

Shelly
Aug 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
13276
by: Raj | last post by:
Hi all, Can anyone help me with a script which would delete files or move them to a different folder at some scheduled time..! Please.....!!! Thanks in advance...
3
14059
by: Asif Rahman | last post by:
Hi all! Please improve on the following code to make sure the record gets deleted only when the function returns false. Now I see the msgbox, but the record gets deleted no matter the user clicks yes or no. Thanks in advance. Asif =======================
4
3032
by: DrData | last post by:
I'm working on an ASP.Net application written in C#. On one page, there are several datagrid controls used to display, edit and delete detail records relating to the master record also displayed on that page. Each row in each datagrid includes a Delete button (added at runtime by the code-behind page as a ButtonColumn) and an Edit button (added at runtime by the code-behind page as an EditCommandColumn). What is the quickest, easiest and...
0
2688
by: Elton W | last post by:
Hi Peter, You use DeleteButton.Attributes.Add("onclick", "return confirm ('Are you sure you want to delete?');"); in datagrid_ItemDataBound event to add confirmation for delete button.
3
2102
by: John Rivers | last post by:
Hello, I think this will apply to alot of web applications: users want the ability to delete a record in table x this record is related to records in other tables and those to others in other tables etc. in other words we must use cascade delete to do
5
3112
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove the row. The Delete method marks the row as Deleted in the DataSet or DataTable but does not remove it. Instead when the DataAdapter encounters a row marked as Deleted, it executes its DeleteCommand method to delete the row at the data source. The...
3
3426
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. Filename : search_student.php <?php include("../user_access/user_access_control.php"); include("../Database/database.php"); $searchStudentControl = new Access_user;
5
2520
by: paitoon | last post by:
I have a DHTML confirm box that i will use to confirm delete the information from my page which are from database.... this is the script </script> <script type="text/javascript"> function verify(ver){ if(ver){ // Confirmed message, i.e. clicked on "Yes" alert('Message confirmed'); }else{
2
19754
by: Francesco Pietra | last post by:
Please, how to adapt the following script (to delete blank lines) to delete lines containing a specific word, or words? f=open("output.pdb", "r") for line in f: line=line.rstrip() if line: print line f.close()
29
5344
by: shivasusan | last post by:
Hi! I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks the delete button selected row wants to delete. My problem is(If i delete the first row, its say undefined and change the value is 0) pls check my program. <%pathdefiner = "../"%> <!--#include file="../connection/connector.asp" -->...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.