![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
The Little Guy
-
Posts
6,675 -
Joined
-
Last visited
Posts posted by The Little Guy
-
-
My site has 3 examples of this (with code). The first result was posted by me and works, but you will need to modify it (requires a database), the other 2 I haven't tried, and don't know if they will work for you because they don't use a database.
http://phpsnips.com/search.php?search_by=1&q=online&submit=Search
-
use "require_once" instead of "include_once" you then won't get that error, BUT the second time in the loop the file won't be included again.
-
GeoIP database:
http://www.maxmind.com/app/geolitecity
The API:
http://www.maxmind.com/app/php
This is a free php solution to getting a users Location based on their IP address.
-
-
alter table yourtablename change col4 col4 varchar(15) after col2
-
Here we go:
select domain_id, count(s.domain_id) as total, d.is_validated from domains d left join searches s using(domain_id) where member_id = 1 group by d.domain_id;
This is what I want.
-
I would like to get a count, even if there is a count of zero.
example: I have 2 domains in the database, each domain has zero searches on them, I would still like to get them, but display 0 for the count. Any suggestions on what I should do? I can't seem to think how.
select d.domain, count(*) total from domains d left join searches s on(d.domain_id = s.domain_id and d.member_id = 1) group by d.domain_id
Thanks for the help!
Are you saying that you don't get back 2 records?
Correct. I should get back 2 records, and count should contain 0 for both.
@joel24 that doesn't work, as it comes back with a count of 1.
I should note that the searches table has 0 records in it.
-
I would like to get a count, even if there is a count of zero.
example: I have 2 domains in the database, each domain has zero searches on them, I would still like to get them, but display 0 for the count. Any suggestions on what I should do? I can't seem to think how.
select d.domain, count(*) total from domains d left join searches s on(d.domain_id = s.domain_id and d.member_id = 1) group by d.domain_id
Thanks for the help!
-
and don't worry about slowing the database with too many records
A good indexed table of this size should run fairly quickly with 500,000,000 rows. You should be able to get a count in less than 1 sec with that many rows.
-
I don't know if you need to be logged in to download, or not, but here is a simple solution (IMO).
- When the user clicks on the link, insert into the database either their user_id, or their ip address
- When you load the page, check to see if the value is in the database, if it is don't show it.
- If you base it on IP address, you will probably only want to limit the last download to a certain period, due to dynamic IP addresses.
-
If you have imagemagick you could make your life a lot easier and just do this:
shell_exec("convert rose.jpg -resize 50% thumb/rose.png");
-
Before I try, will this work with a port OTHER than port 80?
-
I like Wamp, You can easily update the php/apache config by just checking some check boxes, which for some reason I like better than opening it in a file editor saving then restarting...
-
I would create a table with 3 columns:
id, user_id, page
Then every time they view a page, insert it into the database, then to get the last 5 pages I would do this:
select * from history where user_id = 123 order by id desc limit 5;
-
SELECT * FROM table WHERE date_format(date, '%Y-%m') = '2011-10';
-
$username = "Ericquits"; echo $result->users->$username->icon;
-
Or do you want them kinda like this?
[attachment deleted by admin]
-
Wouldn't that be a lot of work?
Programming isn't a walk in the park. If you wan't valid reliable data you need to put work into it. If you don't validate the data, what would you do if I decide I want to use the date "Monkey Pants"?
-
convert it to a time:
$starttime = date("Y-m-d H:i:s", strtotime($_POST['date']));
This isn't the best solution, because not everything will be converted properly. I would recommend having pre-define values that users can select, such as a drop down, or separate input fields that each get validated as a month, day or year.
-
His post said nothing about a gui.
-
By using my method, (Which will save your from writing lots of php/mysql, at least more than needed), Go into phpMyAdmin and look a the structure of the table jupiter.
Check the boxes for the fields "code" and "ip". Next go to the bottom of the table and click the button "Unique" this will make it so that BOTH code and ip are unique columns.
Code, ip
3werwf, 1.1.1.1
3werwf, 1.1.1.1 <- This insert will fail
3werwf, 1.1.1.2 <- This insert will succeed
3w, 1.1.1.1 <- This insert will succeed
asdfsadfas,12.234.45.544 <- This insert will succeed
asdfsadfas, 1.1.1.1 <- This insert will succeed
Make sense?
-
what do you mean by "extend it to check for both values"?
-
add 2 sepertate unique indexs one to code, and one to ip
then you can do this:
mysql_query("INSERT IGNORE INTO jupiter(code,euro,ip,date,used) VALUES('$code','$secret','$remote_addr',CURDATE(),'n')"); if(mysql_affected_rows() == 0){ // Duplicates found }else{ // No duplicates were found }
-
This has nothing to do with anything in this threadI like using Putty. its small, but it is command line which is faster than a gui.
mysql -u root myDatabase
PHP MySQL Query
in PHP Coding Help
Posted
mysql_query only returns a data set. you need to use mysql_fetch_array or mysql_fetch_assoc like this: