Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Software > Adobe Software > Dreamweaver

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-2008, 03:14 AM
RL Joneson
 
Posts: n/a
PHP Delete Record Issue

I've set up a simple database for adding event news to a site. I'm pretty new
to PHP, but I have the Insert, Update, and Display pages working properly.
However the Delete Record page is being a big pain. I have it set up just as it
explains in Dreamweaver Help, as well as a tutorial i am using as a backbone
for this project. Its a form with a hidden filed that is dynamically pulling my
ID. I have the Delete behavior pointing at the same ID and record set.

My Delete link is properly setting up a dynamic page with the title of record
to be deleted showing up just fine. Also, the redirect page is correct after
hitting the Delete button. Which makes me believe the issue is happening in
somewhere in the behavior. None of my records are being deleted when I go back
to the Display page. They are still there. Im pointing the behavior at my
Primary record so im not sure what's going on. I'm a first-timer to this. Any
help would be much appreciated.

Here is my code:


<?php require_once('Connections/connPRHevents.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
"NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

if ((isset($_POST['DateID'])) && ($_POST['DateID'] != "")) {
$deleteSQL = sprintf("DELETE FROM events WHERE DateID=%s",
GetSQLValueString($_POST['DateID'], "int"));

mysql_select_db($database_connPRHevents, $connPRHevents);
$Result1 = mysql_query($deleteSQL, $connPRHevents) or die(mysql_error());

$deleteGoTo = "events.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}

$colname_Events = "-1";
if (isset($_GET['DateID'])) {
$colname_Events = $_GET['DateID'];
}
mysql_select_db($database_connPRHevents, $connPRHevents);
$query_Events = sprintf("SELECT * FROM events WHERE DateID = %s",
GetSQLValueString($colname_Events, "date"));
$Events = mysql_query($query_Events, $connPRHevents) or die(mysql_error());
$row_Events = mysql_fetch_assoc($Events);
$totalRows_Events = mysql_num_rows($Events);
?><html><!-- InstanceBegin template="/Templates/main.dwt"
codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Pretty Hurt</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
body {
background-color: #000000;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #666666;
}
.style3 {
font-size: 14px;
color: #333333;
font-family: Geneva, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.style5 {
font-size: 10px;
font-family: Geneva, Arial, Helvetica, sans-serif;
color: #C4047F;
}
.norepeat {
background-repeat: no-repeat;
}
.contact {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
text-decoration: none;
}
.contact a:link {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
text-decoration: none;
}
.contact a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
text-decoration: none;
}
.contact a:hover {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #999999;
text-decoration: none;
}
.contact a:active {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
text-decoration: none;
}
.style6 {font-size: 9px; font-family: Geneva, Arial, Helvetica, sans-serif;
color: #C4047F; }
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
onLoad="MM_preloadImages('images/medicgear_over.gif','images/apparel_over.gif','
images/accessories_over.gif','images/newproducts_over.gif','images/home_over.gif
','images/crutches_over.gif','images/events_over.gif','images/contact_over.gif')
">
<!-- ImageReady Slices (PHR_Site.psd) -->
<table width="900" height="920" border="0" align="center" cellpadding="0"
cellspacing="0" id="Table_01">
<tr>
<td width="187" height="239" background="images/PHR_Site_01.jpg"><img
src="images/PHR_Site_01.jpg" width="187" height="239" border="0"
usemap="#Map"></td>
<td width="616" height="239" background="images/PHR_Site_02.jpg">&nbsp;</td>
<td width="97" height="239" background="images/PHR_Site_03.jpg">&nbsp;</td>
</tr>
<tr>
<td>
<img src="images/PHR_Site_04.jpg" width="187" height="25" alt=""></td>
<td>
<img src="images/PHR_Site_05.jpg" width="616" height="25" alt=""></td>
<td>
<img src="images/PHR_Site_06.jpg" width="97" height="25" alt=""></td>
</tr>
<tr>
<td height="229" background="images/PHR_Site_07.jpg">&nbsp;</td>
<td>
<img src="images/banner.jpg" width="616" height="229" alt=""></td>
<td width="97" height="229" background="images/PHR_Site_09.jpg">&nbsp;</td>
</tr>
<tr>
<td valign="top" background="images/PHR_Site_10.jpg"
class="norepeat">&nbsp;</td>
<td height="370" align="center" valign="top" bgcolor="#FFFFFF"><table
width="616" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="33" align="center" bgcolor="#01BAEF"><a href="index.html"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Home','','images/home_over.gif',1)"><img
src="images/home.gif" alt="Home" name="Home" width="72" height="30"
border="0"></a><a href="crutches.html" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Crutches','','images/crutches_over.gif',1)"><img
src="images/crutches.gif" alt="Crutches" name="Crutches" width="101"
height="30" border="0"></a><a href="apparel.html"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Apparel','','images/apparel_over.gif',1)"><img
src="images/apparel.gif" alt="Apparel" name="Apparel" width="101" height="30"
border="0"></a><a href="accessories.html" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Accessories','','images /accessories_over.gif',1)"><im
g src="images/accessories.gif" alt="Accessories" name="Accessories" width="140"
height="30" border="0"></a>&nbsp;&nbsp;<a href="events.php"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Events','','images/events_over.gif',1)"><img
src="images/events.gif" alt="Events" name="Events" width="86" height="30"
border="0"></a><a href="forms/contact.php" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Contact','','images/contact_over.gif',1)"><img
src="images/contact.gif" alt="Contact" name="Contact" width="87" height="30"
border="0"></a>&nbsp;&nbsp;</td>
</tr>
</table>
<br>
<br>
<!-- InstanceBeginEditable name="EditRegion3" -->
<table width="550" height="86" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><p><?php echo $row_Events['Title']; ?></p>
<form name="form1" method="post" action="events_delete.php">
<p>
<input type="submit" name="button" id="button" value="Delete">
<input name="DateID" type="hidden" id="DateID" value="<?php echo
$row_Events['DateID']; ?>">
</p>
</form> <p>&nbsp;</p></td>
</tr>
</table>
<!-- InstanceEndEditable --><br>
<table width="600" height="18" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="18"><!-- InstanceBeginEditable name="EditRegion4"
-->&nbsp;<!-- InstanceEndEditable --></td>
</tr>
</table>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>
<img src="images/PHR_Site_13.gif" width="187" height="25" alt=""></td>
<td width="616" align="center" valign="top"
background="images/PHR_Site_14.gif" class="style6">Pretty Hurt.
Northern/Southern California. 949-355-4607. <a href="policy.html">Privacy
Policy</a> | <a href="forms/support.php">Support</a></td>
<td>
<img src="images/PHR_Sit
Reply With Quote
  #2 (permalink)  
Old 08-23-2008, 08:06 PM
SaigonJeff
 
Posts: n/a
Re: PHP Delete Record Issue

Hi

I was reading your post and realized that I had the same troubles the first
time I tried to setup a record deletion page.

I hope the following helps.

What I ended up doing was to set up 3 pages..
1) a user list page of all users in the users table
2) a confirmation page to show user info
3) a delete page which does the actual deletion

