Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem Updating Database Table

    The data is assigned via a form on a separate page being posted to a second page.

    This is the update page but I keep a failed message -

    I have done an exit to the query to see if the data is being assigned correctly and it is - so I am guessing that the issue is actually when it attempts to write the data into the database.

    I have been working on this for a long time now trying to figure it out - any help to resolve this issue will be greatly appreciated.

    Thanks

    Code:
    <?php
    
    $feild1_namep = $_POST['field1_name'];
    $field2_descp = $_POST['field2_desc'];
    $field3_categoryp = $_POST['field3_category'];
    $field4_approvalp = $_POST['field4_approval'];
    
            $query = "UPDATE products SET ";
       	$query .= "field1_name='$field1_namep',field2_desc='$field2_descp',field3_category='$field3_category',field4_approvalp='field4_approval',";
       	$query .= "WHERE field1_name = '$field1_namep'";
       	
    
        $result = mysql_query ($query)
        	or die ("failed");
    
    
       	echo "<center>Product Updated.</center>";
        ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Echo mysql_error() when it fails.

    And when you get that syntax error, it will point to the problem, which I just noticed is an errant comma.


  •  

    Posting Permissions

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