Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_SESSION shot in the dark 2

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

this one might be obscure.

I have a user form that accepts user input, evaluates it for errors, and if no errors are found, inserts a record into a mysql database. Everything works perfectly on my testing server (apache) but there is a minor glitch on my remote server.

The problem is:
I use session variables to display a summary of the last successfully inserted record. The php script is sent to itself ($_SERVER['PHP_SELF']) and an array ($error) is created. If there are any errors an array element is added and the insert record script is ignored.

The insert record code is as follows

Code:
// wraps entire insert record behavior in a conditional stament based on whether the $error array is empty
if (!$error) {
	if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "residential")) {
	  $insertSQL = sprintf("INSERT INTO residential (user_id, dt_enter, dt_service, cust_id, service_id, address, city, vendor, `zone`, listers, signs, co_listing, co_value, status, instructions, hanger1, hanger2, hanger3, topper, amount, price) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
						   GetSQLValueString($_POST['user_id'], "int"),
						   GetSQLValueString($_POST['dt_enter'], "date"),
						   GetSQLValueString($_POST['dt_service'], "date"),
						   GetSQLValueString($_POST['realtor_id'], "int"),
						   GetSQLValueString($_POST['service_id'], "int"),
						   GetSQLValueString($_POST['address'], "text"),
						   GetSQLValueString($_POST['city'], "int"),
						   GetSQLValueString($_POST['vendor'], "text"),
						   GetSQLValueString($_POST['zone'], "int"),
						   GetSQLValueString($_POST['listers'], "int"),
						   GetSQLValueString($_POST['signs'], "int"),
						   GetSQLValueString($_POST['co_listing'], "int"),
						   GetSQLValueString($_POST['co_value'], "text"),
						   GetSQLValueString($_POST['status'], "int"),
						   GetSQLValueString($_POST['instructions'], "text"),
						   GetSQLValueString($_POST['hanger1'], "text"),
						   GetSQLValueString($_POST['hanger2'], "text"),
						   GetSQLValueString($_POST['hanger3'], "text"),
						   GetSQLValueString($_POST['topper'], "text"),
						   GetSQLValueString($_POST['amount'], "double"),
						   GetSQLValueString($_POST['price'], "double"));
	
	  mysql_select_db($database_regentAdmin, $regentAdmin);
	  $Result1 = mysql_query($insertSQL, $regentAdmin) or die(mysql_error());
	 
	 // assign a session tracking variable when record is inserted
	 $_SESSION['success'] = $Result1;
			
	  $insertGoTo = "comp_submissions.php";
	  if (isset($_SERVER['QUERY_STRING'])) {
		$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
		$insertGoTo .= $_SERVER['QUERY_STRING'];
	  }
	  header(sprintf("Location: %s", $insertGoTo));
	}
	// if the record has been inserted, clear the POST array
	$_POST = array();
}

The page is based on other session variables so i know that the session is set and working. However the
"$_SESSION['success'] = 1;" is not "working"

later in the script i have a refrence to this value
Code:
		// uses the return value of the insert query function to display a success or error message.
		if(isset($_SESSION['success']) && $_SESSION['success'] == 1){
			echo "<p class='success'><strong>The following record was sucessfully submitted:</strong></p><p class='success'>REALTOR: ".$_SESSION['rltr_firstName']." ".$_SESSION['rltr_familyName']."<br />ADDRESS: ".$_SESSION['address']."</p>";
		}elseif(isset($_SESSION['success']) && $_SESSION['success'] != 1){
	 		echo "<p class='success'>Record submission failed.  Please try again.<br />If problem persits, contact the Regent Signs office.</p>";
		}
it is always unset let alone equal to 1(which is, to my understanding, the successful return of the mysql_query function).

Again, this all works perfectly on my testing apache server.

Is there some session varriable setting that might be different on my remote server that i need to adjust for.

 
thank the Lord for that. i was really confused by this one...
 
so far so good, I tired a number of test and they all work, i think we can close the case on this one,

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top