FAQ
•
Search
•
User Groups
•
Forum Admins
•
Smilies List
•
Statistics
•
Rules
•
Login
•
Register
H
ome
FAQs
L
inks
N
ews
Online Tools
phpBB
Scripts
T
utorials
A
bout us
C
ontact us
Contribute
Credits
Link to us
MySQL (with PHP) How 2 check duplicate date?
Forum Index
»
Databases
Author
Message
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
Posted: Sun Feb 17, 2002 6:39 pm (22 years, 2 months ago)
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
Display posts from previous:
All Posts
1 Day
7 Days
2 Weeks
1 Month
3 Months
6 Months
1 Year
Oldest First
Newest First
Forum Index
»
Databases
Jump to:
Select a Forum
» 4WebHelp
Announcements
Our Site: Feedback & Questions
» General
Chit Chat
Freedom2Surf
Advertisements
» Support
General
Website Reviews
Client-Side Coding
Server-Side Coding
Databases
Web Servers
Hosting & Domain Names
Graphics & Flash
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.24808 seconds :: 19 queries executed :: All Times are GMT
Powered by
phpBB
2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme