IrishKnights Posted October 10, 2008 Share Posted October 10, 2008 <? include_once("db.info.inc.php"); mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname) or die( "Unable to select database"); $query="INSERT INTO search (topic, memo) VALUES('$topic', '$notes')"; mysql_query($query); mysql_close(); header("Location: addtopic.php"); exit; ?> What is wrong with this code, it doesn't goto the header. Link to comment https://forums.phpfreaks.com/topic/127854-header-location/ Share on other sites More sharing options...
micmania1 Posted October 10, 2008 Share Posted October 10, 2008 Can you please give more detail? By "Doesn't go to the header" do you mean the url doesn't show that its on the correct page when it actually is, or that there is a php error? Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-661906 Share on other sites More sharing options...
JasonLewis Posted October 11, 2008 Share Posted October 11, 2008 Don't use short-tags, they are not recommend. Also turn on error reporting, if it isn't going anywhere maybe something is happening somewhere. <?php error_reporting(E_ALL); include_once("db.info.inc.php"); mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname) or die( "Unable to select database"); $query="INSERT INTO search (topic, memo) VALUES('$topic', '$notes')"; mysql_query($query); mysql_close(); header("Location: addtopic.php"); exit; ?> Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-662608 Share on other sites More sharing options...
waynew Posted October 11, 2008 Share Posted October 11, 2008 <? include_once("db.info.inc.php"); error_reporting(E_ALL); mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname) or die( "Unable to select database"); $query="INSERT INTO search (topic, memo) VALUES('$topic', '$notes')"; mysql_query($query); mysql_close(); header("Location: addtopic.php"); exit; ?> Try that and see if you've got any errors. Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-662630 Share on other sites More sharing options...
IrishKnights Posted October 13, 2008 Author Share Posted October 13, 2008 Warning: Cannot modify header information - headers already sent by (output started at /home/irishknights.co.za/public_html/ss/private/db.info.inc.php:6) in /home/irishknights.co.za/public_html/ss/private/addtopic_func.php on line 11 This is the error I get which is: header("Location: addtopic.php"); and line 6 is: ?> Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-663770 Share on other sites More sharing options...
Zane Posted October 13, 2008 Share Posted October 13, 2008 the error is in the db include file Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-663772 Share on other sites More sharing options...
budimir Posted October 13, 2008 Share Posted October 13, 2008 You are getting output in your db.info.inc file and then header is failing and reporting an error message. Link to comment https://forums.phpfreaks.com/topic/127854-header-location/#findComment-663798 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.