fat creative Posted July 16, 2010 Share Posted July 16, 2010 I have come across a problem in a database I am working with. I have a work around, but am still curious as to why this is happening and wondered if anyone else has experienced such a thing. I have a form that updates my database. I submit it and it updates fine. However, if I edit the database using phpmyadmin and then submit the form again, it will no longer update that field in the database. My form is updating a field to say YES and I edited it again in phpmyadmin to say NO and submit the form again, just to confirm everything is working. It won't update the database on the second submit. However, I can submit the form several times and have it update different information in that field and it works. Its only as soon as I update with phpmyadmin, the submit will no longer update that field. It will update other fields, just not the one I edited in phpmyadmin. Does anyone have any idea why this would happen? Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 16, 2010 Share Posted July 16, 2010 Can we see your code? Ken Quote Link to comment Share on other sites More sharing options...
fat creative Posted July 16, 2010 Author Share Posted July 16, 2010 This is the code. I was originally testing paypals IPN and it wasn't working. I finally stripped everything down to a single update statement and thats when I discovered it wasnt the IPN, it was updating with phpmyadmin. My workaround is I'm just not updating with phpmyadmin anymore, I am using this form. Now that I have the workaround, the form has grown quite a bit in complexity. But the problem existed when I was updating a single text field. include('inc/dbc.php'); $email = $_POST['email']; $city = $_POST['city']; $featured = $_POST['featured']; $today=date(Ymd); $item_name = $_POST['item_name']; // this will check what item was purchased, 1, 3 6 or 12 months and set the end date of the featured item to today PLUS that time lenght if ($item_name == 'Subscription term: 1 month') { $featured_end_date = date('Y-m-d', strtotime('+1 month')); } if ($item_name == 'Subscription term: 3 months') { $featured_end_date = date('Y-m-d', strtotime('+3 month')); } if ($item_name == 'Subscription term: 6 months') { $featured_end_date = date('Y-m-d', strtotime('+6 month')); } if ($item_name == 'Subscription term: 12 months') { $featured_end_date = date('Y-m-d', strtotime('+12 month')); } $query = "SELECT * FROM vendors WHERE email = '$email'"; $result = mysql_query($query) or die ("There was an error:<br />".mysql_error()."<br />Query: $query"); if(mysql_num_rows($result)) //if a record is found!!! { $ok = mysql_query("UPDATE vendors SET featured_end_date = '$featured_end_date', featured_start_date = '$today', featured = '$featured' WHERE email = '$email'") or die(mysql_error()); if($ok) { echo "record updated. city is $city and emai lis $email and featured is $featured and featured start date is $today and end date is $featured_end_date"; } else { echo "sorry didint work"; } } else { $ok = mysql_query("INSERT INTO vendors (email, password, featured, featured_start_date, featured_end_date, active) VALUES('". mysql_escape_string($email) ."', 'password' ,'yes','$today','$featured_end_date', 'yes') ") or die(mysql_error()); if($ok) { $query1k = "SELECT * FROM vendors WHERE email = '$email'"; $result1k = mysql_query($query1k); while($row = mysql_fetch_array($result1k, MYSQL_ASSOC)) { $sr = "sr"; $sr .= "$row[ttd]"; $sr2 = "sr2"; $sr2 .="$row[ttd]"; $sr3 = "sr3"; $sr3 .="$row[ttd]"; $sr4 = "sr4"; $sr4 .="$row[ttd]"; $ok1 = mysql_query("UPDATE vendors SET sr_ttd = '$sr', ttd2 = '$sr2', ttd3 = '$sr3', ttd4 = '$sr4' WHERE email = '$email'"); } echo "record INSERTED. city is $city and emai lis $email and featured is $featured and featured end date is $today"; } else { echo "sorry didint work"; } } Thank you for any suggestions! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.