Hi All;
I am new to this forum.
Can anybody let me know, how to insert the ip address and date into mysql table, if the ip address didnt store into current date.
insert the date & ip address if the ip not exists in current date else not store.
can any body know to write the mysql query plz let me know. I need to write for storing daily hits in my site.
Thanks in advance....
how to insert the ip address if it not exists in current dat
Moderator: General Moderators
-
theultimateboss
- Forum Newbie
- Posts: 2
- Joined: Fri Nov 07, 2008 6:32 am
Re: how to insert the ip address if it not exists in current dat
Hi,
one solution would be to set the ip column to unique, so you get an error if you try to insert the same ip twice.
An other solution would be just using SELECT before you insert the new row.
one solution would be to set the ip column to unique, so you get an error if you try to insert the same ip twice.
An other solution would be just using SELECT before you insert the new row.
-
theultimateboss
- Forum Newbie
- Posts: 2
- Joined: Fri Nov 07, 2008 6:32 am
Re: how to insert the ip address if it not exists in current dat
I already did ur first option. If we use the first method, once the ip will be stored into our database, then it will never store. The user may be come to again oour site after 2 days. Then his ip wont store.
So, the 2nd option is better I think. But How to select the ip from database and compare to date whether it present or not.
I cant get it,
If u can get plz let me know...
Thanks...
So, the 2nd option is better I think. But How to select the ip from database and compare to date whether it present or not.
I cant get it,
If u can get plz let me know...
Thanks...
Re: how to insert the ip address if it not exists in current dat
Hannes2k wrote:one solution would be to set the ip column to unique, so you get an error if you try to insert the same ip twice.
theultimateboss wrote:I already did ur first option. If we use the first method, once the ip will be stored into our database, then it will never store. The user may be come to again oour site after 2 days. Then his ip wont store.
One could always define unique constraint or even primary key based on two columns
There are 10 types of people in this world, those who understand binary and those who don't
Re: how to insert the ip address if it not exists in current dat
I used to be in your shoes... The first step to a learning curve is always the hardest... I learned PHP/MYSQL through phpmyAdmin. Use the tool to insert the data for you once. Then you will notice a link called Create PHP Code where it will write the query for you based on how you inserted your data. It is a great tool and can be very valuable for learning PHP/MYSQL.
Another solution would be to dig through forums where other people are having problems. Read through how they fixed them. There is great incite (and maybe insanity) to be had through forum reading.
.02
Good luck!
Robert
Another solution would be to dig through forums where other people are having problems. Read through how they fixed them. There is great incite (and maybe insanity) to be had through forum reading.
.02
Good luck!
Robert