www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP Update issue...dull but annoying

  1. #1
    Join Date
    May 2012
    Posts
    2

    PHP Update issue...dull but annoying

    Hi .. I can't get this UPDATE working, i can successfully INSERT INTO and SELECT*FROM the mysql table, but this UPDATE script does not update. I have copy/pasted any section i can from working queries. I have followed and implemented all forum solutions with no joy, I run the script in the browser and get no errors ... This is my first attempt at PHP web services so my knowledge is limited and so hopefully the problem will be painfully obvious to the trained eye.

    If anyone can see anything or suggest something to establish the problem it would be greatly appreciated

    Code:
    <?php
    
    mysql_connect('**********','************','************','************');
    
    @mysql_select_db('*************') or die ('Unable to find database');
    
    
    $formTitle = $_POST['formTitle'];
    $formRows = $_POST['formRows'];
    $status = $_POST['status'];
    $openedBy = $_POST['openedBy'];
    $openedDate = $_POST['openedDate'];
    $modifiedBy = $_POST['modifiedBy'];
    $modifiedDate = $_POST['modifiedDate'];
    $closedBy = $_POST['closedBy'];
    $closedDate = $_POST['closedDate'];
    $sendTo = $_POST['sendTo'];
    $formCount = $_POST['formCount'];
    
    $query = "UPDATE forms SET formRows='$formRows',status='$status',openedBy='$openedBy',openedDate='$openedDate',modifiedBy='$modifiedBy',modifiedDate='$modifiedDate',closedBy='$closedBy',closedDate='$closedDate',sendTo='$sendTo',formCount='$formCount' WHERE formTitle ='$formTitle'";
    
    mysql_query($query) or die (mysql_error());
    
    ?>

  2. #2
    Join Date
    Mar 2011
    Posts
    1,160
    I'd suggest you start with the essentials: Add echo($query) to the script so you can see exactly what's being sent to the mysql_query() function. Then use a tool like phpMyAdmin to examine the data before and after your tests. At a guess, I'd bet that there's a problem with the $formTitle variable that prevents the query from finding a matching record in the database to update. The code runs without an error because there are no syntax errors in the script or the query, but nothing happens.

  3. #3
    Join Date
    May 2012
    Posts
    2
    Thank you for your suggestions, i went back to using the formID rather than the formTitle .... for anyone else in the same predicament ...this is what ended up working in the end... so might be worth trying.

    Code:
    mysql_query("UPDATE forms SET formRows='".$formRows."',status='".$status."',openedBy='".$openedBy."',openedDate='".$openedDate."',modifiedBy='".$modifiedBy."',modifiedDate='".$modifiedDate."',closedBy='".$closedBy."',closedDate='".$closedDate."',sendTo='".$sendTo."',formCount='".$formCount."' WHERE formID ='".$id."'");

  4. #4
    Join Date
    May 2012
    Posts
    59
    Sounds quite clear... the formTitle couldn't be found!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles