close ad
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

MySQLi file input update query problem with consecutive updates

Thread began 8/02/2023 4:21 am by Willem | Last modified 8/07/2023 8:40 am by Willem | 327 views | 7 replies


MySQLi file input update query problem with consecutive updates

I am upgrading a website from MySQL to MySQLi. I am updating a form with a file input ('guide_file'). The name of the file is written to 'Studyguide' field in database. Everythings works OK, on the first update submission, but if I update again, NULL is written to the 'Studyguide' field, as is expected. In the old code that did not happen due to the checking 'Studyguide=IFNULL(%s,Studyguide)' that was done.

How do I implement that in the MySQLi update procedure?

The Old code and New code is given below.


Old code

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE moderering_ekstern SET Date_modify=%s, `Year`=%s, Course_name=%s, Studyguide=IFNULL(%s,Studyguide) WHERE id_ecsa=%s",
GetSQLValueString($_POST['Time_modify'], "text"),
GetSQLValueString($_POST['jaar'], "int"),
GetSQLValueString($_POST['vak'], "text"),
GetSQLValueString($_POST['guide_file'], "text")
GetSQLValueString($_POST['hiddenfield'], "int"));

mysql_select_db($database_ecsa, $ecsa);
$Result1 = mysql_query($updateSQL, $ecsa) or die(mysql_error());

$updateGoTo = "edit_list_ext.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $updateGoTo));

MySQLi code

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$UpdateQuery = new WA_MySQLi_Query($ecsa);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "moderering_ekstern";
$UpdateQuery->bindColumn("Date_modify", "s", "".($_POST['Time_modify']) ."", "WA_BLANK");
$UpdateQuery->bindColumn("Year", "s", "".($_POST['jaar']) ."", "WA_BLANK");
$UpdateQuery->bindColumn("Course_name", "s", "".($_POST['vak']) ."", "WA_BLANK");
$UpdateQuery->bindColumn("Studyguide", "s", "".($_POST['guide_file']) ."", "WA_BLANK");
$UpdateQuery->addFilter("id_ecsa", "=", "d", "".($_POST['hiddenfield']) ."");
$UpdateGoTo = "edit_list_ext.php";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";

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





Ease of use


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...