ok guys, thanks for all the help so far.
The following code accepts apostrophes in test but not in live. In live it only accepts the update if no apostrophes are present:
Let me know if you need the first part where the page populates the form prior to edit. At this point the changes have already been made & submitted
<?php
// if submit button has been pressed to make a record change then...
if(isset($_POST['subchanges']))
{
// we need to feed all possible fields which could have changed
//nb propid, beds, type, loc not editable
$newpropid = $_POST['newpropid'];
$newprice = $_POST['newprice'];
$newbeds = $_POST['newbeds'];
$newtype = $_POST['newtype'];
$newloc = $_POST['newloc'];
$newmaindesc = str_replace("'","''",$_POST['newmaindesc']);
$newroom1hdr = str_replace("'","''",$_POST['newroom1hdr']);
$newroom1det = str_replace("'","''",$_POST['newroom1det']);
$newroom2hdr = str_replace("'","''",$_POST['newroom2hdr']);
$newroom2det = str_replace("'","''",$_POST['newroom2det']);
$newroom3hdr = str_replace("'","''",$_POST['newroom3hdr']);
$newroom3det = str_replace("'","''",$_POST['newroom3det']);
$newroom4hdr = str_replace("'","''",$_POST['newroom4hdr']);
$newroom4det = str_replace("'","''",$_POST['newroom4det']);
$newroom5hdr = str_replace("'","''",$_POST['newroom5hdr']);
$newroom5det = str_replace("'","''",$_POST['newroom5det']);
require("../property_config.php");
if ($mysqli === false) {
die("Error - could not connect. " . mysqli_connect_error());
}
//update the db
$sql =
"UPDATE table1 SET
price = '$newprice',
maindesc = '$newmaindesc',
hdr1 = '$newroom1hdr',
desc1 = '$newroom1det',
hdr2 = '$newroom2hdr',
desc2 = '$newroom2det',
hdr3 = '$newroom3hdr',
desc3 = '$newroom3det',
hdr4 = '$newroom4hdr',
desc4 = '$newroom4det',
hdr5 = '$newroom5hdr',
desc5 = '$newroom5det'
WHERE id = $newpropid" ;
if ($mysqli->query($sql) === true) {
?><div class="msg"><?php
echo 'Record id ' . $newpropid . ' updated';
?></div><?php
$imagepath = substr($row[4], 0, 17);
//if update has worked, display the record
$sql =
"SELECT table1.id, table1.price, table1.beds, table1.type, table1.mainpic, table1.location, table1.maindesc, table1.hdr1,
table1.desc1, table1.hdr2, table1.desc2, table1.hdr3, table1.desc3, table1.hdr4, table1.desc4, table1.hdr5, table1.desc5
FROM table1 WHERE ('$newpropid' = table1.id)";
if ($result = $mysqli->query($sql)) {
if ($result->num_rows > 0) {
while($row = $result->fetch_array()) {
//display the newly edited record...