weekenthe9 Posted March 13, 2009 Share Posted March 13, 2009 I made a webpage using php that allows user to update mysql database through an html form. There is an option on this page that disables modification, so it only displays the current data. However after the user submits the data and goes back to this page, the data has not been updated (while the db is). Has this got something to do with sessions or cookies? Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/ Share on other sites More sharing options...
phpdragon Posted March 13, 2009 Share Posted March 13, 2009 you will need to post some code so we can see what you are doing Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783846 Share on other sites More sharing options...
weekenthe9 Posted March 13, 2009 Author Share Posted March 13, 2009 Basically, when user updates the data from the webpage, although the database has been updated, the result is not shown on the webpage. All the data shown on the webpage are the old ones before the update. This is weird because the data on the webpage comes from the database, but now they have a mismatch. It takes some time and/or a reboot for web explorer for the new data to be shown on the webpage Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783912 Share on other sites More sharing options...
Maq Posted March 13, 2009 Share Posted March 13, 2009 Has this got something to do with sessions or cookies? Maybe... Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783927 Share on other sites More sharing options...
weekenthe9 Posted March 13, 2009 Author Share Posted March 13, 2009 I just found that the condition to make the updates show on the webpage is: Delete the webpage (e.g. somePage.php) from the server and re-upload it, then refresh the webpage Although this does not solve the problem, but maybe it's a useful hint... Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783943 Share on other sites More sharing options...
Maq Posted March 13, 2009 Share Posted March 13, 2009 you will need to post some code so we can see what you are doing Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783946 Share on other sites More sharing options...
weekenthe9 Posted March 13, 2009 Author Share Posted March 13, 2009 echo "<form name=\"input\" action=\"mysql_test_comments_added.php\" method=\"post\">"; echo "<table border=\"1\">"; echo "<tr><td>User</td><td>Comments</td><td>Comment Date</td></tr>"; while ($sapedUsers[$i]) { $result = mysql_query("SELECT * FROM ".$comments_tb." WHERE Project_Key=$PKey AND user=\"$sapedUsers[$i]\"") or die(mysql_error()); $row = mysql_fetch_array( $result ); if ($editable != 1) { $ltstring = " readonly=\"readonly\" "; $ltstring2 = " style=\"border:none;\" "; } else { $ltstring = " "; $ltstring2 = " "; } echo "<tr><td>"."<input".$ltstring2."type=\"text\"".$ltstring."name=\"user[".$i."]\" value=\"".$sapedUsers[$i]."\">"; echo "</td><td>"."<input".$ltstring2."type=\"text\"".$ltstring."name=\"comment_link[".$i."]\" value=\"".$row['comment_Link']."\">"; echo "</td><td>"."<input".$ltstring2."type=\"text\"".$ltstring."name=\"comments_Date[".$i."]\" value=\"".$row['comment_date']."\">"; echo "</td></tr>"; $i = $i + 1; } echo "<input type=\"hidden\" name=\"item_index\" value=\"".$i."\">"; echo "<input type=\"hidden\" name=\"Project_Key\" value=\"".$PKey."\">"; echo "</table>"; if ($editable == 1) { echo "<br><input type=\"submit\" value=\"Submit\">"; } echo "</form>"; _______________________________________________________________ and here's the target of the form: $user = $_POST["user"]; $comment_link = $_POST["comment_link"]; $Project_Key = $_POST["Project_Key"]; $comments_Date = $_POST["comments_Date"]; $item_index = $_POST["item_index"]; $i = 0; while ($i < $item_index) { $result = mysql_query("SELECT * FROM ".$comments_tb." WHERE Project_Key=$Project_Key AND user=\"$user[$i]\"") or die(mysql_error()); $row = mysql_fetch_array( $result ); if (!$row) { $goodreq = "INSERT INTO ".$comments_tb." (`user`, `comment_Link`, `project_Key`, `comment_Date`) VALUES ('$user[$i]', '$comment_link[$i]', '$Project_Key', '$comments_Date[$i]');"; } else { $goodreq = "UPDATE ".$comments_tb." SET `comment_Link` = '$comment_link[$i]', `comment_date` = '$comments_Date[$i]' WHERE Project_Key=$Project_Key AND user='$user[$i]'"; } echo $goodreq; mysql_query($goodreq) or die(mysql_error()); $i = $i + 1; } Quote Link to comment https://forums.phpfreaks.com/topic/149264-mysql-update-issue/#findComment-783967 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.