close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQli update server behavior not updating record

Thread began 4/01/2015 10:30 am by stephen287384 | Last modified 4/13/2015 6:31 pm by Ray Borduin | 1545 views | 15 replies |

stephen287384

MySQli update server behavior not updating record

I have a MySQli update server behavior that is not updating the record but redirects to the correct page after i submit the form. Here is the code:

<?php
$rsStores = new WA_MySQLi_RS("rsStores",$PPUconn,1);
$rsStores->setQuery("SELECT * FROM stores WHERE StoreID = ?");
$rsStores->bindParam("i", "".(isset($_GET['StoreID'])?$_GET['StoreID']:"") ."", "-1"); //colname
$rsStores->execute();
?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$UpdateQuery = new WA_MySQLi_Query($PPUconn);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "stores";
$UpdateQuery->bindColumn("StoreName", "s", "".((isset($_POST["StoreName"]))?$_POST["StoreName"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreLogo", "s", "".((isset($_POST["StoreLogo"]))?$_POST["StoreLogo"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreABN", "s", "".((isset($_POST["StoreABN"]))?$_POST["StoreABN"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreAbout", "s", "".((isset($_POST["StoreAbout"]))?$_POST["StoreAbout"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreFirstName", "s", "".((isset($_POST["StoreFirstName"]))?$_POST["StoreFirstName"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreSurname", "s", "".((isset($_POST["StoreSurname"]))?$_POST["StoreSurname"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StorePhone", "s", "".((isset($_POST["StorePhone"]))?$_POST["StorePhone"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreEmail", "s", "".((isset($_POST["StoreEmail"]))?$_POST["StoreEmail"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreURL", "s", "".((isset($_POST["StoreURL"]))?$_POST["StoreURL"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreAddress", "s", "".((isset($_POST["StoreAddress"]))?$_POST["StoreAddress"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreSuburb", "s", "".((isset($_POST["StoreSuburb"]))?$_POST["StoreSuburb"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StorePostcode", "s", "".((isset($_POST["StorePostcode"]))?$_POST["StorePostcode"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingMon", "s", "".((isset($_POST["StoreTradingMon"]))?$_POST["StoreTradingMon"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingTues", "s", "".((isset($_POST["StoreTradingTues"]))?$_POST["StoreTradingTues"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingWed", "s", "".((isset($_POST["StoreTradingWed"]))?$_POST["StoreTradingWed"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingThurs", "s", "".((isset($_POST["StoreTradingThurs"]))?$_POST["StoreTradingThurs"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingFri", "s", "".((isset($_POST["StoreTradingFri"]))?$_POST["StoreTradingFri"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingSat", "s", "".((isset($_POST["StoreTradingSat"]))?$_POST["StoreTradingSat"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("StoreTradingSun", "s", "".((isset($_POST["StoreTradingSun"]))?$_POST["StoreTradingSun"]:"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("StoreID", "=", "i", "".($_GET['StoreID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "admin_control_panel.php";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>

The results page has a link that passes the StoreID to the update page as a URL variable and the correct record loads but when i submit he form on the update page, it doesn't update but still redirects to the correct page as if it has.

I have also tried this for the lookup value:

$UpdateQuery->addFilter("StoreID", "=", "i", "".($rsStores->getColumnVal("StoreID")) ."");

Sign in to reply to this post

Ray BorduinWebAssist

Are you sure you are passing the url parameter correctly in the form action? I'd have to look at the code to fully debug it. If you post ftp information to a private area of this thread I'll take a look and figure it out.

Sign in to reply to this post

stephen287384

I'm not passing the url via a form, it's passed by a simple link eg: <a href="store_update.php?StoreID=<?php echo($rsStores->getColumnVal("StoreID")); ?>">View</a> from the store_results.php page.

The store_update.php page then loads the correct store record but won't update it when I submit the form on the store_update.php page.

Sign in to reply to this post

Ray BorduinWebAssist

You need to keep passing it through the form action so that after the submit it can be used in the update. If you can provide a url and ftp access in the private area I can give line numbers and help more directly. What do you have as the form action parameter on the update page?

Sign in to reply to this post

stephen287384

PM

Sign in to reply to this post

Ray BorduinWebAssist

Change that to:

php:
<form  action="store_update.php?StoreID=<?php echo(intval($_GET["StoreID"])); ?>" name="storeUpdate" id="storeUpdate" method="post">



Then it should work

Sign in to reply to this post

stephen287384

PM

Sign in to reply to this post

Ray BorduinWebAssist

I had my brackets wrong... please try again I've updated the previous thread.

Sign in to reply to this post

stephen287384

Yep, that worked, thanks Ray!

Sign in to reply to this post

Jay1983

Jay329

Hi Ray,

I'm experiencing a similar issue. My database is not updating. Please see below. I'm passing the id from another page via URL. I suspect the issue may be the way the form action is setup. Thank you for your help.


<?php require_once('.php'); ?>
<?php require_once('webassist/mysqli/rsobj.php'); ?>
<?php require_once('webassist/mysqli/queryobj.php'); ?>
<?php
$UpdateTicketCount = new WA_MySQLi_RS("UpdateTicketCount",$xxxxxxxxx,1);
$UpdateTicketCount->setQuery("SELECT * FROM TicketCounts WHERE Id = ?");
$UpdateTicketCount->bindParam("i", "".(isset($_GET['Id'])?$_GET['Id']:"") ."", "-1"); //colname
$UpdateTicketCount->execute();
?>
<?php
if (isset($_POST['submit']) || isset($_POST["submit_x"])) {
$UpdateQuery = new WA_MySQLi_Query($xxxxxxx);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "TicketCounts";
$UpdateQuery->bindColumn("Artist", "s", "".($UpdateTicketCount->getColumnVal("Artist")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Venue", "s", "".($UpdateTicketCount->getColumnVal("Venue")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("ShowDate", "t", "".($UpdateTicketCount->getColumnVal("ShowDate")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("TotalSold", "i", "".($UpdateTicketCount->getColumnVal("TotalSold")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("PreviousDaySold", "i", "".($UpdateTicketCount->getColumnVal("PreviousDaySold")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Wrap", "i", "".($UpdateTicketCount->getColumnVal("Wrap")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Capacity", "i", "".($UpdateTicketCount->getColumnVal("Capacity")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Open", "i", "".($UpdateTicketCount->getColumnVal("Wrap")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Advance", "s", "".($UpdateTicketCount->getColumnVal("Advance")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Dos", "s", "".($UpdateTicketCount->getColumnVal("Dos")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("OnSaleDate", "t", "".($UpdateTicketCount->getColumnVal("OnSaleDate")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("TM", "i", "".($UpdateTicketCount->getColumnVal("TM")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Hold", "i", "".($UpdateTicketCount->getColumnVal("Hold")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("FanClub", "s", "".($UpdateTicketCount->getColumnVal("FanClub")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Consignment", "i", "".($UpdateTicketCount->getColumnVal("Consignment")) ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("Sold", "i", "".($UpdateTicketCount->getColumnVal("Sold")) ."", "WA_DEFAULT");
$UpdateQuery->addFilter("Id", "=", "i", "".($_GET['Id']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "index4.php";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]> <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="">
<!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled Document</title>
<link href="boilerplate.css" rel="stylesheet" type="text/css">
<link href="update.css" rel="stylesheet" type="text/css">

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="respond.min.js"></script>
</head>
<body>
<div class="gridContainer clearfix">
<div id="div1" class="fluid">


</div>

<section class="fluid UpdateTable">

<form action="index4.php?StoreID=<?php echo(intval($_GET["Id"])); ?>" name="submit" id="submit" method="post">


<table width="200" border="1">
<tbody>
<tr>
<td>Artist/Band: </td>
<td>
<input value= "<?php echo($UpdateTicketCount->getColumnVal("Artist")); ?>" />
</td>
</tr>
<tr>
<td>Venue: </td>
<td>
<input value= <?php echo($UpdateTicketCount->getColumnVal("Venue")); ?> maxlength="100" />
</td>
</tr>
<tr>
<td>Show Date:</td>
<td>
<input value = <?php echo($UpdateTicketCount->getColumnVal("ShowDate")); ?> /> </td>
</tr>
<tr>
<td>Total Sold:</td>
<td>

<input value = <?php echo($UpdateTicketCount->getColumnVal("TotalSold")); ?> />

</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>

<input type = "hidden" name ="Id" value = "<?php echo($UpdateTicketCount->getColumnVal('Id')); ?>" />

<input name="submit" type="submit" id="submit" value="Update Record">


</form>

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...