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

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.