Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header Redirect 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I thought I did this before and it worked? However gives error:

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\update.php:5) in C:\Program Files\xampp\htdocs\update.php on line 37

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\update.php:5) in C:\Program Files\xampp\htdocs\update.php on line 38

Code removed is only putting/getting variables data
Wanting this page to return to index.php (root/localhost at moment) Thanks

<?
session_start()
?>

<?
$username="";
$password="";
$database="";

mysql_connect(localhost,$username);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM template";
$result=mysql_query($query);

$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
// Bits in here

$i++;
}
mysql_close();


header("Location:../index.php");
header("Connection: close");

?>
 
Use ob_start() before the header() then use ob_end_flush() right after ;)
 
you cannot redirect the page once any output has been sent to the browser.

there is a space between you close tags and open tags which causes this
for a start, change this:
Code:
<?
session_start()
?>

<?
to
Code:
<?
session_start()
 
Thanks again jpadie, another star, now works.
Thanks alsaffar, can you explain that a bit more.
 
I'll leave alsaffar to explain output buffering but my ha'porth:

output buffering just occludes the issue and makes debugging a bit more difficult.

there are of course, good reasons to use output buffering (for example to get the output of an "included" script into a string) but i don't recommend it as a matter of course.
 
Thanks again. Do you know if there is any MS Access to MySql query converters out there, or help on adapting Access type SQL over? Must learn it properley one day, as I cheat and use query grids more than I should. Regards
 
query converter? i don't think so but then again i dont think that anything needs converting other than how to address dates.


i always build compelx mysql queries by using ms access to link to the mysql tables and then using the access query by example, finally converting it into sql and then copy and pasting.
 
Thanks. I did look at linking Access to MySql tables, but for some reason I think I have no ODBC on the pc. It let me select ODBC, went off and never came back again. I am only going to do basic queries, loop through records until ID = a number in a loop, and then insert session variable into designated fields. Might have another go at why Access is not linking. But many thanks for today sorting out the wretched problem I had.
 
no problem.

you will need to have the mysql odbc connector installed, and then to set up the odbc connection in the admin control panel applet.
 
I just downloaded the MySql ODBC driver and installed it.
Where is the admin control panel applet? I went into PhpMyAdmin maybe too quickly. I also went into Access, generated a module hoping I could find something in references to add. ?? Thanks
 
control panel -> administrative tools -> Data Sources
 
Got to that bit okay thanks. Do I have to have a copy of the tables in an Access DB first?. I tried getting external data/Link tables, went into MySql folder/Data/, selected ODBC type files but went nowhere.
 
Stupid me, I did not select configure to give the database name. Will carry on, should get there. Thanks again.
 
process:

1. set up the odbc data link to your mysql tables in the control panel.
2. create a new access database.
3. in access file->external data->linktables
4. change file type to odbc
5. select the odbc connection that you created in item 1. it could be system, user or file depending on what you did above.

personally - i tend to use user dsn's
 
Got there almost. My Access 2003 does not want to know. When I select ODBC files it just does nothing. However I still have my faithfull Access97 available, that works so that should do me for now. Regards
 
Many thanks jpadie for taking the time doing that. All goes well with Access 2003 until I select the dropdown box, ODBC files. It just sits doing nothing. Access 97 does what you describe all the way through so I thought I would use that for now. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top