This is doing my head in.
I have another page on a different table (same database) where this works fine. Yet now when I try to update the record, the eventbody (text area) just echos the data with formatting and it says "unable to update record" - which is defined error.
All I did was change the field names on this page...
Hope you can help
<?php error_reporting(E_ALL); ini_set("display_errors", 1); //include database connection include 'db_connect.php'; //check any user action $action = isset( $_POST['action'] ) ? $_POST['action'] : ""; if($action == "update"){ //if the user hit the submit button //write our update query //$mysqli->real_escape_string() function helps us prevent attacks such as SQL injection $query = "update eventguide set eventtitle = '".$mysqli->real_escape_string($_POST['eventtitle'])."', eventbody = '".$mysqli->real_escape_string($_POST['eventbody'])."', eventdate = '".$mysqli->real_escape_string($_POST['eventdate'])."', where eventid = S'".$mysqli->real_escape_string($_REQUEST['eventid'])."'"; //execute the query if( $mysqli->query($query) ) { //if updating the record was successful echo "<h1><strong>User was updated.</strong></h1>"; }else{ //if unable to update new record echo "Database Error: Unable to update record."; } } //select the specific database record to update $query = "select eventid, eventtitle, eventbody, eventdate from eventguide where eventid = '".$mysqli->real_escape_string($_REQUEST['eventid'])."' limit 0,1"; //execute the query $result = $mysqli->query( $query ); //get the result $row = $result->fetch_assoc(); //assign the result to certain variable so our html form will be filled up with values $eventid = $row['eventid']; $eventtitle = $row['eventtitle']; $eventbody = $row['eventbody']; $eventdate = $row['eventdate']; ?>