Jump to content

Redirect to link and add 1 to counter


MadnessRed

Recommended Posts

Here is my code

 

<?php
// DB info
$servername = "~";
$database = "~";
$username = "~";
$password = "~";
$prefix = "~";

// Rate info
$id = $_POST["id"];

// Lets connect
$con = mysql_connect($servername,$username,$password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Lets select the database
mysql_select_db("$database", $con);


// Add the count
$query1 = "UPDATE `madnessred_sites` SET `Visits` =  `Visits` + 1 WHERE `ID` = '$id'";

mysql_query($query1, $con);


// We need redirect the user.
// First get the page to redirect to
$result = mysql_query("SELECT `url` FROM `madnessred_sites` WHERE `ID` = '$id'"); 

//Now make the page
while($row = mysql_fetch_array($result))
  {
  echo '<html><head><title>Redirecting...</title><meta http-equiv="REFRESH" content="0;url='.$row['url'].'"></HEAD>';
  echo '<body><center><a href="'.$row['url'].'"><h2>You will be redirected, if not, click here</h2></a></center></body></html>';
  }

// Now lets leave the database
mysql_close($con);

// DONE :-)
?>

 

I don't see why its doesn't work, nothing gets added to the Visits in the database and if I press view source, the page shows as blank when i view it on the internet.

Link to comment
https://forums.phpfreaks.com/topic/111916-redirect-to-link-and-add-1-to-counter/
Share on other sites

//Now make the page
echo $query1;

 

what should I be expecting?

You should be expecting an sql statement...

 

I have found that if there is an error anywhere in the page the page will come up blank it sounds like that is what is happening... i've found that this could be ANY error.

Then you don't have error reporting turned on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.