I am trying to insert 50ish records into a mySQL database and… the obligatory code post
[php]<?php require_once('Connections/connection.php'); ?>
<?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")) {
mysql_select_db($database_direwolves, $direwolves);
// loop through the input values
for ($i = 0, $len = count($_POST['member_uid[]']); $i < $len; $i++) {
$insertSQL = sprintf("INSERT INTO pk_dues (member_uid, dues_level, dues_date, dues_amount) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['member_uid'][$i], "int"),
GetSQLValueString($_POST['dues_level'][$i], "int"),
GetSQLValueString($_POST['dues_date'][$i], "date"),
GetSQLValueString($_POST['dues_amount'][$i], "int"));
$Result1 = mysql_query($insertSQL, $direwolves) or die(mysql_error());
} // end loop
$insertGoTo = "pk_dueslist.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_direwolves, $direwolves);
$query_members = "SELECT * FROM pk_members WHERE member_exempt < 1";
$members = mysql_query($query_members, $direwolves) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
$totalRows_members = mysql_num_rows($members);
?>
Untitled Document
<?php do { ?><?php
if
($row_members['member_level'] < 10) {$dues = 0 ;}
else if
($row_members['member_level'] < 15) {$dues = 2000;}
else if
($row_members['member_level'] < 20) {$dues = 4000;}
else if
($row_members['member_level'] < 25) {$dues = 6000;}
else if
($row_members['member_level'] < 30) {$dues = 8000;}
else {$dues = 10000;}
?>
<?php echo $row_members['member_pkname']; ?> |
ID: |
|
Level: |
|
Date: |
" size="15" maxlength="15" readonly="readonly" /> |
Dues: |
|
|
<?php } while ($row_members = mysql_fetch_assoc($members)); ?>
<?php
mysql_free_result($members);
?>[/php]
My db connection is good, and my page generates 50ish records with a post button, the page forwards to pk_dueslist.php when you hit generate but no records are created and there are no errors displayed. I've tried a few different things from around the internet but this is where I ended up.