Deleting records - mySQL / PHP

I've just worked through this whole database thing from
scratch again after a little glitch, and it's all working pretty
well.
I do still have the issue with deleting records - I have the
search results page which is fine, and has a delete options at the
end of the row.
It was working just fine bringing up the 'confirm deletion'
page with the selected record - but it goes wrong after I add the
'delete record' server behaviour.
Basically after I do, when I click delete in the results
page, it skips the 'confirm deletion' page, going straight to the
'deletion confirmed' page.
It does still delete the record at least, but it would be
good to have the confirmation page.
Here's a
link
(if you need to log in use 'admin' and 'password'.)
This is all the script code in the 'confirm delete' page :
<?php require_once('../Connections/ConnHandprint.php');
?>
<?php
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
$theValue = (!get_magic_quotes_gpc()) ?
addslashes($theValue) : $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($_GET['recordID'])) && ($_GET['recordID']
!= "")) {
$deleteSQL = sprintf("DELETE FROM Contacts WHERE
ContactID=%s",
GetSQLValueString($_GET['recordID'], "int"));
mysql_select_db($database_ConnHandprint, $ConnHandprint);
$Result1 = mysql_query($deleteSQL, $ConnHandprint) or
die(mysql_error());
$deleteGoTo = "contactdeleted.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $deleteGoTo));
$colname_Recordset1 = "1";
if (isset($_GET['recordID'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ?
$_GET['recordID'] : addslashes($_GET['recordID']);
mysql_select_db($database_ConnHandprint, $ConnHandprint);
$query_Recordset1 = sprintf("SELECT * FROM Contacts WHERE
ContactID = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $ConnHandprint)
or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Any ideas?
Cheers,
Iain

Hi,
It is a good idea to do it in database level such that declare foreign key from child to parent table and specify DELETE CASCADE.
regards,
'

Similar Messages

  • Delete record behaviour (PHP/mySQL)

    I've just worked through this whole database thing from
    scratch again after a little glitch, and it's all working pretty
    well.
    I do still have the issue with deleting records - I have the
    search results page which is fine, and has a delete options at the
    end of the row.
    It was working just fine bringing up the 'confirm deletion'
    page with the selected record - but it goes wrong after I add the
    'delete record' server behaviour.
    Basically after I do, when I click delete in the results
    page, it skips the 'confirm deletion' page, going straight to the
    'deletion confirmed' page. It's as tho' simply going to the
    confirmation page is triggering the deletion, rather than requiring
    the 'delete record' button to be pressed. Does the form / button
    require an 'action'? Although as far as I can tell I followed the
    instructions
    correctly, but something is going wrong on the confirmation page.
    It does still delete the record at least, but it would be
    good to have the confirmation page.
    Here's a link (if you need to log in use 'admin' and
    'password'.)
    link
    This is all the script code in the 'confirm delete' page :
    <?php require_once('../Connections/ConnHandprint.php');
    ?>
    <?php
    function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "", $theNotDefinedValue = "")
    $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue)
    : $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($_GET['recordID'])) && ($_GET['recordID']
    != "")) {
    $deleteSQL = sprintf("DELETE FROM Contacts WHERE
    ContactID=%s",
    GetSQLValueString($_GET['recordID'], "int"));
    mysql_select_db($database_ConnHandprint, $ConnHandprint);
    $Result1 = mysql_query($deleteSQL, $ConnHandprint) or
    die(mysql_error());
    $deleteGoTo = "contactdeleted.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $deleteGoTo));
    $colname_Recordset1 = "1";
    if (isset($_GET['recordID'])) {
    $colname_Recordset1 = (get_magic_quotes_gpc()) ?
    $_GET['recordID'] : addslashes($_GET['recordID']);
    mysql_select_db($database_ConnHandprint, $ConnHandprint);
    $query_Recordset1 = sprintf("SELECT * FROM Contacts WHERE
    ContactID = %s", $colname_Recordset1);
    $Recordset1 = mysql_query($query_Recordset1, $ConnHandprint)
    or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    Any ideas?
    Cheers

    Hello,
    S. Khawar wrote:
    my question is that when I execute DELETE_RECORD built in it fails due to constraint restriction and Oracle forms raise message that "Child record exist/unable to delete record " until here it's Ok but Oracle Forms still removes record from the screen/form and move up the remaining records(although record is failed to delete).Yet this is the default forms behaviour. Because when you press delete it will remove from the screen but not from the database till you use COMMIT as francois mentioned.
    I want the Oracle Form to do not remove record from screen/form once it's failed to delete record actually.Yes, for this type of requirement. Why don't you check dependency of record before removing the record. What i mean is you can use the code in KEY-DELREC trigger like below (before using the DELETE_RECORD built-in) for checking if child record exists then show message otherwise remove. For example...
    DECLARE
      vCntRec NUMBER;
    BEGIN
      SELECT COUNT(*)
      INTO vCntRec
      FROM child_table_name
      WHERE key_column = :form_key_column_name;
      IF vCntRec>0 THEN  -- Here means record found in child table so it will not remove from screen but message will appear.
        MESSAGE('<Your error message goes here...>');
        MESSAGE('<Your error message goes here...>');
        RAISE FORM_TRIGGER_FAILURE;
      ELSE  -- Here mean there is not dependency so it will remove which is default forms behaviour.
        DELETE_RECORD;
      END IF;
    END;So, when you will press button for delete first it will check for any child record if exsits then it will display message and will not vanish from the screen otherwise it will remove from the screen and furthor COMMIT will remove from database.
    -Ammad
    Edited by: Ammad Ahmed on Jul 7, 2010 8:48 AM

  • How to insert date into updated record (MySql, PHP)

    I want to be able to update an existing record and automatically include the date the change was made when I submit the data back to the MySql database.
    I saw this thread on how to insert the date on a new record using NOW()
    http://forums.adobe.com/thread/855152?decorator=print&displayFullThread=true#855152
    After reading it I successfully amended my insert.php page.
    Here's the code from my insert.php page which works nicely:
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO standardsclient_tbl (client_name, pantone_ref1, pantone_ref1_image, font_ref1, font_ref1_image, `date`) VALUES (%s, %s, %s, %s, %s, NOW())",
                           GetSQLValueString($_POST['client_name'], "text"),
                           GetSQLValueString($_POST['pantone_ref1'], "text"),
                           GetSQLValueString($_POST['pantone_ref1_image'], "text"),
                           GetSQLValueString($_POST['font_ref1'], "text"),
                           GetSQLValueString($_POST['font_ref1_image'], "text"),
                           GetSQLValueString($_POST['date'], "date"));
    This is the update.php page, I changed `date`=%s to `date`=NOW() but all this did was stop me from updating the record at all.
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE standardsclient_tbl SET client_name=%s, pantone_ref1=%s, pantone_ref1_image=%s, font_ref1=%s, font_ref1_image=%s, `date`=NOW() WHERE client_ID=%s",
                           GetSQLValueString($_POST['client_name'], "text"),
                           GetSQLValueString($_POST['pantone_ref1'], "text"),
                           GetSQLValueString($_POST['pantone_ref1_image'], "text"),
                           GetSQLValueString($_POST['font_ref1'], "text"),
                           GetSQLValueString($_POST['font_ref1_image'], "text"),
                           GetSQLValueString($_POST['date'], "date"),
                           GetSQLValueString($_POST['client_ID'], "int"));
    Can anyone see where I've gone wrong?
    Thanks

    In update query you have 6 %s but 7 GetSQLValueString. That's your problem.

  • CS6 Dreamweaver using PHP & MySQL - Delete Record Server Behavior?

    When I try to insert the Delete Record server behavior. I get an error message about a DeleteRecord.js file, which seems to be missing or defective.  I cannot use the server behavior.  I have a file that I developed using CS5, and it does indeed delete the record, but does not proceed to the destination I want.  I cannot change that except in the server behavior, so I'm stuck.  I have noticed that server behaviors seem to disappear without apparent cause, as it seems to have in this case.  I will appreciate any suggestions!  Is there any way to embed a call to a target page manually?  All is working WITHOUT the server behavior appearing, but I want to go to a confirmation display page that shows the record is indeed deleted, and we just return to the (now blank) delete confirmation page.  That'll drive a user bonkers!
    Thanks!
    Delete Record in CS6 Dreamweaver using PHP & MySQL?

    Well, your error message is self-explanatory.
    DW stores ServerBehaviors in 'Configuration' folder in installation directory. If one of the behavior JS files is missing/ corrupt, you'll see the error message you just did.
    I've uploaded a functional, proper version of DeleteRecord.js onto my site for you to download. Here's the link:
    http://www.sudarshan.me/adobeforum/dw/app/behavior-js/DeleteRecord.zip
    Download this file, extract it and put DeleteRecord.js file in your installation directory as follows. If prompted, 'replace' your local copy:
    Mac: Applications > Adobe Dreamweaver CS6 > Configuration > ServerBehaviors > PHP_MySQL
    Windows: C:\Users\Your User Name\AppData\Roaming\Adobe\Dreamweaver CS6\[language]\Configuration\ServerBehaviors\PHP_MySQL
    It should work as expected.
    If that still doesn't solve the problem, reset your DW preferences and cache and try doing it. Follow the instructions here to reset cache: http://forums.adobe.com/thread/494811
    Let us know how it goes.
    -ST

  • 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:

    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!

  • Deleting Record from Database in PHP

    I'm trying to figure out how to delete a record from my
    database. I already have a recordset with my form selected. But
    when I try to add "Delete Record," I can never seem to figure out
    why it won't delete anything when I load the page in a browser, it
    won't even go to the page I told it to go to after it deletes a
    record. My guess is it's what I'm entering in the "Delete Record"
    part of it, any help would be great. Also, my id is primary key if
    that helps. Thanks ahead of time.

    edwin@aw wrote:
    > However, whenever I click on the hyperlink, the link
    will becomes
    >
    http://www.domain.com/www.LinkFromDatabase.com.
    Why it always append the web
    > site's address?? Do I miss something?
    This is happening because your link doesn't begin with
    http://.
    > echo "<a href='$link' target='_blank'> $link
    </a>";
    This should be echo "<a href='
    http://$link' target='_blank'> $link
    </a>";
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Inserting & uploading records with Dreamweaver CS3, MYSQL & PHP

    I'm able to build a web page that allows for images to be
    uploaded to a server folder. Also have a web page created to insert
    info about the image into a MYSQL/PHP database.
    My goal is to find a way to combine the two together so that
    when you click the submit button... 1) the image gets uploaded to
    the server folder, 2) the info about the image gets placed into the
    database table, and 3) there is an entry in the database that
    establishes the path to the image.
    Any help or direction to a tutorial would be greatly
    appreciated.

    I use a DW extension from DMXzone (Pure PHP Upload) that
    allows me to both insert data form an online form into a MySQL
    table as well as upload files to a directory on the server with one
    button click. This might be a solution for you.

  • [DW MX 2004] DELETE RECORD

    Hi,
    I can't DELETE RECORD in LOCAL SERVER (MySQL Server 5.0)
    and REMOTE SERVER , but INSERT AND UPDATE WORKS.
    Page code is
    <?php require_once('../Connections/connpuntofermo.php');
    ?>
    <?php
    session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this
    page
    function isAuthorized($strUsers, $strGroups, $UserName,
    $UserGroup) {
    // For security, start by assuming the visitor is NOT
    authorized.
    $isValid = False;
    // When a visitor has logged into this site, the Session
    variable
    MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that
    Session
    variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only
    certain
    users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    // Or, you may restrict access to only certain users based
    on their
    username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    if (($strUsers == "") && true) {
    $isValid = true;
    return $isValid;
    $MM_restrictGoTo = "index.php";
    if (!((isset($_SESSION['MM_Username'])) &&
    (isAuthorized("",$MM_authorizedUsers,
    $_SESSION['MM_Username'],
    $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING)
    > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar .
    "accesscheck=" .
    urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    ?>
    <?php
    function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "",
    $theNotDefinedValue = "")
    $theValue = (!get_magic_quotes_gpc()) ?
    addslashes($theValue) : $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($_GET['ID'])) && ($_GET['ID'] != "")) {
    $deleteSQL = sprintf("DELETE FROM news WHERE ID=%s",
    GetSQLValueString($_GET['ID'], "int"));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $Result1 = mysql_query($deleteSQL, $connpuntofermo) or
    die(mysql_error());
    $deleteGoTo = "ok-cancella.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $deleteGoTo));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $query_rs_elenco = "SELECT ID, `data`, titolo FROM news ORDER
    BY ID DESC";
    $rs_elenco = mysql_query($query_rs_elenco, $connpuntofermo)
    or
    die(mysql_error());
    $row_rs_elenco = mysql_fetch_assoc($rs_elenco);
    $totalRows_rs_elenco = mysql_num_rows($rs_elenco);
    ?>
    <html><!-- InstanceBegin
    template="/Templates/template-adm.dwt"
    codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>amministrazione Piadineria Punto
    Fermo</title>
    <!-- InstanceEndEditable --><meta
    http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1"><style
    type="text/css">
    <!--
    body {
    background-color: #CCD57B;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    -->
    </style>
    <link href="../css/style.css" rel="stylesheet"
    type="text/css">
    <style type="text/css">
    @import "news/domnews.css";
    </style>
    <script type="text/javascript"
    src="news/domnews.js"></script>
    <!-- InstanceBeginEditable name="head" --><!--
    InstanceEndEditable -->
    </head>
    <body>
    <table width="100%" height="100%" border="0"
    align="center" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center" valign="middle"><table
    width="760" height="430"
    border="0" align="center" cellpadding="0" cellspacing="1"
    bgcolor="#A7B339">
    <tr>
    <td width="779" align="left" valign="middle"
    bgcolor="#FFFFCC"><table width="760" height="334"
    border="0" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center"
    class="body"><strong>AMMINISTRAZIONE SITO
    PUNTO FERMO </strong></td>
    </tr>
    <tr>
    <!-- InstanceBeginEditable name="header" --><td
    height="42"
    align="center" valign="top" class="body"><a
    href="menu.php"
    class="body">torna
    a men&ugrave; principale </a></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <!-- InstanceBeginEditable name="body" -->
    <td align="center" valign="top"
    class="body"><p>ELENCO NEWS
    INSERITE</p>
    <table width="505" border="0" cellpadding="5"
    cellspacing="1"
    bgcolor="#999999" class="body">
    <tr bgcolor="#FFFFA8">
    <td>ID</td>
    <td width="104">DATA</td>
    <td width="134">TITOLO</td>
    <td width="110"> </td>
    <td width="112"> </td>
    </tr>
    <?php do { ?>
    <tr align="left" valign="top" bgcolor="#FFFFCC">
    <td><?php echo $row_rs_elenco['ID'];
    ?></td>
    <td><?php echo $row_rs_elenco['data'];
    ?></td>
    <td><?php echo $row_rs_elenco['titolo'];
    ?></td>
    <td><a href="mod-news.php?ID=<?php echo
    $row_rs_elenco['ID']; ?>"
    class="body">MODIFICA</a></td>
    <td><form name="elimina1" method="post"
    action="">
    <input type="submit" name="Submit" value="ELIMINA">
    </form></td>
    </tr>
    <?php } while ($row_rs_elenco =
    mysql_fetch_assoc($rs_elenco)); ?>
    </table>
    <p>  </p></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    </table> </td>
    </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($rs_elenco);
    ?>
    Where is error?
    Thanks.

    MX 2004 was always a bit "gummy" on this.  Instead of using the DW wizard, I downloaded a free version of Microsoft SQL Server Express Edition.  I use that for all table Inserts, Updates,etc.   This accesses the tables directly on the server.  Nothing needs to be synced, put, gotten or whatever.  Use DW for Form and UI creation and making prebuilt queries.
    Hope that helps
    Jerry H

  • Delete record works too well !

    I've done this before successfully several times but now something strange is happening.  I've stared at this for a couple of hours now and don't see what I'm missing, it must be something blindingly obvious.
    I created a page showing all records in a table using a repeating region. I added a column with a big red X image so that users can delete the record by clicking on the "X". This links to a delete page which displays the record and asks "Are you sure" the user clicks "Yes" and the record should be deleted.
    What's happening is when the user clicks on the big red X the record is deleted and control is returned back to the page showing all records. I know it's going to the confirmation page as I tried removing the Delete Record behavior and it successfully displays the record I want to delete. I tried creating a new delete page from scratch to delete the record just in case there was something left over from the page I started with to create the delete page in the first place, same result.
    Anyone have any clues? I'm using DW CS4, PHP, MySQL and Win 7
    Thanks

    oops sorry, here's the code for the delete page
    <?php require_once('../Connections/adminconnection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $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($_GET['reservationnumber'])) && ($_GET['reservationnumber'] != "")) {
      $deleteSQL = sprintf("DELETE FROM dinner WHERE reservationnumber=%s",
                           GetSQLValueString($_GET['reservationnumber'], "int"));
      mysql_select_db($database_adminconnection, $adminconnection);
      $Result1 = mysql_query($deleteSQL, $adminconnection) or die(mysql_error());
      $deleteGoTo = "admin2.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $deleteGoTo));
    $colname_rsdeletedinntest = "-1";
    if (isset($_GET['reservationnumber'])) {
      $colname_rsdeletedinntest = $_GET['reservationnumber'];
    mysql_select_db($database_adminconnection, $adminconnection);
    $query_rsdeletedinntest = sprintf("SELECT * FROM dinner WHERE reservationnumber = %s", GetSQLValueString($colname_rsdeletedinntest, "int"));
    $rsdeletedinntest = mysql_query($query_rsdeletedinntest, $adminconnection) or die(mysql_error());
    $row_rsdeletedinntest = mysql_fetch_assoc($rsdeletedinntest);
    $totalRows_rsdeletedinntest = mysql_num_rows($rsdeletedinntest);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="../styles/thrColLiqHdr.css" rel="stylesheet" type="text/css" />
    </head>
    <body class="oneColFixCtrHdr">
    <div id="container">
      <div id="header">
        <h1>Header</h1>
      <!-- end #header --></div>
      <div id="mainContent">
        <h1> Main Content </h1>
        <p>L</p>
        <p> </p>
        <table width="400" border="1">
          <tr>
            <td>res name</td>
            <td><?php echo $row_rsdeletedinntest['reservationname']; ?></td>
          </tr>
          <tr>
            <td>num in pty</td>
            <td><?php echo $row_rsdeletedinntest['numberinparty']; ?></td>
          </tr>
          <tr>
            <td>paid</td>
            <td><?php echo $row_rsdeletedinntest['amountpaid']; ?></td>
          </tr>
        </table>
        <p> </p>
        <p> </p>
        <form id="form1" name="form1" method="post" action="deletedinner.php">
          <label>are you sure
            <input type="submit" name="delete" id="delete" value="Submit" />
          </label>
        </form>
        <p> </p>
        <p>Donec nec libero.</p>
        <h2>H2 level heading </h2>
        <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
    <!-- end #mainContent --></div>
      <div id="footer">
        <p>Footer</p>
      <!-- end #footer --></div>
    <!-- end #container --></div>
    </body>
    </html>
    <?php
    mysql_free_result($rsdeletedinntest);
    ?>

  • Delete Record server behavior problem

    Hi all!
    I'm such a painful situation, that I can't figure out, why my
    Delete
    Record form don't work as supposed.
    It seems all things work (also gives message "You have
    successfully
    deleted the article."), but the problem is
    that in the MySQL (5) database real deletion doesn't
    occure...
    I was walking along with very nice tutorial
    (www.adobe.com/devnet/dreamweaver/articles/php_blog2_11.html)
    if someone has time to think about...
    I have all the steps (from the tutorial) done multiple times
    and
    result... no real deletion, despite "successfully deleted"
    text :(
    with regards,
    andreta

    Yeah! As always - if one is doing too much over and over,
    then it's too
    much of trouble.
    I used sample delete_art.php(premade by Marius) file instead
    of mine and
    it worked!
    If I was wondering what is different, then there was large
    amount of
    additional code in my file:
    In pre-made sample is 200 lines versus 242 in mine :(
    Differences(looked with Winmerge):
    MINE(not working): Working:
    (why my DW8 inserts session handling in this way?)
    1)
    $_SESSION['MM_Username'] = NULL;
    session_unregister('MM_Username');
    $_SESSION['MM_UserGroup'] = NULL;
    session_unregister('MM_UserGroup');
    $_SESSION['PrevUrl'] = NULL;
    unset($_SESSION['MM_Username']);
    unset($_SESSION['MM_UserGroup']);
    unset($_SESSION['PrevUrl']);
    2)
    if (!isset($_SESSION)) { session_start();
    session_start();
    3)
    in NONworking: (in WORKING - nothing )
    (NB! this was a double-code - i think because of the redoings
    (?recordset deleting & recreating?) )
    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;
    4)
    NONworking:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml"><!--
    InstanceBegin
    template="/Templates/admintemplate.dwt.php"
    codeOutsideHTMLIsLocked="false" -->
    Working:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    5)
    NonW:
    <?php do { ?>
    <tr class="topheader">
    <td><?php echo $row_rsDeletedArticle['title_art'];
    ?></td>
    Working:
    <tr class="topheader">
    <td><?php echo $row_rsDeletedArticle['title_art'];
    ?></td>
    6)
    NONW:
    <td colspan="3"><?php echo
    $row_rsDeletedArticle['text_art']; ?></td>
    </tr>
    <tr>
    <td colspan="3"> </td>
    </tr>
    <?php } while ($row_rsDeletedArticle =
    mysql_fetch_assoc($rsDeletedArticle)); ?>
    </table>
    <table width="30%" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td><form id="delete" name="delete" method="post"
    action="delete_art.php">
    <input name="yes" type="submit" id="yes" value="yes"
    />
    <input name="id_art" type="hidden" id="id_art"
    value="<?php echo $row_rsDeletedArticle['id_art']; ?>"
    />
    </form>
    </td>
    <td><form id="cancel" name="cancel" method="post"
    action="list_art.php">
    <input name="no" type="submit" id="no" value="No" />
    </form>
    </td>
    </tr>
    </table>
    <?php } // Show if recordset not empty ?>
    <?php if ($totalRows_rsDeletedArticle == 0) { // Show if
    recordset empty ?>
    <p>You have successfully deleted the
    article.</p>
    <form id="back" name="back" method="post"
    action="list_art.php">
    <input name="back" type="submit" id="back" value="Back"
    />
    </form>
    <?php } // Show if recordset empty
    ?><p>  </p>
    <!-- InstanceEndEditable --></td>
    Working:
    <td colspan="2"><p><?php echo
    $row_rsDeletedArticle['text_art']; ?></p></td>
    </tr>
    <tr>
    <td colspan="2"><table width="15%" border="0"
    cellspacing="0" cellpadding="0">
    <tr>
    <td><form action="delete_art.php" method="post"
    name="delete" id="delete">
    <input name="yes" type="submit" id="yes" value="Yes">
    <input name="id_art" type="hidden" id="id_art"
    value="<?php echo $row_rsDeletedArticle['id_art'];
    ?>">
    </form></td>
    <td><form action="list_art.php" method="post"
    name="cancel" id="cancel">
    <input name="no" type="submit" id="no" value="No">
    </form></td>
    </tr>
    </table></td>
    </tr>
    </table>
    <?php } // Show if recordset not empty ?>
    <?php if ($totalRows_rsDeletedArticle == 0) { // Show if
    recordset
    empty ?>
    <p>You have successfully deleted the
    article.</p>
    <form action="list_art.php" method="post" name="back"
    id="back">
    <input name="back" type="submit" id="back"
    value="Back">
    </form>
    <?php } // Show if recordset empty ?>
    <p>  </p>
    <p> </p> <p> 
    </p></td>
    </tr>
    Boo-oo-hh!
    It's enough for now
    Please can someone give me advices about what is wrong with
    the nonworking
    (I deleted the section 3 from nonworking but it anyway
    doesn't work)
    AndreTa wrote:
    > Oh, sorry!
    >
    > additional information - working with DW8.0.2, PHP
    5.1.6, and with the
    > "blog" database with MySQL 4.1.14
    > (have also MySQL 5.0 - havn't tried with this... I'll do
    it after sweet
    > dreams and hard workday i.e. tomorrow)
    > In local PC WinXP, Apache 2.2.3
    >
    > andreta
    >
    >

  • Delete Record Behavior doesn't wait for Submit button

    I have master / detail page set.  From the detail set there are links to delete or update a record.  When I click the link to delete the record, it goes to the   confirmation page with the correct record.  Now, when I add the delete record server behavior and a submit button, this is what happens.  As soon as I click the link to go to the delete confirm page, the record deletes and the page redirects to the page I put in the server behavior.  It doesn't show the confirm page and doesn't wait for me to hit the confirm button.  The page runs and successfully deletes the page from the DB.
    How do I get it to wait until I hit the submit button?

    You need to surround your delete query with an "If" statement that checks for a confirmation variable of some sort, then when the user clicks the confirmation link you can pass the necessary variable and the ID of the record the delete query is expecting.
    As an alternative you could use a JS alert fuction to ask the user if they are sure they want to delete the record and then allwo the delet to run after confirmation. To do this you could use code like this...
    <input type="submit" name="DELETE" value="DELETE"
       onclick="return confirm('Are you SURE you want to DELETE this record?')">
    Lawrence   *Adobe Community Expert*
    www.Cartweaver.com
    Complete Shopping Cart Application for
    Dreamweaver, available in ASP, PHP and CF
    www.twitter.com/LawrenceCramer

  • Delete Record Automatically deleting

    I have been trying to see if anyone has had this same issue with no real luck. I was hoping someone could give me a quick hand. I am created a delete record page as you would usually do. It is supposed to populate like any other page first so that yiou see the user's information. You should then be able to hit the delete button to delete the actual record. Unfortunately as soon as you go to the page it automatically deletes the record not giving you a chance to review the file first.
    Here is the standard delete record code from Dreamweaver:
    if ((isset($_GET['ID'])) && ($_GET['ID'] != "")) {
      $deleteSQL = sprintf("DELETE FROM entry WHERE ID=%s",
                           GetSQLValueString($_GET['ID'], "int"));
      mysql_select_db($database_toyosupport, $toyosupport);
      $Result1 = mysql_query($deleteSQL, $toyosupport) or die(mysql_error());
      $deleteGoTo = "/support/EnterDealer/Admin_Edit_dealer.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $deleteGoTo));
    My form is pretty basic:
    <form action="/support/EnterDealer/Admin_Edit_dealer.php" method="post" name="delete_User" id="delete_User">
    Form is set to post so i can;t see any reason it should automatically delete the file.
    Any ideas? 

    OK so thi sis not the "RIGHT" answer as I still don't know why it is automatically deleting. But with that in mind all I did was create a "View" page stating "ARE YOU SURE YOU WOULD LIKE TO DLETE THIS USER?" After that they are then sent to the delete record page which then deletes the record. If anyone wants to take a stab at it here is the complete code for the "delete" page. There may be something i am just not seeing ...
    <?php  session_start(); ?>
    <?php require_once('../../Connections/toyosupport.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $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($_GET['ID'])) && ($_GET['ID'] != "")) {
      $deleteSQL = sprintf("DELETE FROM entry WHERE ID=%s",
                           GetSQLValueString($_GET['ID'], "int"));
      mysql_select_db($database_toyosupport, $toyosupport);
      $Result1 = mysql_query($deleteSQL, $toyosupport) or die(mysql_error());
      $deleteGoTo = "/support/EnterDealer/Admin_Edit_dealer.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
        $deleteGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $deleteGoTo));
    $colname_rsDEALERLIST = "-1";
    if (isset($_POST['ID'])) {
      $colname_rsDEALERLIST = $_POST['ID'];
    mysql_select_db($database_toyosupport, $toyosupport);
    $query_rsDEALERLIST = sprintf("SELECT * FROM entry WHERE ID = %s", GetSQLValueString($colname_rsDEALERLIST, "int"));
    $rsDEALERLIST = mysql_query($query_rsDEALERLIST, $toyosupport) or die(mysql_error());
    $row_rsDEALERLIST = mysql_fetch_assoc($rsDEALERLIST);
    $totalRows_rsDEALERLIST = mysql_num_rows($rsDEALERLIST);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head>
    </head>
    <!--<body oncontextmenu="return false;">-->
    <body>
    <form method="post" name="delete_User" id="delete_User">
      <table border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#FFFFFF" width="100%">
        <tr valign="top" bgcolor="#FFFFFF">
          <td colspan="3" bgcolor="#3399CC" class="BoldTextBLK"><font class="drupal_blend_9pt">Please
            enter ALL  information.
            <input name="ID" type="hidden" id="ID" value="<?php echo $row_rsDEALERLIST['ID']; ?>" />
          </font></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td width="38%" bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt">First
            Name/Pr&eacute;nom <br />
            </font></span></td>
          <td width="14%" colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Name']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td width="38%" bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Last
            Name/Nom</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['NameLast']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#006699">
          <td height="5" bgcolor="#FFFFFF"> </td>
          <td height="5" colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Password']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Store
            Number <font size="1">(Toyo Account #)</font></font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['DealerNumber']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td width="38%" bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Company
            Name/Nom du D&eacute;taillant </font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Company']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Address/Adresee</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Address']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">City/Ville</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['City']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Province</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['DealerProv']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Postal
            Code/Code Postal</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['PostalCode']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Email/Courriel</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['EmailAddress']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Phone/Num&eacute;ro</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Phone']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt"><font class="drupal_blend_9pt">Fax</font></span></td>
          <td colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Fax']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#006699">
          <td height="5" bgcolor="#FFFFFF"><span class="Drupal_Blend_9pt">Price List</span></td>
          <td height="5" colspan="2" bgcolor="#FFFFFF"><?php echo $row_rsDEALERLIST['Plist_0']; ?><br />
            <?php echo $row_rsDEALERLIST['Plist_U']; ?> <br />
            <?php echo $row_rsDEALERLIST['Plist_G']; ?></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td colspan="3" bgcolor="#FFFFFF"><font class="drupal_blend_9pt"> </font></td>
        </tr>
        <tr valign="top" bgcolor="#FFFFFF">
          <td width="38%" align="right" bgcolor="#FFFFFF"><font class="drupal_blend_9pt"><b>Delete record.</b></font><font color="#FF0000">Note this is permanent!</font></td>
          <td colspan="2" bgcolor="#FFFFFF"><font class="drupal_blend_9pt">
            <input name="Delete_User" type="submit" id="Delete_User" value="Delete_User" />
          </font></td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($rsDEALERLIST);
    ?>

  • CANNOT FIND mmhttpdb.php  and mysql.php  files

    does anyone know where I can download these two files from ? (in order to connect to database)
    mmhttpdb.php     mysql.php
    I deleted them accidentially.

    * Vista/Windows 7: C:\Program Files (x86)\Adobe\Adobe Dreamweaver CC\Configuration\DisabledFeatures
    * Mac OS X: /Applications/Adobe Dreamweaver CC/Configuration/DisabledFeatures
    If they no longer reside anywhere including your trash/recycle bin, you may need to re-install CC.
    Nancy O.

  • Delete record from the form and from the database

    hi,
    i want delete record from the form and the database ,but the record is only delete from the from !!!
    this is my code :
    if //condition then
    delete_record;
    commit;
    end if ;
    Any solutions ??
    thnx

    You have unique key field(s) on the table you are trying to insert which actually restricts you from inserting the same value again.
    When you are deleting the record and issue commit there is a record to be inserted in the table which is a duplicate that's why you are getting this unique error.
    As oracle is not able to insert your commit fails and stops your deletion of record from table

  • Delete records from tableA which are not in tableB

    Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
    delete from tableA where empno not in (select empno from tableb)
    or
    delete from tableA where empno not exists (select empno from tableb
    where b.empno=a.empno)
    any help

    Hi
    If you can do this, do with this:
    create table tableC
    as select a.*
    from tableA a,
    (select empno from tableA
    minus
    select empno from tableB) b
    where a.empno = b.empno;
    drop table tableA;
    rename table tableC to tableA;
    Ott Karesz
    http://www.trendo-kft.hu

Maybe you are looking for