PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Sep 04, 2006 9:57 pm
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
om im working on a clients site and this script works perfectly fine on my webserver, but on his webserver. it will not add none of the data to the database. I receive no errors. any suggestions?Code: Select all
<?php
if ( strlen($_POST['site_name']) > 0
&& strlen($_POST['site_url']) > 0
&& strlen($_POST['email']) > 0 )
{
$site_name = strip_tags($_POST['site_name']);
$site_name = htmlspecialchars($site_name);
$site_url = strip_tags($_POST['site_url']);
$site_url = htmlspecialchars($site_url);
$email = strip_tags($_POST['email']);
$email = htmlspecialchars($email);
require_once 'sql_config.php';
mysql_query ("INSERT INTO Sites(site_name, site_url, email ) VALUES ('$site_name', '$site_url','$email')") or die(mysql_error());
$result = mysql_query( "SELECT * FROM Sites WHERE site_url='$site_url'" );//
$row=mysql_fetch_array($result); //Store Record Of Data in $row
$message = "You must link our site with the following http://www.styleikon.com/?id=" . $row['id'];
echo $message;
$from1="From: info@styleikon.com\r\nX-Priority: 1 (Highest)";
mail ($email,$from1, $message) or print "Could not send mail";
}
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Sep 04, 2006 10:25 pm
sorry about that. =)
anyway, thats not the problem. the problem relies in here
last_click = time()
Code: Select all
$date1 = strtotime(time());
$date2 = strtotime($row['last_click']);
$diff = $date1 - $date2;
$days = $diff/60/24;
if ($days >= 20)
{
is this how i tell if 20 days have passed?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 04, 2006 10:27 pm
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Sep 04, 2006 10:38 pm
still having troubles. it keeps deleting the entry. any ideas?
Code: Select all
$date1 = strtotime(time());
$date2 = strtotime($row['last_click']);
$diff = $date1 - $date2;
$days = floor($diff/86400);
if ($days >= 20)
{
$id = $row['id'];
mysql_query("DELETE FROM Sites WHERE id = '$id'") or die("DELETE Error: ".mysql_error());
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 04, 2006 10:41 pm
Why are you using
strtotime() on
time() ? It's already a unix timestamp.
You may need to examine $row['last_click'] and $date2.
Strtotime() may not be able to fully convert it.
var_dump() could be of help in this, if only temporarily.
psychotomus
Forum Contributor
Posts: 487 Joined: Fri Jul 11, 2003 1:59 am
Post
by psychotomus » Mon Sep 04, 2006 10:45 pm
so basicly I only need
$diff = time() - $row['last_click'] ?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 04, 2006 10:54 pm
If $row['last_click'] is a unix timestamp in the past, yes.