This first page was a simple repeat region table showing the entire list of
users in the database table. I linked the username to the conformation page
with a simple URL Parameter to isolate the user I want to delete

Here is the code

<a href="admin_users_delconfirm.php?id=<?php echo $row_rsUsers['id']; ?>

The on the confirmation page I have a delete button graphic which is linked to
the delete page in the same way.

Code:
<a href="admin_users_delete.php?id=<?php echo $row_rsUsers['id']; ?>

Finally on the delete page I applied the" delete record" server behaiviour so
that the deletion is done when the page loads. You can also have it redirect
back to the master list of users when the deletion is done.

It may seem a little redundant to have 3 pages, but the purpose of the 2nd
page is to give the user an opportunity to change their mind and also to remind
them that the delete action cannot be undone.

I hope this helps you.

Good Luck and Good Coding!


Reply With Quote
  #3 (permalink)  
Old 08-31-2008, 04:43 AM
submit@zuka.net
 
Posts: n/a
Re: PHP Delete Record Issue

On Aug 23, 3:06 pm, "SaigonJeff" <webforumsu...@macromedia.com> wrote:
> Hi
>
> I was reading your post and realized that I had the same troubles the first
> time I tried to setup a record deletion page.
>
> I hope the following helps.
>
> What I ended up doing was to set up 3 pages..
> 1) a user list page of all users in the users table
> 2) a confirmation page to show user info
> 3) a delete page which does the actual deletion
>
> This first page was a simple repeat region table showing the entire list of
> users in the database table. I linked the username to the conformation page
> with a simple URL Parameter to isolate the user I want to delete
>
> Here is the code
>
> <a href="admin_users_delconfirm.php?id=<?php echo $row_rsUsers['id']; ?>
>
> The on the confirmation page I have a delete button graphic which is linked to
> the delete page in the same way.
>
> Code:
> <a href="admin_users_delete.php?id=<?php echo $row_rsUsers['id']; ?>
>
> Finally on the delete page I applied the" delete record" server behaiviour so
> that the deletion is done when the page loads. You can also have it redirect
> back to the master list of users when the deletion is done.
>
> It may seem a little redundant to have 3 pages, but the purpose of the 2nd
> page is to give the user an opportunity to change their mind and also to remind
> them that the delete action cannot be undone.
>
> I hope this helps you.
>
> Good Luck and Good Coding!


Hi,

Sorry to just barge in here but I am having a bit of an issue with
this same scenario. I have it all working but have run in to an issue
where the page will not re-direct to the userlist.php (original list
of users) because the header info has already been sent by the time
the delete page is reached. The code that is causing this issue is the
redirect code i.e. header(sprintf("Location: %s", $deleteGoTo)); Just
wondering if youu have experienced this type of problem and if so,
perhaps you can share your experience with it in how you solved it. It
seems trivial but it is very frustrating.

Here is the php error I am getting:

[30-Aug-2008 20:51:20] PHP Warning: Cannot modify header information
- headers already sent in /usr/web/home/fsmgroup.zuka.net/docs/site/
admin/delete.php on line 44


thanks for any help.

Dave
Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Software > Adobe Software > Dreamweaver


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 06:38 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Remortgages | Loans | Loans | Gas Suppliers | JJ Benitez



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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114