Jump to content

data not being added to MySql DB


richiejones24

Recommended Posts

The script below used to work fine but the HTTP_REFERER was unreliable so i added a re-direct if the HTTP_REFERER was unavailable and now nothing is being added to the MySQL BD, the script runs ok ie it sends the user back to where they come from, any ideas what could be wrong? 

 


<?php
require("../include/mysqldb.php");
$uinwish = $_GET['uinwish'];
$wishrefer = $_SERVER['HTTP_REFERER'];
$wishdate  = mktime(0, 0, 0, date("m"), date("d")+3, date("Y"));
$rand_wish_cookie = $_COOKIE["wishtracking"];

$con = mysql_connect("$dbhost","$dbuser","$dbpass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("$dbame", $con);

//DB Stuff start code below

//check if the uin and cookie have already been stored together.
$sql = "select * from Wish_list_guest where usercookie='$rand_wish_cookie' and uinwish='$uinwish'";
$result = mysql_query($sql);


$row = mysql_fetch_row($result);
if (mysql_num_rows($result)!= 1) {

$issetvar = "1";

if (!isset ($wishrefer)){

$host  = $_SERVER['HTTP_HOST'];
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;
}

if (isset ($wishrefer)){

header("Location: $wishrefer");
exit;
}
}

if ($issetvar = 1) {

mysql_query("INSERT INTO Wish_list_guest (usercookie, date_delete, uinwish, referwish)
VALUES ('$rand_wish_cookie', '$wishdate', '$uinwish', '$wishrefer')");

mysql_close($con);


if (!isset ($wishrefer)){

$host  = $_SERVER['HTTP_HOST'];
$extra = 'profile.php?uin=';
header("Location: http://$host/$extra$uinwish");
exit;
}

if (isset ($wishrefer)){

header("Location: $wishrefer");
exit;
}
}


?>

Link to comment
https://forums.phpfreaks.com/topic/250509-data-not-being-added-to-mysql-db/
Share on other sites

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.