BadGoat Posted October 13, 2006 Share Posted October 13, 2006 Hello!I am trying to update a field in the database which is not working. It is a date field, which is not updating. There are two other fields in the update script which work fine, the $updated however, does not change. As a matter of fact, it erases the date that is in the db and leaves it blank. My code:[code]<input type="hidden" name="newupdated" value="' .$updated. '">';$updated=date('M j Y');$query = "UPDATE record SET nic = '".escapeSingleQuotes($_REQUEST['newnic'])."', company_id = '".$_REQUEST['newcompany_id']."', updated = '".$_REQUEST['newupdated']."' WHERE id='$id'";[/code]I'm not sure what I did to futz up this easy little script :( Link to comment https://forums.phpfreaks.com/topic/23888-update-question/ Share on other sites More sharing options...
kenrbnsn Posted October 13, 2006 Share Posted October 13, 2006 You're not actually doing an update. You're just defining a query string. You need to call mysql_query() with the query sting.[code]<?php$query = "UPDATE record SET nic = '".escapeSingleQuotes($_REQUEST['newnic'])."', company_id = '".$_REQUEST['newcompany_id']."', updated = '".$_REQUEST['newupdated']."' WHERE id='$id'";$rs = mysql_query($query) or die("Could not update the database, query: $query<br>" . mysql_error());?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/23888-update-question/#findComment-108561 Share on other sites More sharing options...
BadGoat Posted October 13, 2006 Author Share Posted October 13, 2006 My fault, I should have included more of the code. I was hoping my error was glaring. I should note that the script works fine updating the other two variables, the one which does not update is the '$updated' field. immediately following the $query line is this:[code] $result = mysql_query($query) or die("<b>mySQL Error:</b>"); if(!$result) { echo 'Error processing request.'; } else { echo '<B>The Record has been successfully updated!</B>'; } }[/code] Link to comment https://forums.phpfreaks.com/topic/23888-update-question/#findComment-108565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.