skylineview
New Members-
Posts
7 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
skylineview's Achievements
Newbie (1/5)
0
Reputation
-
This is the Error (basically the same as my first posting) Warning: Cannot modify header information - headers already sent by (output started at C:\Webserver\insert.php:1) in C:\Webserver\insert.php on line 59 From what I can understand its basically the same code, just doing something different when the button is pushed. I don't understand why I got the first page working, but I create a new page and it doesn't work.
-
I just don't understand whats going on. There is no whitespace or characters before or after any of my tags. The edit.php page worked GREAT when I resaved the file as a .php type (was .php but not .php type) Now i've created this insert.php file and its giving me the same error, I've tried re-saving, taking out the extra <?php and ?> tags, I don't know what else is wrong. Please help. Thanks.
-
Well I went to create an insert records page, and its doing the same thing. Just like the update records page, I want it to go back to index.php. I am geting the same stupid error again. Here is my code: <?php virtual('/Connections/edit.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; } } mysql_select_db($database_edit, $edit); $query_rs1 = "SELECT * FROM birthday"; $rs1 = mysql_query($query_rs1, $edit) or die(mysql_error()); $row_rs1 = mysql_fetch_assoc($rs1); $totalRows_rs1 = mysql_num_rows($rs1); $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO birthday (id, firstname, lastname, dob) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['id'], "int"), GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['dob'], "text")); mysql_select_db($database_edit, $edit); $Result1 = mysql_query($insertSQL, $edit) or die(mysql_error()); $insertGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Firstname:</td> <td><input type="text" name="firstname" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Lastname:</td> <td><input type="text" name="lastname" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Dob:</td> <td><input type="text" name="dob" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Insert record"></td> </tr> </table> <input type="hidden" name="id" value=""> <input type="hidden" name="MM_insert" value="form1"> </form> <p> </p> </body> </html> <?php mysql_free_result($rs1); ?>
-
OK I have tried everything I could find here and about 40 other sites. I don't understand whats going wrong, I understand the problem, but nothing I can find will do the trick. I continually get the message "Warning: Cannot modify header information - headers already sent by (output started at C:\Webserver\edit.php:1) in C:\Webserver\edit.php on line 55". I'd like the form to redirect back to the index.php page when i click on the update button. So it will update my DB and redirect at the same time. If there is a way for me to take this code and turn it into a "success" type page, that would be perfect too. I've used Dreamweaver CS4 to create this code automatically, using the wizards ( know lame thing to do) But I'm still trying to learn and understand PHP. Can someone please help me find the problem with this code and help me correct it. I've tried moving the header() to the top I've tried the ob_start() tags, I've tried removing the header() completely and I've triple verified there is no white space. I appreciate your help <?php virtual('/Connections/bday.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_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE birthday SET firstname=%s, lastname=%s, dob=%s WHERE id=%s", GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['dob'], "text"), GetSQLValueString($_POST['id'], "int")); @mysql_select_db($database_bday, $bday); $Result1 = mysql_query($updateSQL, $bday) or die(mysql_error()); $updateGoTo = "/index.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_rs1 = "-1"; if (isset($_GET['id'])) { $colname_rs1 = $_GET['id']; } mysql_select_db($database_bday, $bday); $query_rs1 = sprintf("SELECT * FROM birthday WHERE id = %s", GetSQLValueString($colname_rs1, "int")); $rs1 = mysql_query($query_rs1, $bday) or die(mysql_error()); $row_rs1 = mysql_fetch_assoc($rs1); $totalRows_rs1 = mysql_num_rows($rs1); ?> <html> <body> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Firstname:</td> <td><input type="text" name="firstname" value="<?php echo htmlentities($row_rs1['firstname'], ENT_COMPAT, ''); ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Lastname:</td> <td><input type="text" name="lastname" value="<?php echo htmlentities($row_rs1['lastname'], ENT_COMPAT, ''); ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Dob:</td> <td><input type="text" name="dob" value="<?php echo htmlentities($row_rs1['dob'], ENT_COMPAT, ''); ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Update record"></td> </tr> </table> <input type="hidden" name="id" value="<?php echo $row_rs1['id']; ?>"> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="id" value="<?php echo $row_rs1['id']; ?>"> </form> <p> </p> </body> </html> <?php mysql_free_result($rs1); ?>