Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Wierd MySQL error... Please help!
Old 12-17-2005, 12:36 PM Wierd MySQL error... Please help!
Webmaster Talker

Posts: 626
Trades: 0
I have 4 pages:

index.php : which is a list of clients
viewpage.php : which views the client selected on index.php
addinsurance.php : which is the page to add an insurance product
saveinsurance.php : which is the page which saves the data into mysql

PROBLEM:

I can open index.php fine. I select the client I want fine. The viewpage.php opens fine and gets all data from db. I click the addinsurance button and it works fine. I enter in the data for addinsurance and click save. saveinsurance.php saves the data into the db but when I redirect it back to the viewpage, I get "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\blahblah".

I can't figure it out... The first time I open it everything is fine but the second time I get this error??? HELP PLEASE!

here is my code for viewpage.php:
Code:
<html>
<head>
</head>

<body style="font-family:Arial, Helvetica, sans-serif;">
<?php
function listproducts($table, $ClientNumber) {
	$conn2 = mysql_connect('localhost', 'root', 'PW') or die('Connection Failed: '.mysql_error());
	mysql_select_db('Clientbase') or die('Database Error: '.mysql_error());
	$tmp = "";
	
	switch($table){
		case "insurance":
			$sql = "SELECT * FROM $table WHERE ClientNumber=\"$ClientNumber\" ORDER BY 'DateSold', 'FaceAmount', 'Status'";
			break;
		case "mortgages":
			$sql = "SELECT * FROM $table WHERE ClientNumber=\"$ClientNumber\" ORDER BY 'DateSold', 'Amount', 'Status'";
			break;
		case "mutualfunds":
			$sql = "SELECT * FROM $table WHERE ClientNumber=\"$ClientNumber\" ORDER BY 'AccountNumber', 'Type'";
			break;
		case "todo":
			$sql = "SELECT * FROM $table WHERE ClientNumber=\"$ClientNumber\" ORDER BY 'DueDate', 'Type'";
			break;
		case "notes":
			$sql = "SELECT * FROM $table WHERE ClientNumber=\"$ClientNumber\" ORDER BY 'Date', 'Time'";
			break;		
	}
	$results = mysql_query($sql, $conn2);
	
	switch($table) {
		case "insurance" :
			if(mysql_num_rows($results) > 0) {
			$tmp =<<< LISTPRODUCT
				<table cellspacing="0" cellpadding="0" valign="top" style="width:100%; font-size:12px;">
					<tr valign="top" style="height:12px; background-color:#CCCCCC;">
						<td align="center" style="width:13%;padding:0px 5px 0px 5px;">Date Sold</td>
						<td align="left" style="width:15%;padding:0px 5px 0px 5px;">Policy No.</td>
						<td align="left" style="width:22%;padding:0px 5px 0px 5px;">Company</td>
						<td align="center" style="width:10%;padding:0px 5px 0px 5px;">Type</td>
						<td align="right" style="width:15%;padding:0px 5px 0px 5px;">Face Amount</td>
						<td align="right" style="width:10%;padding:0px 5px 0px 5px;">Premium</td>
						<td align="right" style="width:10%;padding:0px 5px 0px 5px;">Status</td>
					</tr>
LISTPRODUCT;
		
				while($Data = mysql_fetch_array($results)) {
					extract($Data) or die(mysql_error());
					$CompanyName = substr($CompanyName, 0, 20);
					
					$tmp .=<<< LISTPRODUCT
					<tr valign="top" style="height:12px; ">
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$DateSold</td>
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$AccountNumber</td>
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$CompanyName</td>
						<td align="center" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$PolicyType</td>
						<td align="right" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$FaceAmount</td>
						<td align="right" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$PmtAmount</td>
						<td align="right" style="padding:0px 5px 0px 5px;">$PolicyStatus</td>
					</tr>
LISTPRODUCT;
				}
				$tmp .= "</table>";
			} else {
				$tmp = "<center style=\"color:#000033;\"><b>- No Insurance Products -</b></center>";
			}
			break;
		case "mortgages":
			if(mysql_num_rows($results) > 0) {
			$tmp =<<< LISTPRODUCT
				<table cellspacing="0" cellpadding="0" style="width:100%; font-size:12px;">
					<tr style="background-color:#CCCCCC;">
						<th style="width:13%;">Closing Date</th>
						<th style="width:15%">Mortgage No.</th>
						<th style="width:22%">Company</th>
						<th style="width:10%">Type</th>
						<th style="width:15%">Amount</th>
						<th style="width:10%">Payment</th>
						<th style="width:10%">Status</th>
					</tr>
LISTPRODUCT;
		
				while($Data = mysql_fetch_array($results)) {
					extract($Data) or die(mysql_error());
					$CompanyName = substr($CompanyName, 0, 20);
			
					$tmp .=<<< LISTPRODUCT
					<tr>
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$ClosingDate</td>
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$MortgageNumber</td>
						<td style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$CompanyName</td>
						<td align="center" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$Type</td>
						<td align="right" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$Amount</td>
						<td align="right" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$PmtAmount</td>
						<td align="center" style="padding:0px 5px 0px 5px;">$Status</td>
					</tr>
LISTPRODUCT;
				}
				$tmp .= "</table>";
			} else {
				$tmp = "<center style=\"color:#000033;\"><b>- No Mortgages -</b></center>";
			}
			break;
		case "mutualfunds":
			if(mysql_num_rows($results) > 0) {
			$tmp =<<< LISTPRODUCT
				<table cols="5" cellspacing="0" cellpadding="0" style="width:100%; font-size:12px;">
					<tr style="background-color:#CCCCCC;">
						<th style="width:10%">Type</th>
						<th style="width:15%">Account No.</th>
						<th style="width:50%">Fund Name</th>
						<th style="width:15%">Code</th>
						<th style="width:10%">Target %</th>
					</tr>
LISTPRODUCT;
		
				while($Data = mysql_fetch_array($results)) {
					extract($Data) or die(mysql_error());
			
					$tmp .=<<< LISTPRODUCT
					<tr>
						<td align="left" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$AccountType</td>
						<td align="center" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$AccountNumber</td>
						<td align="left" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$FundName</td>
						<td align="left" style="padding:0px 5px 0px 5px; border-right:1px solid #CCCCCC;">$FundCode</td>
						<td align="right" style="padding:0px 5px 0px 5px;">$TargetAllocation %</td>
					</tr>
LISTPRODUCT;
				}
				$tmp .= "</table>";
			} else {
				$tmp = "<center style=\"color:#000033;\"><b>- No Mutual Funds -</b></center>";
			}
			break;
		case "notes":
			if(mysql_num_rows($results) > 0) {
			$tmp =<<< LISTPRODUCT
				<table cellspacing="0" cellpadding="0" style="width:100%; font-size:12px; border-bottom:1px solid #FF6600;">
LISTPRODUCT;
		
				while($Data = mysql_fetch_array($results)) {
					extract($Data) or die(mysql_error());
			
					$tmp .=<<< LISTPRODUCT
					<tr>
						<td style="color:#FF9900; border:1px solid #FF6600;">
							<b style="color:#000033">$Date - $ContactType</b><br>
							<b style="color:#A0A0A0;"><i>$Subject:</b> &nbsp;$Notes</i>
						</td>
					</tr>
LISTPRODUCT;
				}
				$tmp .= "</table>";
			} else {
				$tmp = "<center style=\"color:#000033;\"><b>- No Notes -</b></center>";
			}
			break;
		case "todo":
			if(mysql_num_rows($results) > 0) {
			$tmp =<<< LISTPRODUCT
				<table cellspacing="0" cellpadding="0" style="width:100%; font-size:12px;">
LISTPRODUCT;
		
				while($Data = mysql_fetch_array($results)) {
					extract($Data) or die(mysql_error());
			
					$tmp .=<<< LISTPRODUCT
					<tr style="color:#000033;">
						<td><b>$DueDate @ $Time - $Type: $Status</b><br>
					</tr>
					<tr>
						<td style="color:#FFCC00;">
							$Comments
						</td>
					</tr>
LISTPRODUCT;
				}
				$tmp .= "</table>";
			} else {
				$tmp = "<center style=\"color:#000033;\"><b>- No Tasks -</b></center>";
			}
			break;
	} // end of switch for tables
		
	return $tmp;
	mysql_close($conn2);
}
	extract($_POST);
	
	$Referrer = $_SERVER['PHP_SELF'];
	$conn = mysql_connect('localhost', 'root', 'PW') or die('Connection Failed: '.mysql_error());
	mysql_select_db('Clientbase') or die('Database Error: '.mysql_error());
	$sql = "SELECT * FROM Clientbase WHERE ClientNumber=$ClientNumber";
	$results = mysql_query($sql, $conn);
	$Data = mysql_fetch_array($results);
	extract($Data) or die(mysql_error());
	
	$drvstr = "Driver's License";
	$BirthYear = substr($DOB,0,4);
	$BirthMonth = substr($DOB,5,2);
	$BirthDay = substr($DOB,8,2);
	$InsuranceList = listproducts('insurance', $ClientNumber);
	$MortgageList = listproducts('mortgages', $ClientNumber);
	$MutualFundList = listproducts('mutualfunds', $ClientNumber);
	$todoList = listproducts('todo', $ClientNumber);
	$Notes = listproducts('notes', $ClientNumber);

	switch($BirthMonth) {
		case "01": $BirthMonth = "January"; break;
		case "02": $BirthMonth = "February"; break;
		case "03": $BirthMonth = "March"; break;
		case "04": $BirthMonth = "April"; break;
		case "05": $BirthMonth = "May"; break;
		case "06": $BirthMonth = "June"; break;
		case "07": $BirthMonth = "July"; break;
		case "08": $BirthMonth = "August"; break;
		case "09": $BirthMonth = "September"; break;
		case "10": $BirthMonth = "October"; break;
		case "11": $BirthMonth = "November"; break;
		case "12": $BirthMonth = "December"; break;
	}
	
	if(substr($BirthDay,0,1) == "0") { $BirthDay = substr($BirthDay,1,1); }
	
	switch($PrimaryContact) {
		case "0": $PrimaryContact = "No"; $MailingName = "&nbsp;"; break;
		case "1": $PrimaryContact = "Yes"; $MailingName = "<b>Mailing Name:</b> &nbsp;".$MailingName; break;
	}

	switch($Smoker) {
		case "0": $Smoker = "No"; break;
		case "1": $Smoker = "Yes"; break;
	}
	
	if($HomePhone <> NULL) { $HomePhone = substr($HomePhone,0,3).'-'.substr($HomePhone, 3, 3).'-'.substr($HomePhone, 6, 4);}
	if($CellPhone <> NULL) { $CellPhone = substr($CellPhone,0,3).'-'.substr($CellPhone, 3, 3).'-'.substr($CellPhone, 6, 4);}
	if($WorkPhone <> NULL) { $WorkPhone = substr($WorkPhone,0,3).'-'.substr($WorkPhone, 3, 3).'-'.substr($WorkPhone, 6, 4);}
	if($WorkExt <> NULL) { $WorkExt = "x ".$WorkExt; }
	if($WorkFax <> NULL) { $WorkPhone = substr($WorkPhone,0,3).'-'.substr($WorkPhone, 3, 3).'-'.substr($WorkPhone, 6, 4);}		
	if($SIN <> NULL) { $SIN = substr($SIN, 0, 3).'-'.substr($SIN,3,3).'-'.substr($SIN,6,3); }
	if($HomePostal <> NULL) { $HomePostal = substr($HomePostal, 0, 3).' '.substr($HomePostal, 3, 3); }
	if($WorkPostal <> NULL) { $WorkPostal = substr($WorkPostal, 0, 3).' '.substr($WorkPostal, 3, 3); }


	$viewpage =<<< VIEWPAGE
		<table cellspacing="0" cellpadding="0" style="width:975px; height:595px; font-size:12px;">
			<tr>
				<td valign="top" style="width:600px; border:1px solid #ADD6D6;">
					<table cellspacing="0" cellpadding="0" style="width:600px; font-size:12px;">
						<tr>
							<td style="width:70%; background-color:#ADD6D6;">
								<b>$Title $FirstName $MiddleName $LastName ($GreetingName)</b>
							</td>
							<td align="right" style="width:30%; background-color:#ADD6D6;">
								<b>Client Number:</b> &nbsp;&nbsp;&nbsp;&nbsp;$ClientNumber
							</td>
						</tr>
						<tr>
						<td colspan="2" style="border:1px solid #ADD6D6; height:20px; padding:10px 0px 0px 0px;">
							<table cols="10" cellspacing="0" cellpadding="0" style="width:100%; font-size:12px; padding:0px 10px 0px 10px;">
								<tr>
									<td colspan="3" style="width:30%;">
										<b>Primary Contact:</b> &nbsp;$PrimaryContact
									</td>
									<td colspan="7" align="right" style="width:70%;">
										$MailingName
									</td>
								</tr>
								<tr>
									<td colspan="3" nowrap style="width:30%;">
										<b>Birthday:</b> &nbsp;&nbsp; $BirthMonth $BirthDay, $BirthYear
									</td>
			
									<td colspan="3" style="width:30%;">
										<b>SIN:</b> &nbsp;&nbsp;$SIN
									</td>
									<td colspan="4" style="width:40%;">
										<b>ID Type:</b> &nbsp;$IDType
									</td>
								</tr>
								<tr style="padding-bottom:10px">
									<td colspan="5" style="width:50%;">
										<b>ID Number:</b> &nbsp;$IDNumber
									</td>
									<td align="right" colspan="5" style="width=50%;">
										<b>Smoker:</b> &nbsp;$Smoker
									</td>
								</tr>
								<tr>
									<td colspan="10" align="center" style="width:100%; background-color:#ADD6D6;">
										<b>Home Address</b>
									</td>
								</tr>
								<tr style="padding-top:10px;">
									<td colspan="10" align="left" style="width:100%;">
										<b>Address 1:</b> &nbsp;&nbsp;$HomeAddress1
									</td>
								</tr>
								<tr>
									<td colspan="10" align="left" style="width:100%;">
										<b>Address 2:</b> &nbsp;&nbsp;$HomeAddress2
									</td>
								</tr>
								<tr>
									<td colspan="4" align="left" style="width:40%;">
										<b>City:</b> &nbsp;$HomeCity
									</td>
									<td colspan="2" align="left" style="width:20%;">
										<b>Province:</b> &nbsp;$HomeProv
									</td>
									<td colspan="4" align="left" style="width:40%;">
										<b>Postal Code:</b> &nbsp;$HomePostal
									</td>
								</tr>
								<tr>
									<td colspan="5" align="left" style="width:50%;">
										<b>Phone:</b> &nbsp;$HomePhone
									</td>
									<td colspan="5" align="left" style="width:50%;">
										<b>Cell:</b> &nbsp;$CellPhone
									</td>
								</tr>
								<tr style="padding-bottom:10px;">
									<td colspan="10" align="left" style="width:100%;">
										<b>Email:</b> &nbsp;$Email
									</td>
								</tr>
								<tr>
									<td colspan="10" align="center" style="width:100%; background-color:#ADD6D6;">
										<b>Work Information</b>
									</td>
								</tr>
								<tr style="padding-top:10px;">
									<td colspan="5" align="left" style="width:50%;">
										<b>Employer:</b> &nbsp;$Employer
									</td>
									<td colspan="5" align="left" style="width:50%;">
										<b>Occupation:</b> &nbsp;$Occupation
									</td>
								</tr>
								<tr>
									<td colspan="10" align="left" style="width:100%;">
										<b>Address 1:</b> &nbsp;&nbsp;$WorkAddress1
									</td>
								</tr>
								<tr>
									<td colspan="10" align="left" style="width:100%;">
										<b>Address 2:</b> &nbsp;&nbsp;$WorkAddress2
									</td>
								</tr>
								<tr>
									<td colspan="4" align="left" style="width:40%;">
										<b>City:</b> &nbsp;$WorkCity
									</td>
									<td colspan="2" align="left" style="width:20%;">
										<b>Province:</b> &nbsp;$WorkProv
									</td>
									<td colspan="4" align="left" style="width:40%;">
										<b>Postal Code:</b> &nbsp;$WorkPostal
									</td>
								</tr>										
								<tr>
									<td colspan="5" align="left" style="width:50%;">
										<b>Phone:</b> &nbsp;$WorkPhone $WorkExt
									</td>
									<td colspan="5" align="left" style="width:50%;">
										<b>Fax:</b> &nbsp;$WorkFax
									</td>
								</tr>
								<tr style="padding-bottom:10px;">
									<td colspan="10" align="left" style="width:100%;">
										<b>Income:</b> &nbsp;$Income
									</td>
								</tr>
								<tr style="background-color:#000033; color:white;">
									<td colspan="10" align="Center" style="width:100%;">
										<b>Insurance Products</b>
									</td>
								</tr>
								<tr>
									<td colspan="10" align="Center" valign="top" style="width:100%; padding:0px;">
										<div style="height:70px; width:100%; overflow-y:scroll;">
											$InsuranceList
										</div>
									</td>
								</tr>
								<tr style="background-color:#000033; color:white;">
									<td colspan="10" align="Center" style="width:100%;">
										<b>Mortgage(s)</b>
									</td>
								</tr>
								<tr>
									<td colspan="10" align="Center" style="width:100%; padding:0px;">
										<div style="height:70px; width:100%; overflow-y:scroll;">
											$MortgageList
										</div>
									</td>
								</tr>
								<tr style="background-color:#000033; color:white;">
									<td colspan="10" align="Center" style="width:100%;">
										<b>Target Portfolio Allocation</b>
									</td>
								</tr>
								<tr>
									<td colspan="10" align="Center" style="width:100%; padding:0px;">
										<div style="height:93px; width:100%; overflow-y:scroll;">
											$MutualFundList
										</div>
									</td>
								</tr>
								
			<!-- -->
							</table>
							</td>
						</tr>
					</table>
				</td>
