wizardry Posted February 7, 2009 Share Posted February 7, 2009 i have have the code working out side of using dw to create the form. here is the code maybe another set of eyes could help. thanks in advance! code: <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO user (user_Id, UEA, UEAP) VALUES (null, %s, %s)", GetSQLValueString($_POST['user_Id'], "int"), GetSQLValueString($_POST['UEA'], "text"), GetSQLValueString($_POST['UEAP'], "text")); $insertSQL1 = sprintf("insert into uname (uname_Id, user_Id_fk, Fname, Lname) values ( LAST_INSERT_ID(), LAST_INSERT_ID(), %s, %s )", GetSQLValueString($_POST['uname_Id'], "int"), GetSQLValueString($_POST['user_Id_fk'], "int"), GetSQLValueString($_POST['Fname'], "text"), GetSQLValueString($_POST['Lname'], "text")); $insertSQL2 = sprintf("insert into uzip (uname_Id_fk, uzip_Id, Zip) VALUES (LAST_INSERT_ID(), null, %s,)", GetSQLValueString($_POST['uname_Id_fk'], "int"), GetSQLValueString($_POST['uzip_Id'], "int"), GetSQLValueString($_POST['Zip'], "text")); //----------------- db name ------------- db connection mysql_select_db($database_user, $Schema); $Result1 = mysql_query($insertSQL, $Schema) or die(mysql_error()); mysql_select_db($database_uname, $Schema); $Result2 = mysql_query($insertSQL1, $Schema) or die(mysql_error()); mysql_select_db($database_uzip, $Schema); $Result3 = mysql_query($insertSQL2, $Schema) or die(mysql_error()); $insertGoTo = "userdataset.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">Email Address:</td> <td><input type="text" name="UEA" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Password:</td> <td><input type="password" name="UEAP" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">First Name:</td> <td><input type="text" name="Fname" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Last Name:</td> <td><input type="text" name="Lname" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Zip:</td> <td><input type="text" name="Zip" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert record" /></td> </tr> </table> <input type="hidden" name="user_Id" value="" /> <input type="hidden" name="uname_Id" value="" /> <input type="hidden" name="user_Id_fk" value="" /> <input type="hidden" name="uname_Id_fk" value="" /> <input type="hidden" name="uzip_Id" value="" /> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/144244-mysql-insert-loop/ Share on other sites More sharing options...
Mchl Posted February 7, 2009 Share Posted February 7, 2009 And the problem is? Link to comment https://forums.phpfreaks.com/topic/144244-mysql-insert-loop/#findComment-756971 Share on other sites More sharing options...
wizardry Posted February 7, 2009 Author Share Posted February 7, 2009 it errors says that table doesn't exists but they do. i created the inital form out side of dw that has the same logic i just created this form in dw using their auto form and applied the logic that i used in the previous one to it. now this errors. i'm new to dw, i like their extras they add to the code for security. dw can connect to each table and schema Link to comment https://forums.phpfreaks.com/topic/144244-mysql-insert-loop/#findComment-756978 Share on other sites More sharing options...
corbin Posted February 8, 2009 Share Posted February 8, 2009 $database_user and the other vars are set somewhere, yes? Link to comment https://forums.phpfreaks.com/topic/144244-mysql-insert-loop/#findComment-757095 Share on other sites More sharing options...
wizardry Posted February 8, 2009 Author Share Posted February 8, 2009 yes they are in a seperate conf.php which is included in the file i just left that line out. Link to comment https://forums.phpfreaks.com/topic/144244-mysql-insert-loop/#findComment-757108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.