Jump to content

[SOLVED] header redirect problem .


imarockstar

Recommended Posts

 

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.