garydt Posted February 27, 2007 Share Posted February 27, 2007 I managed, with help from here, to update a single field. Now i'm trying to update multiple fields but they aren't being updated. I'm not getting an error either. The code - <?php session_start(); ?> <?php require_once('Connections/elvisdb.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $user = $_SESSION['MM_Username']; $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE userinformation SET why=%s, howlong=%s, decade=%s, song=%s, album=%s, pictur=%s, aboutu=%s WHERE usernm=%s", GetSQLValueString($_POST['why'], "text"), GetSQLValueString($_POST['sincewhen'], "text"), GetSQLValueString($_POST['decad'], "text"), GetSQLValueString($_POST['favsong'], "text"), GetSQLValueString($_POST['favealbum'], "text"), GetSQLValueString($_POST['file'], "text"), GetSQLValueString($_POST['textarea'], "text"), GetSQLValueString($_POST['hiddenField'], "text")); mysql_select_db($database_elvisdb, $elvisdb); $Result1 = mysql_query($updateSQL, $elvisdb) or die(mysql_error()); $updateGoTo = "usernmm.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 {font-family: Arial, Helvetica, sans-serif} .style5 {font-family: Helvetica, Arial, "Times New Roman"} --> </style> </head> <body> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1"> <label></label> <table width="550" border="0" align="center" cellpadding="5"> <tr> <td bgcolor="#FFFFFF"><div align="left" class="style5">Why do you like/love Elvis </div> <span class="style5"> <label> </label> </span> <span class="style5"> <label></label> </span> <label> <div align="left" class="style5"> <textarea name="why" id="why"></textarea> </div> </label> </td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="left" class="style5">How long have you been an Elvis fan </div> <span class="style5"> <label> </label> </span> <span class="style5"> <label></label> </span> <label> <div align="left" class="style5"> <input name="sincewhen" type="text" id="sincewhen" /> </div> </label> </td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="left" class="style5">Which Elvis decade is your favourite? </div> <span class="style5"> <label> </label> </span> <span class="style5"> <label></label> </span> <label> <div align="left" class="style5"> <select name="decad" size="1" id="decad"> <option selected="selected">1950's</option> <option>1960's</option> <option>1970's</option> <option>All 3 decades</option> </select> </div> </label> </td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="left" class="style5"> <p> <label> Your favourite Elvis song<br /> <input name="favsong" type="text" id="favsong" /> </label> </p> </div></td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="left" class="style5"> <p>Your favourite Elvis album <label><br /> <input name="favealbum" type="text" id="favealbum" /> </label> </p> </div></td> </tr> <tr> <td bgcolor="#FFFFFF"><label> Upload a photo <br /> <input type="file" name="file" /> </label></td> </tr> <tr> <td bgcolor="#FFFFFF"><div align="left"><span class="style1"><span class="style5"></span></span> <label></label> <label> About you <br /> <textarea name="textarea"></textarea> </label> </div></td> </tr> <tr> <td bgcolor="#FFFFFF"><label> <input type="submit" name="Submit" value="Submit" /> </label></td> </tr> </table> <p> <input name="hiddenField" type="hidden" value="MM_Username" /> </p> <p> <label></label> </p> <input type="hidden" name="MM_update" value="form1"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/40339-multiple-update-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.