imarockstar Posted May 7, 2008 Share Posted May 7, 2008 im trying to redirect my page after some database updates .. here is the link: http://dfwdrives.com/ after you click on a tag you go here : http://dfwdrives.com/out.php here is the code thats NOT working ... any help would be rad !!! (everything works fine except the redirect) im running php 5 <? $getcount = mysql_query("SELECT * FROM cloud where tag='$_GET[tag]'"); $result = mysql_query($query); while ($result=mysql_fetch_array($getcount)){ $new_count = ($result[count] + 1); //adds one to the number from num_votes column $addy = "http://www.yahoo.com"; $update_rating = mysql_query("UPDATE the_cloud SET count='$new_count' where tag='$_GET[tag]'"); //this updates the specific row in the database that is concerned. Change the table name to fit yours. } header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/ Share on other sites More sharing options...
smartin1017 Posted May 7, 2008 Share Posted May 7, 2008 Try this... header('Location:http://www.example.com/'); I am pretty sure you need to use single quotes inside the () Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534920 Share on other sites More sharing options...
imarockstar Posted May 7, 2008 Author Share Posted May 7, 2008 nope lol .. that was not it ... Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534944 Share on other sites More sharing options...
benphp Posted May 7, 2008 Share Posted May 7, 2008 Is that your entire script? Are you using print or echo anywhere? That will foul things up. Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534947 Share on other sites More sharing options...
imarockstar Posted May 7, 2008 Author Share Posted May 7, 2008 thats the entire script ... for out.php no print and no echo ... it just updates the DB then neads to redirect .. Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534951 Share on other sites More sharing options...
realjumper Posted May 7, 2008 Share Posted May 7, 2008 I would do it like this: (by the way, what's '$addy = "http://www.yahoo.com";' for??) <?php $tag=$_GET['tag']; $result = mysql_query("SELECT * FROM cloud where tag='$tag'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $new_count = ($row[count] + 1); //adds one to the number from num_votes column $query="UPDATE the_cloud SET count='$new_count' where tag='$tag'"; mysql_query($query); //this updates the specific row in the database that is concerned. Change the table name to fit yours. } header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534964 Share on other sites More sharing options...
trq Posted May 7, 2008 Share Posted May 7, 2008 Most of that code is not needed, making your script VERY inefficient. <?php if (isset($_GET['tag'])) { $tag = mysql_real_escape_string($_GET['tag']); $sql = "UPDATE the_cloud SET count=count+1 WHERE tag='$tag'"; if (mysql_query($sql)) { header("Location: http://www.example.com/"); exit(); } else { echo mysql_error(); } } ?> Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534966 Share on other sites More sharing options...
realjumper Posted May 7, 2008 Share Posted May 7, 2008 Most of that code is not needed, making your script VERY inefficient. Yes, your way is more efficient, no doubt about it...my way would work though ;-) Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534968 Share on other sites More sharing options...
trq Posted May 7, 2008 Share Posted May 7, 2008 my way would work though Indeed, just not at all well. Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534973 Share on other sites More sharing options...
ThYGrEaTCoDeR201 Posted May 7, 2008 Share Posted May 7, 2008 sometimes you may have to use ob_start(); if you don't want to get a bunch of errors. Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-534993 Share on other sites More sharing options...
imarockstar Posted May 8, 2008 Author Share Posted May 8, 2008 ok kool guys I shall try this ... ya my code prob sucked ass ... Im a beginner .. and Im still learning .. so thanks for you help .. I will let you know if it works .. rock on Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-535648 Share on other sites More sharing options...
imarockstar Posted May 8, 2008 Author Share Posted May 8, 2008 what the fuck .. thats still not working ... im not sure why any of the header redirects are not working .. Do I need to have something turned on in my php configuration ? Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-535650 Share on other sites More sharing options...
imarockstar Posted May 8, 2008 Author Share Posted May 8, 2008 ok it works .... i figured it out !!! thanks guys !!! Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-535668 Share on other sites More sharing options...
smartin1017 Posted May 8, 2008 Share Posted May 8, 2008 I ran into a problem like this once and the answer was to replace the capital L on Location with a lowercase. I never understood why but it worked. Try that. Link to comment https://forums.phpfreaks.com/topic/104490-solved-header-redirect-problem/#findComment-535671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.