<!--				// Starting the right side of page.       -->
				<td valign="top" style="width:375px; height:595px; border:1px solid #ADD6D6">
					<table cellspacing="0" cellpadding="0" style="font-size:12px; width:100%; height:595px; border:1px solid #505050;">
						<tr>
							<td align="center" style="width:100%; height:15px; background-color:#A0A0A0;">
								<b>To-Do List</b>
							</td>
						</tr>
						<tr valign="top">
							<td style="width:100%;">
								<div style="height:198px; overflow-y:scroll;">
									$todoList
								</div>
							</td>
						</tr>
						<tr>
							<td align="center" style="width:100%; height:15px; background-color:#A0A0A0;">
								<b>Notes</b>
							</td>
						</tr>
						<tr valign="top">
							<td style="width:100%;">
								<div style="height:285px; overflow-y:scroll;">
									$Notes
								</div>
							</td>
						</tr>
						<tr valign="middle">
							<td style="width:100%; height:80px; border:1px solid #A0A0A0; padding:10px; background-color:#ADA6D6;">
								<form name="EditClient" action="edit.php" method="post" style="display:inline; margin:0px;">
									<input type="hidden" name="ClientNumber" value="$ClientNumber">
									<input type="submit" value="Edit Client" style="font-size:12px;">
								</form>
								<form name="viewing" action="addinsurance.php" method="post" style="display:inline; margin:0px; ">
									<input type="hidden" name="Referrer" value="$Referrer">
									<input type="hidden" name="FirstName" value="$FirstName">
									<input type="hidden" name="MiddleName" value="$MiddleName">
									<input type="hidden" name="LastName" value="$LastName">
									<input type="hidden" name="GreetingName" value="$GreetingName">
									<input type="hidden" name="ClientNumber" value="$ClientNumber">
									<input type="submit" value="Add Insurance" style="font-size:12px;">
								</form>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
