4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 MySQL (with PHP) How 2 check duplicate date?
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Feb 17, 2002 6:39 pm (22 years, 2 months ago) Reply with QuoteBack to Top

I want to add a date to a database, but only if that date doesn't already exist.

I wrote this query to check, but it was returning any dates set to 0000-00-00 as duplicates.

Quote:
$another_date = "2002-03-01";

$query = "SELECT count(*)
FROM $tablename
WHERE date = $another_date";

$result = mysql_query($query, $link_id);
$query_data = mysql_fetch_row($result);
$duplicates = $query_data[0];

So I added the AND statement which stoped 0000-00-00 triggering a duplicate, along with everything else!

Quote:
$another_date = "2002-03-01";

$query = "SELECT count(*)
FROM $tablename
WHERE date = $another_date
AND rom_date != '0000-00-00'";

$result = mysql_query($query, $link_id);
$query_data = mysql_fetch_row($result);
$duplicates = $query_data[0];

What am I doing wrong? How can I do it right?

Thanks,
Darren
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.205508 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme