-
Posts
24,609 -
Joined
-
Last visited
-
Days Won
832
Everything posted by Barand
-
This class is excellent for working with AD
-
As a compromise, when you add a download record, get the id of the matching ip_lookup record and store that in the download record. That way you aren't duplicating the contry/area/city data and you get extremely efficient joins. SELECT download.FILENAME , ip_lookup.country , ip_lookup.area , ip_lookup.city FROM download INNER JOIN ip_lookup ON download.ip_id = ip_lookup.id WHERE download.FILENAME is not null
-
convert unsigned int ip_address from db to string
Barand replied to larry29936's topic in PHP Coding Help
Were they originally saved using INET_ATON to convert from "w.x.y.z" to an integer? -
Without knowing what output you are expecting from that input, how can we say what's missing? The inputs are dodgy too. Each sub2 will overwrite the previous one, leaving you with 2-92 and 3-90 only.
-
convert unsigned int ip_address from db to string
Barand replied to larry29936's topic in PHP Coding Help
Are you sure that is line 205? -
PHP login system fetch username and redirect issue
Barand replied to etopal's topic in PHP Coding Help
try echo '<pre>' . print_r($_SESSION, true) . '</pre>'; That will show the contents of $_SESSION. If it's doesn't contain the expected values you need to trace backwards to where the values should be set and work out why it isn't happening. -
PHP login system fetch username and redirect issue
Barand replied to etopal's topic in PHP Coding Help
Have you checked if $_SESSION contains what you are expecting it to contain? -
Can you post the output from SHOW CREATE TABLE ip_lookup; and SHOW CREATE TABLE download;
-
Use json_decode() to create either an object or array. You can then access the individual elements.
-
You could replace $myfile = fopen("test.txt", "r") or die("Unable to open file!"); while(!feof($myfile)) { $text[] = fgets($myfile); } fclose($myfile); with $text = file('test.txt', FILE_IGNORE_NEW_LINES);
-
... and a meaningful topic title
-
Remove the ( ) from the SELECT clause. download +----+---------------------+------------+----------+ | ID | LOG_TIME | IP_ADDRESS | FILENAME | +----+---------------------+------------+----------+ | 1 | 2020-05-03 17:26:56 | 20 | NULL | | 2 | 2020-05-03 17:26:56 | 160 | a.txt | | 3 | 2020-05-03 17:26:56 | 205 | b.txt | +----+---------------------+------------+----------+ ip_lookup +-------+----------+--------+---------+--------+------------+ | IP_ID | start_ip | end_ip | country | area | city | +-------+----------+--------+---------+--------+------------+ | 1 | 1 | 100 | USA | NY | New York | | 2 | 101 | 200 | UK | N West | Manchester | | 3 | 201 | 300 | Spain | North | Barcelona | +-------+----------+--------+---------+--------+------------+ mysql> SELECT download.FILENAME, ip_lookup.country, ip_lookup.area, ip_lookup.city -> FROM download, ip_lookup -> WHERE download.IP_ADDRESS BETWEEN ip_lookup.start_ip and ip_lookup.end_ip; +----------+---------+--------+------------+ | FILENAME | country | area | city | +----------+---------+--------+------------+ | NULL | USA | NY | New York | | a.txt | UK | N West | Manchester | | b.txt | Spain | North | Barcelona | +----------+---------+--------+------------+ Also, use explicit join syntax and not "FROM A,B WHERE ..." SELECT download.FILENAME , ip_lookup.country , ip_lookup.area , ip_lookup.city FROM download INNER JOIN ip_lookup ON download.IP_ADDRESS BETWEEN ip_lookup.start_ip and ip_lookup.end_ip;
-
Why do you feel this urge to duplicate the country, area,city data? You only need it in the ip_lookup table. Join the two tables in a query whenever you want that info for access table records.
-
Php script to receive http request from a software?
Barand replied to ARAD's topic in PHP Coding Help
One of the reasons for using an http request (AJAX) is to stay on the same page. If you want output to go to another page use a link or a form with GET or POST and send to the other page. -
The var_dump() output has now shown you why - the values are not the same. You search for "charlie" but array contains "charlie\n"
-
No. PHP knows nothing about where the page should appear, it is running remotely on the server. Things like opening new tabs need to be handled on the client, using HTML or JavaScript.
- 1 reply
-
- 1
-
-
Does a var_dump() of $word and $text[2] reveal any differences?
-
Start by following those two links that @requinix included for you in his reply.
-
Unlikely Quotes need removing... $query = "UPDATE `greencard` SET `comments`= '$comments', 'sent' = '$sent' WHERE `hospitalnumber`= '$hospitalnumber' and `PIN`= '$PIN'"; ^ ^ and it's easier just to use ... sent = NOW() WHERE ...
-
The best place to set the default timezone is in your php.ini file. Then you don't have to set the default in every script.
-
Yes $a = new DateTime('2020-05-01'); $b = new DateTime('2020-05-04'); echo $a->diff($b)->days; //-> 3
-
You appear to be duplicating the city in most tables
-
Yet you still do it, which is why I have given up.
-
I refer to the last topic you posted here. https://forums.phpfreaks.com/topic/310600-delete-the-whole-sentence-which-contains-two-consecutive-words-beginning-with-large-letters/?do=findComment&comment=1576951
-
As you just post a problem then disappear with acknowledging any replies, why should we waste our time?