VIEWPAGE;

	echo $viewpage;
?>
</body></html>
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-17-2005, 04:47 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
I'm assuming, since that code is a bit hard to read, that when a user selects a client on the index page this client information is then passed to the viewpage page? If so, is your viewpage page dependent on this information? If so, are you passing this information back when you redirect back to viewpage.php from the end of the process?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-17-2005, 05:15 PM
Webmaster Talker

Posts: 626
Trades: 0
Actually, the only information that is passed the the viewpage is the ClientNumber. When the viewpage is opened, it runs a query WHERE ClientNumber=$_POST['ClientNumber'].

When going back to the viewpage (at the end of the process I am passing the ClientNumber as well.

Here is the code for saveinsurance.php:
Code:
<?php
	$conn = mysql_connect('localhost', 'root', 'PW') or die(mysql_error());
	mysql_select_db("Clientbase") or die(mysql_error());

	extract($_POST);
	
	// put all string variable and varchar's in single quotes
	$ClientNumber == NULL ? $ClientNumber = "NULL" : $ClientNumber = "'$ClientNumber'";
	$AccountNumber == NULL ? $AccountNumber = "NULL" : $AccountNumber = "'$AccountNumber'";
	$CompanyName == NULL ? $CompanyName = "NULL" : $CompanyName = "'$CompanyName'";
	$PolicyType == NULL ? $PolicyType = "NULL" : $PolicyType = "'$PolicyType'";
	$PolicyStatus == NULL ? $PolicyStatus = "NULL" : $PolicyStatus = "'$PolicyStatus'";
	$FaceAmount == NULL ? $FaceAmount = "NULL" : $FaceAmount = "'$FaceAmount'";
	$PmtAmount == NULL ? $PmtAmount = "NULL" : $PmtAmount = "'$PmtAmount'";
	$PmtFreq == NULL ? $PmtFreq = "NULL" : $PmtFreq = "'$PmtFreq'";
	$HealthStatus == NULL ? $HealthStatus = "NULL" : $HealthStatus = "'$HealthStatus'";
	$CTRAmt == NULL ? $CTRAmt = "NULL" : $CTRAmt = "'$CTRAmt'";
	$GIOAmt == NULL ? $GIOAmt = "NULL" : $GIOAmt = "'$GIOAmt'";
	$SpousalAmt == NULL ? $SpousalAmt = "NULL" : $SpousalAmt = "'$SpousalAmt'";
	$CIAmt == NULL ? $CIAmt = "NULL" : $CIAmt = "'$CIAmt'";


	$DateSold = "'"."$YearSold-$MonthSold-$DaySold"."'";
	$IssueDate = "'"."$IssueYear-$IssueMonth-$IssueDay"."'";
	$RenewalDate = "'"."$RenewalYear-$RenewalMonth-$RenewalDay"."'";
	
	//  find out if the checkboxes from the preceeding form were check or left blank and format
	//  to mysql format.
	if (!array_key_exists('WP', $_POST)) { $WP = 0;} else {$WP = 1; }
	if (!array_key_exists('ROP', $_POST)) { $ROP = 0;} else {$ROP = 1;}
	if (!array_key_exists('ROPS', $_POST)) {$ROPS = 0; } else {$ROPS = 1;}
	if (!array_key_exists('CTR', $_POST)) { $CTR = 0; } else { $CTR = 1;}
	if (!array_key_exists('GIO',$_POST)) { $GIO = 0; } else {$GIO = 1;}
	if (!array_key_exists('Spousal', $_POST)) { $Spousal = 0; } else {$Spousal = 1;}
	if (!array_key_exists('CI', $_POST)) { $CI = 0; } else {$CI = 1;}
	if (!array_key_exists('Editing', $_POST)) {$Editing = "NO"; $ID = "NULL";} else {$Editing = "YES";}

//  working on sql statement - need to exclude all NULL values (columns too).
	if ($Editing == "YES") {
		$sql = "REPLACE INTO insurance (ID, ClientNumber, DateSold, AccountNumber, CompanyName, PolicyType, PolicyStatus, FaceAmount, PmtAmount, PmtFreq, IssueDate, RenewalDate, WP, ROP, ROPS, CTR, CTRAmt, GIO, GIOAmt, CI, CIAmt, Spousal, SpousalAmt, HealthStatus)
			VALUES ($ID, $ClientNumber, $DateSold, $AccountNumber, $CompanyName, $PolicyType, $PolicyStatus, $FaceAmount, $PmtAmount, $PmtFreq, $IssueDate, $RenewalDate, $WP, $ROP, $ROPS, $CTR, $CTRAmt, $GIO, $GIOAmt, $CI, $CIAmt, $Spousal, $SpousalAmt, $HealthStatus)";
	} else {
		$sql = "INSERT INTO insurance (ID, ClientNumber, DateSold, AccountNumber, CompanyName, PolicyType, PolicyStatus, FaceAmount, PmtAmount, PmtFreq, IssueDate, RenewalDate, WP, ROP, ROPS, CTR, CTRAmt, GIO, GIOAmt, CI, CIAmt, Spousal, SpousalAmt, HealthStatus)
			VALUES ($ID, $ClientNumber, $DateSold, $AccountNumber, $CompanyName, $PolicyType, $PolicyStatus, $FaceAmount, $PmtAmount, $PmtFreq, $IssueDate, $RenewalDate, $WP, $ROP, $ROPS, $CTR, $CTRAmt, $GIO, $GIOAmt, $CI, $CIAmt, $Spousal, $SpousalAmt, $HealthStatus)";
	}	

	mysql_query($sql) or die(mysql_error());
	mysql_close($conn);

	echo <<<SHOWFORM
		<form name="redirect" action="$Referrer" method="post">
			<input type="hidden" name="ClientNumber" value="$ClientNumber">
		</form>
		<script type="text/javascript" language="javascript">
			document.redirect.submit();
		</script>
SHOWFORM;
?>
PS - Why is the code hard to read? Am I doing something wrong?

Last edited by jim.thornton; 12-17-2005 at 05:19 PM..
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 12-19-2005, 01:44 PM
Novice Talker

Posts: 12
Trades: 0
You're not doing wrong. No offence but you way of coding is obsolete. Try to use OOP instead. My intention is to give advice to be a better programmer not for offensive purposes. Please ignore if you dont want my advice.

regards........
bnet is offline
Reply With Quote
View Public Profile
 
Old 12-19-2005, 11:24 PM
Webmaster Talker

Posts: 626
Trades: 0
I am always looking to improve... If you could show me how to convert that code to OOP that would be great. Or, can you send me to any good tutorials?
jim.thornton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Wierd MySQL error... Please help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28418 seconds with 12 queries