Home > Archive > PHP Programming > May 2004 > PHP Data migration question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
PHP Data migration question
|
|
| OneSolution 2004-05-18, 7:30 pm |
| Hi All,
I found out that I can use the header function to redirect a page. However,
it gives me an error like that:
Warning: Cannot add header information - headers already sent by (output
started at /xxx/xxx/html/xx.php:10) in /xxx/xxx/html/xx.php on line 11
Here's my code:
<?php
$name=$_POST["name"];
$email=$_POST["email"];
$phone=$_POST["phone"];
$xxxx=$_POST["xxxx"];
$currentUserId=$_POST["userid"];
if (($name != "") && ($email != "") && ($phone != "") && ($xxxx!= "")) {
echo "processed $userid";
Header("Location: http://localhost/xxxx/xxxx.asp?id=" . $currentUserId);
}
?>
What I want to do is migrate some data. So my source data is in an MS
access file, and I've found that I can't simply export the data. So I
created a form in ASP that will pull each row from the access db into a
form. The form will auto submit to a PHP. The php will take the submitted
info and save it to the mysql db. Then it will return the user to the
original ASP with the userid that was just processed. The ASP will update
the Access database to show that the row has been saved, and then load the
next row and continue the process.
In ASP, I could say
response.redirect(http://localhost/location.asp?userid=xxx)
When I try this in PHP, it complains with the above error message.
Can anyone help?
Thanks,
Z
| |
| Chris Hope 2004-05-18, 7:30 pm |
| OneSolution wrote:
> I found out that I can use the header function to redirect a page.
> However, it gives me an error like that:
>
> Warning: Cannot add header information - headers already sent by (output
> started at /xxx/xxx/html/xx.php:10) in /xxx/xxx/html/xx.php on line 11
It's because you have written out some info (echo "processed $userid";)
which forms the HTML part of the response, before issuing the redirection.
You cannot do both. Remove or comment out the echo line before the redirect
and it will remove the error message.
If you look at the error you received it actually tells you what the problem
is - "output start at /xxx/xxx/html/xx.php:10" The "10" in this instance is
telling you the line number that output started. This also happens to be
the line number your echo statement is on.
--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
| |
| OneSolution 2004-05-18, 8:30 pm |
| Thanks!!!
I read the error message just fine, but couldn't quite see why it
complained.
But then why does the echo statement complain only in some cases while
working fine in others? This script worked fine for many records, and then
failed and wouldn't budge. Then I removed the echo statement and it works
fine.
"Chris Hope" <chris@electrictoolbox.com> wrote in message
news:1084918973_925@news.athenanews.com...
> OneSolution wrote:
>
>
> It's because you have written out some info (echo "processed $userid";)
> which forms the HTML part of the response, before issuing the redirection.
> You cannot do both. Remove or comment out the echo line before the
redirect
> and it will remove the error message.
>
> If you look at the error you received it actually tells you what the
problem
> is - "output start at /xxx/xxx/html/xx.php:10" The "10" in this instance
is
> telling you the line number that output started. This also happens to be
> the line number your echo statement is on.
>
> --
> Chris Hope
> The Electric Toolbox - http://www.electrictoolbox.com/
>
|
|
|
|
|