Free web host - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY //

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY // prepare the SQL query $sql = “UPDATE journal SET title = ‘$title’, article = ‘$article’ WHERE article_id = $article_id”; // submit the query $done = mysql_query($sql) or die(mysql_error()); } // redirect page on success or $article_id is invalid if ($done || !isset($article_id)) { Most of this code should be familiar. Any backslashes inserted by magic quotes will have been removed by nukeMagicQuotes() because you placed it outside the conditional statements in step 1, so this code block begins by passing items in the $expected array to mysql_real_escape_string() to prepare them for insertion into the database, and storing them in shorter variables ($title, $article, and $article_id). Because it s possible to tamper with a hidden field, you make sure that $article_id is numeric before carrying on. In the UPDATE query, strings need to be quoted, so the entire query is enclosed in double quotes, with $title and $article in single quotes. Although the mysql_query() function returns a result set from a SELECT query, with UPDATE, it returns true or false. So, if the update succeeds, $done is reset to true. You need to add $done || to the condition that controls the page redirection script. This redirects the page either if $done is true or if $article_id is invalid. 8. Save journal_update.php and test it by loading journal_list.php, selecting one of the EDIT links, and making changes to the record that is displayed. When you click Update record, you should be taken back to journal_list.php. You can verify that your changes were made by clicking the same EDIT link again. Check your code, if necessary, with journal_update_mysql02.php. PHP Solution 13-6: Updating a record with MySQL Improved Use journal_update01.php fromthe download files. The code for the first stage of the update process is in journal_update_mysqli01php, and the final code is in journal_update_mysqli02.php. 1. The first stage involves retrieving the details of the record that you want to update. Put the following code above the DOCTYPE declaration: Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply