Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 05-01-2005, 03:55 PM Unique Hits
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
Can you tell me why this isn't working? If the viewer has the same ip as one in the database it still adds it again

PHP Code:
$ip $_SERVER['REMOTE_ADDR'];
$result mysql_query("SELECT * FROM `unique_hits` WHERE `ip`=`$ip`");
if (!
$resultmysql_query("INSERT INTO `unique_hits` (`ID` , `ip`) VALUES ('', '$ip')");
$unique_sql_hits mysql_query("SELECT * FROM `unique_hits`");
$unique_hits mysql_num_rows($unique_sql_hits); 
timsquash5 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-02-2005, 06:01 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Surely $result will only be false if the query failed? An empty result set is still a result.

Instead of if(!$result), try if(mysql_num_rows($result) == 0)
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 05-03-2005, 07:51 AM
cuongdm's Avatar
Skilled Talker

Posts: 63
Name: Cuong Dao M.
Location: Vietnam
Trades: 0
Oberon already found the bug
I just want to share one more thing.
Normally, I'll set 'ID' field as auto_increment so we don't have to put it into MySql queries.
cuongdm is offline
Reply With Quote
View Public Profile Visit cuongdm's homepage!
 
Reply     « Reply to Unique Hits
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18416 seconds with 12 queries