Forum Moderators: coopster

Message Too Old, No Replies

Error on updating

Cannot modify header information error

         

JSoaper

12:51 pm on Feb 9, 2009 (gmt 0)

10+ Year Member



I keep getting this error when I try update?

Warning: Cannot modify header information - headers already sent by (output started at /home/powerman/public_html/aaa/update.php:2) in /home/powerman/public_html/aaa/update.php on line 22

The two files being used are:
=============================
update.php
=============================

<?
// START PHP CODES. THIS PART MUST ON THE TOP OF THIS PAGE.

// Connect database.
include("config.php");

// ***** This part will process when you Click on "Submit" button *****
// Check, if you clicked "Submit" button
if($_POST['Submit']){

// Get parameters from form.
$id=$_POST['id'];
$Account=$_POST['Account'];
$Client=$_POST['Client'];
$Telephone=$_POST['Telephone'];

// Do update statement.
mysql_query("update client set Account='$Account', Client='$Client', Telephone='$Telephone' where id='$id'");

// Re-direct this page to select.php.
header("location:select.php");
exit;
}
// ************* End update part *************

// *** Select data to show on text fields in form. ***

// Get id parameter (GET method) from select.php
$id=$_GET['id'];

// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("select * from clients where id='$id'");

// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);

// Close database connection.
mysql_close();
?>

<!-- END OF PHP CODES AND START HTML TAGS -->

<html>
<body style="font-family: tahoma; font-size: 8pt">
<!-- set this form to POST method and target this form to itself ($PHP_SELF;)-->
<form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>">
<p>Name :
<!-- name of this text field is "name" -->
<input name="Client" type="text" id="name" value="<? echo $row['Client']; ?>"/>
<br />
Email :
<!-- name of this text field is "email" -->
<input name="Account" type="text" id="email" value="<? echo $row['Account']; ?>"/>
<br />
Tel :
<!-- name of this text field is "tel" -->
<input name="Telephone" type="text" id="tel" value="<? echo $row['Telephone']; ?>"/>
</p>
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</body>
</html>

============================================
and
config.php
============================================
<?
// Connection codes with database selection.
$dbhost="localhost";
$dbuname="username";
$dbpass="password";

mysql_connect($dbhost,$dbuname,$dbpass);
mysql_select_db("databse_name"); // select database

// You can put or die(); after mysql_connect() and mysql_select_db()

?>

Any help greatly appreciated

[edited by: eelixduppy at 6:59 pm (utc) on Feb. 9, 2009]
[edit reason] disabled smileys [/edit]

STeeL

1:25 pm on Feb 9, 2009 (gmt 0)

10+ Year Member



Make sure you don't have any empty space characters before <? tag in update.php file and no empty space before <? tag or after ?> tag in config.php.

[edited by: STeeL at 1:26 pm (utc) on Feb. 9, 2009]

whoisgregg

2:47 pm on Feb 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One "trick" to make sure you never have extra white space after your last closing "?>" is to simply omit it. The PHP parser automagically adds one in if one doesn't exist.

Of course, you can't skip closing "?>" between html blocks but it's a handy trick on include files (like your config.php).

JSoaper

7:05 am on Feb 10, 2009 (gmt 0)

10+ Year Member



Thanks for ther help... now working.