palmtreeinfotech
asked on
Dreamweaver Update Record PHP not working
Seems this is hit and miss. I manually made a form and tied the ID from the previous page (in a recordset dynamic table). When the user clicks on the ID it is a link to the update_record.php page. Everything seems fine but the record is not updating for some reason. No error codes or anything displays, just the form does not work. The form has dynamic form fields on it so the user can update and see what is currently in the DB. I'm not much of a coder so don't know if I'm missing something in my code but it even goes to the update_success.php page after updating, but nothing has changed in the DB. Any ideas?
ASKER
As a side note, I'm trying to update the [modified] field in the DB when the user hits the submit button. I have it has a hidden field called "modified" which is the same field as my database and I have the value set at <?php date("y:m:d h:i:s")?>
Would this update in the database based on the time they hit the submit button to the [modified] field each time? Or should I be posting another question for this?
Would this update in the database based on the time they hit the submit button to the [modified] field each time? Or should I be posting another question for this?
Hi again, palmtreeinfotech,
Your recordset is looking for a URL parameter named ID:
$colname_Recordset1 = "-1";
if (isset($_GET['ID'])) {
$colname_Recordset1 = $_GET['ID'];
}
Is the URL something.php?ID=xxx or something.php?id=xxx
Because if it is the latter, this won't work as PHP is case sensitive.
>> Would this update in the database based on the time they hit the submit button to the [modified]
>> field each time?
Yes, but easier to set the field to a TIMESTAMP and then set it to ON UPDATE CURRENT TIMESTAMP. So each time the row is updated, it gets the latest system time and date.
Your recordset is looking for a URL parameter named ID:
$colname_Recordset1 = "-1";
if (isset($_GET['ID'])) {
$colname_Recordset1 = $_GET['ID'];
}
Is the URL something.php?ID=xxx or something.php?id=xxx
Because if it is the latter, this won't work as PHP is case sensitive.
>> Would this update in the database based on the time they hit the submit button to the [modified]
>> field each time?
Yes, but easier to set the field to a TIMESTAMP and then set it to ON UPDATE CURRENT TIMESTAMP. So each time the row is updated, it gets the latest system time and date.
ASKER
Hi Jason! You're the resident expert I see!
I changed my text field name to capital "ID" and that didn't make a difference. It's actually linking correctly from the previous page based on the ID of the row in the table:
update_record.php?ID=1
The actual URL Param id is "ID" on both page.
What I did on the timestamp is tell Dreamweaver to update my hidden field (hiddenmodified) to update to my database field of [modified] and set the hidden field to "now()" but not sure that will work in MySQL though.
Everything seems to be working except the update is still not working??
I changed my text field name to capital "ID" and that didn't make a difference. It's actually linking correctly from the previous page based on the ID of the row in the table:
update_record.php?ID=1
The actual URL Param id is "ID" on both page.
What I did on the timestamp is tell Dreamweaver to update my hidden field (hiddenmodified) to update to my database field of [modified] and set the hidden field to "now()" but not sure that will work in MySQL though.
Everything seems to be working except the update is still not working??
>> Hi Jason! You're the resident expert I see!
For Dreamweaver, more or less. I also tend to be home at nights because having a small child really ruins ones ability to be out on Saturday nights :)
1. When you go to the update page, are the form fields prepopulated? That will handle the passing of the $_GET array
2. If the form fields are prepopulated, the error is most likely here:
<input name="id" type="text" disabled="disabled" id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
disabled="disabled" may prevent the form from submitting the data altogether. Better to do:
<input name="id" type="hidden" id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
or, if it must be visible:
<input name="id" type="text" readdonly id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
For Dreamweaver, more or less. I also tend to be home at nights because having a small child really ruins ones ability to be out on Saturday nights :)
1. When you go to the update page, are the form fields prepopulated? That will handle the passing of the $_GET array
2. If the form fields are prepopulated, the error is most likely here:
<input name="id" type="text" disabled="disabled" id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
disabled="disabled" may prevent the form from submitting the data altogether. Better to do:
<input name="id" type="hidden" id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
or, if it must be visible:
<input name="id" type="text" readdonly id="id" value="<?php echo $row_Recordset1['ID']; ?>" />
I don't think setting to NOW() will work as expected. You really should define it like so:
ALTER TABLE `tblInfo` CHANGE `datemodified` `datemodified` TIMESTAMP( 23 ) ON UPDATE CURRENT_TIMESTAMP NOT NULL
ALTER TABLE `tblInfo` CHANGE `datemodified` `datemodified` TIMESTAMP( 23 ) ON UPDATE CURRENT_TIMESTAMP NOT NULL
ASKER
Hey Jason cool I understand! I took off the "disabled" and to no avail no change.
I'm not much of a coder. In any case, I changed my hiddenfield of [modified] to timestamp(). I will see if that works but I won't know until I can get the page to actually update!
Good suggestions. Anymore ideas? Everything seems to be working great but just no updates to the database. Weird.
I'm not much of a coder. In any case, I changed my hiddenfield of [modified] to timestamp(). I will see if that works but I won't know until I can get the page to actually update!
Good suggestions. Anymore ideas? Everything seems to be working great but just no updates to the database. Weird.
Can I get a link to the page for testing?
ASKER
Sure!
http://peculiarchamber.com/admin2341231/index.php
Login: admin
Pass: MDDBel9jpU
It's okay to post on here..I just have the session variable set so you cannot access the page without logging in first. I'm just testing anyway.
After login, mainmenu.php, click on an ID, takes you to update page. Change something then hit Submit, go back to main menu and record not updated! Frustrating. Thank you so much for looking at it!
http://peculiarchamber.com/admin2341231/index.php
Login: admin
Pass: MDDBel9jpU
It's okay to post on here..I just have the session variable set so you cannot access the page without logging in first. I'm just testing anyway.
After login, mainmenu.php, click on an ID, takes you to update page. Change something then hit Submit, go back to main menu and record not updated! Frustrating. Thank you so much for looking at it!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Jason, thank you so much and sorry for the late reply. I changed the variable like in your example and it still didn't update. :( I'm wondering if I should delete the update record behaviour and start all over just to be safe? But I shouldn't have to do that I wouldn't think. I checked all the other case id=ID and all of them are capitalized in the update query.
ASKER
Jason, I was playing around and I took off the "disabled" after changing the case id to ID and it seems to be working! How weird is that? It should work either way in my opinion...thanks for all your help!
ASKER
Took off the "disabled" tags and it seems to be working. Thanks a lot for your help and I hope you and the baby are doing well!
>> I took off the "disabled" after changing the case id to ID and it seems to be working! How weird is that?
Why would you think it's weird? Both things were wrong :)
It appears you changed the HTML field name to ID when my first post talked about checking the URL (which turns out to have been a bit of a red herring). The disabled can prevent the form from submitting the data but this appears to be a browser to browser thing.
>> I hope you and the baby are doing well!
Not a baby. 4.5...he just craps out at an early hour :)
Why would you think it's weird? Both things were wrong :)
It appears you changed the HTML field name to ID when my first post talked about checking the URL (which turns out to have been a bit of a red herring). The disabled can prevent the form from submitting the data but this appears to be a browser to browser thing.
>> I hope you and the baby are doing well!
Not a baby. 4.5...he just craps out at an early hour :)
ASKER
Open in new window