Skip to main content
October 10, 2007
Answered

Not showing next page after successful update

  • October 10, 2007
  • 2 replies
  • 622 views
I have a page with 2 forms, one for update and one for insert. For the update I have the insert behavior show the next page after the insert however the insert is happening but the next page does not appear. I have validated repeatedly that the insert occurs. Any ideas on how I can figure out why DW is not displaying the next page that I've indicated in the server behavior? Could it be that the MySQL return code is not "OK" even though the insert was successful?

OSX 10.4.10 on MacTel, PHP, MySQL 5.0.41, DW CS3
This topic has been closed for replies.
Correct answer
Hi Steve,

It appears this has something to do with using a session variable. On a new, clean page I tried a simple insert and move to a new page and it worked with no problem. As soon as I changed the page so that the insert was using a session variable I got the same warning and the navigation to the next page did not work.

I'm not sure what the issue is, or why it's a problem to use session variables to populate field in a server behavior.

Whelp, it looks like I found the culprit here although I have NO idea why this caused the problem. Initially I always had the session_start() code at the very top of the page. I manually add it to each page that uses session variables since I see no way to have DW insert that code when creating a page. I moved that code below <?php require_once('Connections/NadolneWebDev.php'); ?> and it worked fine. Can someone enlighten my ignorance here? I'd like to learn from the mistake instead of trying to keep getting lucky.

<?php require_once('Connections/NadolneWebDev.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php

2 replies

Inspiring
October 10, 2007
Steve Fleischer wrote:
> Can we see the code in question, please.

Seeing the code would definitely help, but there's one other
possibility: are you using temporary files for Preview in Browser?

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Inspiring
October 10, 2007
On Wed, 10 Oct 2007 05:33:55 +0000 (UTC), "davidbarrackphoto"
<webforumsuser@macromedia.com> wrote:

>I have a page with 2 forms, one for update and one for insert. For the update
>I have the insert behavior show the next page after the insert however the
>insert is happening but the next page does not appear. I have validated
>repeatedly that the insert occurs. Any ideas on how I can figure out why DW is
>not displaying the next page that I've indicated in the server behavior? Could
>it be that the MySQL return code is not "OK" even though the insert was
>successful?
>
> OSX 10.4.10 on MacTel, PHP, MySQL 5.0.41, DW CS3

Can we see the code in question, please.
--
Steve Fleischer
steve at flyingtigerwebdesign dot com
Hong Kong
October 10, 2007
Thank you for the help. Here's the code. I get the warning: Cannot modify header information - headers already sent by (output started at /Users/davidbarrack/Sites/NadolneWeb/CreatePatientConversation.php:6) in /Users/davidbarrack/Sites/NadolneWeb/CreatePatientConversation.php on line 63
Line 63 is the following: header(sprintf("Location: %s", $insertGoTo));

I had to rip out the last half of the code because of the 10K limit on the forum page but hope that this code reveals the problem to you.



<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php require_once('Connections/NadolneWebDev.php'); ?>
<?php
$replyby = 48;
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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "CreateConversation")) {
$insertSQL = sprintf("INSERT INTO Conversation (username, createdatetime, topic, patientinquestion, message, replyrequestby, reasonforurgency, status_change, notemergency) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['hiddenusername'], "text"),
GetSQLValueString($_POST['hiddencurrentdatetime'], "date"),
GetSQLValueString($_POST['topic'], "text"),
GetSQLValueString($_POST['patientinquestion'], "text"),
GetSQLValueString($_POST['message'], "text"),
GetSQLValueString($_POST['replyby'], "date"),
GetSQLValueString($_POST['reasonforurgency'], "text"),
GetSQLValueString($_POST['hiddencurrentdatetime'], "date"),
GetSQLValueString(isset($_POST['reasonforurgency']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_NadolneWebDev, $NadolneWebDev);
$Result1 = mysql_query($insertSQL, $NadolneWebDev) or die(mysql_error());
$insertGoTo = "PatientLanding.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$colname_rsGetName = "-1";
if (isset($_SESSION['username'])) {
$colname_rsGetName = (get_magic_quotes_gpc()) ? $_SESSION['username'] : addslashes($_SESSION['username']);
}
mysql_select_db($database_NadolneWebDev, $NadolneWebDev);
$query_rsGetName = sprintf("SELECT logintype, status, firstname, lastname FROM AccountInfo WHERE username = %s", GetSQLValueString($colname_rsGetName, "text"));
$rsGetName = mysql_query($query_rsGetName, $NadolneWebDev) or die(mysql_error());
$row_rsGetName = mysql_fetch_assoc($rsGetName);
$totalRows_rsGetName = mysql_num_rows($rsGetName);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Admin.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>1 Column Fixed, Centered</title>
<!-- InstanceEndEditable -->
<style type="text/css" media="all">
<!--