joecooper Posted May 6, 2008 Share Posted May 6, 2008 if(($trucks*10)<=$money){ //if they can afford it $money=$money-($trucks*10); $result = mysql_query("UPDATE users SET location='{$_GET['newlocation']}' WHERE username='$username'") or die(mysql_error()); $result = mysql_query("UPDATE users SET money='$money' WHERE username='$username'") or die(mysql_error()); header("Location: index.php"); } this will put the data in the MySQL DB but wont redirect the page to index.php afterwards Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/ Share on other sites More sharing options...
947740 Posted May 6, 2008 Share Posted May 6, 2008 1. Is there index.php in the same directory? 2. Do both queries work, or just one? The statement looks fine, so I do not see why it would not work. Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534307 Share on other sites More sharing options...
conker87 Posted May 6, 2008 Share Posted May 6, 2008 Are you outputting anything before this? Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534310 Share on other sites More sharing options...
Dathremar Posted May 6, 2008 Share Posted May 6, 2008 Well try this too: $link_update ="path_to_the_page"; echo "<script language=\"javascript\">"; echo "location.href = \"$link_update\""; echo "</script>"; exit(); It is the same thing actually, but give it a try P.S. and yeah if 1 of the queries fives you an error then the code won't work. Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534311 Share on other sites More sharing options...
joecooper Posted May 6, 2008 Author Share Posted May 6, 2008 index.php is in the same location. i even created another page and put just that in there and still didnt work. the page is a module of the index.php so in index.php theres an include("travel.php"); and in travel.php theres the header script. Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534315 Share on other sites More sharing options...
joecooper Posted May 6, 2008 Author Share Posted May 6, 2008 thanks Dathremar, thats worked perfectly and better! Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534317 Share on other sites More sharing options...
revraz Posted May 6, 2008 Share Posted May 6, 2008 You probably have errors suppressed and you didn't see the Headers already sent error. Link to comment https://forums.phpfreaks.com/topic/104362-header-redirect-not-working/#findComment-534326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.