Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Not showing next page after successful update

Guest
Oct 09, 2007 Oct 09, 2007

Copy link to clipboard

Copied

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
TOPICS
Server side applications

Views

577
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Oct 10, 2007 Oct 10, 2007
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...

Votes

Translate
LEGEND ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

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">
<!--

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

On Wed, 10 Oct 2007 16:56:27 +0000 (UTC), "davidbarrackphoto"
<webforumsuser@macromedia.com> wrote:

> $replyby = 48;

What's this for? What happens if you delete it?
--
Steve Fleischer
steve at flyingtigerwebdesign dot com
Hong Kong

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

That was a leftover variable that I no longer use. I just saw that as well and deleted it but have the same result. Just for kicks I created a new page to do a simple insert, then added the page navigation into the server behavior and it worked fine. I'm going to play with that test page using different kind of variables and see what happens.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

LATEST
davidbarrackphoto wrote:
> 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?

The "headers already sent" error messages that you showed earlier tell
you what the problem is. Once headers are sent, calls to the header()
function (which performs the redirect) won't work.

This happens when *any* output is sent to the browser before you call
session_start(). Any output includes any whitespace or new lines outside
the PHP tags. You must have had some whitespace in your script before
the session_start() block. By moving the code, you have removed the
whitespace, thereby allowing header() to function correctly.

This is an issue that causes major grief to PHP newcomers, but once you
see "headers already sent", go hunting for the extra whitespace.
Sometimes it lurks at the end of include files.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 10, 2007 Oct 10, 2007

Copy link to clipboard

Copied

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/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines