Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Macnimation #1
Deleting a Record using PHP and MySQL with DreamweaverMX 2004
Hi,
I've followed along with the tutorial on Deleting a Record using PHP and MYSQL
:
[url]http://www.macromedia.com/support/dreamweaver/building/users_delete_rcrds_php/[/url]
and it works fine but..
I'm stumped with the result.
When the list in the dynamic table appears, they all have the Delete column
attached as expected.
Rolling over each Delete link shows correctly the ID file in the link script
at the bottom of the page, but no matter what Delete link I click, it always
returns the First record that has ID=1
When I open the page that has the table containing the file that is to be
confirmed, called confirmdelete.php, for deletion I see the following code at
the top of the page:
<?php require_once('../Connections/conn.php'); ?>
<?php
$colname_rsdeleteDetails = "1";
if (isset($_GET['recordID'])) {
$colname_rsdeleteDetails = (get_magic_quotes_gpc()) ? $_GET['recordID'] :
addslashes($_GET['recordID']);
}
I have deduced that the script $colname_rsdeleteDetails = "1"; is calling
the ID number that is assignd to the delete button.
No matter what delete link I choose, the value is always "1" which is calling
the first record.
If I change it manually to "2" or whatever, and then refresh the page then it
will show the matching record correctly.
I have gone through this over and over and I have followed the tutorial
exactly which seems very logical and straight forward and very clear, but I
cannot figure out why it always calls the first record.
Can anyone please shed some light on this?
cheers
Macnimation Guest
-
Odd Contribute 3 + DreamweaverMX 2004 Error
Ok here is the error / bug / problem that I can reproduce at will. I have a template that includes a library item. The library item has a... -
deleting DNS record using dnscmd.exe
Hello, I want to delete a record "comwebcam.yahoo" from the zone "com" When typing - dnscmd localhost /recorddelete com comwebcam.yahoo A I... -
Deleting a Record.
Thanks for the Help on the other problems...all resolved. One last (hopefullly) problem I can't seem to get around for this program...why isn't... -
Deleting curent record
Hi all, can anyone tell me how to delete just the current record if tempdate >= todaydate then Set newMail=Server.CreateObject("CDONTS.newMail")... -
deleting access database record
I am trying to write an asp page to delete a record from my access database. I have written the page to display the info but when I select the entry... -
rickvv1 #2
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
If you're setting up a confirmation page, you will need to set up the "pick for
deletion" page to send a variable (picked up by the delet button behavior), and
also set up the confirmation recordset to "catch" that variable. In the
$colname section of your RS, play with:
$HTTP_GET_VARS['**whatever_your_code_is**']
As you have it now, your confirmation page is set to pick up a static
RecordID, and only shows variable '1'. You may need to use the 'Advanced'
button in your Create RecordSet dialog, if your query is more complex. But read
through that tutorial again. carefully. Your answer is in there (took me a few
run throughs, before I got it)
Good Luck,
rick
[url]http://www.macromedia.com/support/dreamweaver/building/users_delete_rcrds_php/us[/url]
ers_delete_rcrds_php10.html
rickvv1 Guest
-
Macnimation #3
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
Hi,
Thanks for the reply but I still cannot see it:, sorry.
Below is the rs code I use according to the tutorial.
Complete code for the Confirmation Page is:
$colname_rsdeleteDetails = '1';
if (isset($_GET['recordID'])) {
$colname_rsdeleteDetails = (get_magic_quotes_gpc()) ? $_GET['recordID'] :
addslashes($_GET['recordID']);
}
$colname_rsdeleteDetails = "1";
if (isset($_GET['id'])) {
$colname_rsdeleteDetails = (get_magic_quotes_gpc()) ? $_GET['id'] :
addslashes($_GET['id']);
}
mysql_select_db($database_conn, $conn);
$query_rsdeleteDetails = sprintf("SELECT id, Surname, FirstName FROM members
WHERE id = %s", $colname_rsdeleteDetails);
$rsdeleteDetails = mysql_query($query_rsdeleteDetails, $conn) or
die(mysql_error());
$row_rsdeleteDetails = mysql_fetch_assoc($rsdeleteDetails);
$totalRows_rsdeleteDetails = mysql_num_rows($rsdeleteDetails);
The Complete code for the Delete button is:
confirmdelete.php?recordID<?php echo $row_rsdeletemember['id']; ?>
I have the confirmation page to only show the First Name and Surname of the
Record.
But it filters via the Hidden Field dynamically linked to the "id" field of
the recordset
Do you see anything amiss here?
I cannot see where to put the line you recommended:
$HTTP_GET_VARS['**whatever_your_code_is**']
It's probably looking at me, but I'm a bit lost now.
cheers
Macnimation Guest
-
rickvv1 #4
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
This is a little unscientific, but when you view your "pick to delete" page,
and you hover over different 'delete' buttons, does the ID change as you roll?
If not, there's something in your code that isn't sending a variable, rather
it's sending the static code to the confirmation page (in your case , you keep
seeing the hard-coded 1 or 2, depending.
Someone will prbably pop in with the obvious, here...but I'm almost sure that
the error is in the confirmation (or 'result') page.
When I have a page where I'm sending a variable, as in: "list celebrity names
that are EQUAL to 'x', the dynamic code I use looks something like this on the
confirmation page
$colname_rsCelebResult = "1";
if (isset($HTTP_GET_VARS['celeb'])) {
$colname_rsCelebResult = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['celeb']
: addslashes($HTTP_GET_VARS['celeb']);
}
And the tutorial deals with this code on page 11, I think:
[url]http://www.macromedia.com/support/dreamweaver/building/users_delete_rcrds_php/us[/url]
ers_delete_rcrds_php11.html
Don't give up - i wish I could be more helpful.
rick
rickvv1 Guest
-
Macnimation #5
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
Thanks again for the quick reply.
Yes, it's strange, when I roll over the Delete link, the ID does change as I
roll over it correctly.
I'll keep at it, there must be something I'm not seeing here.
cheers again,
I'll let you know if i figure itout.
Macnimation Guest
-
rickvv1 #6
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
OK, macnimation,
Compare the following carefully. You're trying to get a variable called
RecordID, and I'm trying to get a variable called 'celeb'
These are the URL Parameters.
Yours:
if (isset($_GET['recordID'])) {
$colname_rsdeleteDetails = (get_magic_quotes_gpc()) ? $_GET['recordID'] :
addslashes($_GET['recordID']);
}
Mine:
if (isset($HTTP_GET_VARS['celeb'])) {
$colname_rsSearch = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['celeb'] :
addslashes($HTTP_GET_VARS['celeb']);
}
You're dong a $_GET['code']
I'm doing a $HTTP_GET_VARS['code']
You need to have a default value in the colname ($colname_rsdeleteDetails =
'1';), and we both have the nmeral '1'.
But, your $_GET statement is sending that '1', where you need to $HTTP_GET
(and send to the Confirmation page) your _VARiable
And you must be sure taht the Confirmation page is written to have a matching
$HTTP_GET_VARS code to display the variable (that comes from your DeleteMember
page) in your dynamic table on confirmDelete.
Look into and read about URL parameters. And consider that the tutorial might
have left something out. (Maybe not)
Read the page at:
[url]http://www.macromedia.com/support/dreamweaver/building/users_delete_rcrds_php/us[/url]
ers_delete_rcrds_php05.html
and be sure that your URL parameters are the same. Look at your code on
ConfirmationPage..."RecordID" is not the same as "id", and your Confirmation
page has two(2) $_GET statements - not sure why.
Get some rest, something to eat, and look through your work again.
I think you'll have an Aha moment very soon.
rick
rickvv1 Guest
-
Macnimation #7
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
Hi,
I had the AAAHH moment at the weekend but I'm not sure wht I did but it's
working now.
I noticed that when I roled over the Delete link, the value changed to
recordID1, or recordID2, which I thought was correct.
But I noticed that it should be reading recordID=1 or recordID=2 etc.
So I took another look at the Delete link:
confirmdelete.php?recordID<?php echo $row_rsdeletemember['id']; ?>
And found the = sign was missing after recordID, so it should have been:
confirmdelete.php?recordID=<?php echo $row_rsdeletemember['id']; ?>
Once changed, it all came together and worked perfectly.
Stupid stupid mistake, but after several beers it showed itself.
I think I can portion some of the blame to you for not picking it up
though............: o }
Thanks for the help and patience, this was a case of not seeing the woods
because the trees were in the way!
Thanks again.
Macnimation Guest
-
rickvv1 #8
Re: Deleting a Record using PHP and MySQL withDreamweaver MX 2004
Hmm, OK - I'll take a wee bit o' blame, but missing something like this is
usually because the use has been too close to the code for too long, and
everyting starts to look correct.
Also be very careful to make sure that the cAsE is CorREct.
And I'll bet if you poke around your Details Page, and your Confirmation page,
you'll find the "$HTTP_GET_VARS" business that I've been ranting about.
In any case, glad it showed up :)
Now, go forth and have fun
(here's a very excellent site for more PHP tips, tricks & tutorials
[url]http://www.phpfreaks.com/[/url]
But hang around here for a while at macromedia, too.
Have a good week,
Rick
rickvv1 Guest



Reply With Quote

