-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
Looks like you haven't set up the configuration stuff yet. I don't know where $config is coming from, but the code expects it to include database information. What's in there needs to be whatever your MySQL connection details are - which should not be for the root user.
-
The date picker should not be creating dates with names. Regardless of what it displays to the user, it should always "output" in a standardized format like Y-m-d or m/d/Y. But that's what it appears to be doing - at least according to the "dateFormat" (assuming that since it's not defined there then the date picker is using the default). So are you sure that the $this->date in the code is correct? It's not somehow being set to the current date?
-
Your generate_list() will return an array of arrays. Loop over those to get timezone identifiers, construct a DateTimeZone for each, then use its getOffset() method with some quick math (to convert seconds to hours+minutes) to form that output.
-
What did you do to make IIS support PHP, and what did you do to make IIS run the website you're running with PHP? Actually no, let's just skip to the chase: iis method not allowed
-
How did you set it up?
-
Are you running this site on your own computer? With IIS? How did you set it up?
-
I showed you code. You need to make the mental leap to understand what it is and what it does. It's only three lines. More of a step than a leap.
-
Sounds like POSTing isn't enabled for your script. Talk to your hosting provider to see what's up with that.
-
"Weeks"? Really? Array (Whatever variable you dumped is an array, [2] => WP_User Object ( [3] => WP_User Object (containing WP_User objects, [data] => stdClass Object (with "data" properties that are plain stdClass objects, [ID] => 3 [user_email] => [email protected] contain "ID" and "user_email" properties. foreach ($variable as $user) { echo "ID: {$user->data->ID}, Email: {$user->data->user_email}"; }
-
Starting a project, could use a little help!
requinix replied to ZeromusXXX's topic in PHP Coding Help
So how familiar are you with PHP? MySQL? What have you learned so far? This forum works a lot more effectively if you can ask specific questions. In general you'll need 1. To know how to get stuff from a database (the list of states) 2. To know how to put stuff into the database (who the user is and which state they chose) 3. A map 4. Information about where each state is on the map - like actual pixel locations (eg, the center of Florida is at X,Y on this image) - which you should store in the database along with the state information itself 5. Some HTML and CSS knowledge; besides obviously making the page, you will need to be able to overlay one HTML element on top of another (that is, a with the username overlaid on the map) On that main page you'll pull information for one user (I guess?), including which state and where that is on the map, then position an and accordingly. -
If all you need is those IDs then use a foreach to extract the values into a separate array, then sort the array.
-
In PHP, how to save a password in encrypted form ?
requinix replied to abhik143's topic in PHP Coding Help
First, you want hashing. Encryption is when you can get the original password back from your database. That sounds good but it isn't. What you need is hashing, which is taking something like a password and turning it into another thing that looks random but will give you the same result for the same password. (Basically.) Then you compare hashes. Use password_hash and password_verify like // when setting or changing a password $hash = password_hash($_POST["password"]); /* put $hash in the database */ // when checking a password if (password_verify($_POST["password"], $hash_from_database)) { // password matches } else { // password does not match } -
HTML or PHP - which is better for search engines
requinix replied to Walled's topic in Miscellaneous
I assumed the question was about extensions - .html and .php. But any way I interpret the question, the answer is the same. -
HTML or PHP - which is better for search engines
requinix replied to Walled's topic in Miscellaneous
They don't care. -
The question marks are supposed to be there. That's how prepared statements work. Wikipedia
-
What is the new error message?
-
You're binding just fine. SQLSTATE[23000]: Integrity constraint violation: 19 users.active may not be NULLSince active isn't in your list of columns to insert, the database will use the default value. But the default is (apparently) null. The result is that you have to specify the active value when adding a new user.
-
It matches both because you aren't using anchors to enforce a match against the entire string. All you're doing now is checking if the string contains those patterns.
-
Use usort() with strnatcmp() to implement your own sorting algorithm. usort($FIRST_NAT_SORT, function($a, $b) { $a1 = strtok($a, "-"); $a2 = strtok(""); $b1 = strtok($b, "-"); $b2 = strtok(""); return strnatcmp($a1, $b1) ?: -strnatcmp($a2, $b2); });[edit] It's been asked so I'll explain: The function to usort() has to return 0 depending on how the two arguments ($a and $b) compare to each other - negative if $a $b. Fortunately that's exactly how strnatcmp() behaves too. return strnatcmp($a1, $b1) will handle sorting for just the parts before the hyphens, but if they're equal then you need to compare the parts after the hyphens. $x ?: $y is shorthand for $x ? $x : $y, so return strnatcmp($a1, $b1) ? strnatcmp($a1, $b1) : -strnatcmp($a2, $b2);(except the shorthand will only evaluate the first strnatcmp() once) Since strnatcmp() returns 0 if the two are equal and nonzero if not, the function will return that number if the two are not equal because it won't try to do the second comparison. If they are equal then the second strnatcmp() does get evaluated. It works the exact same way as the first one, except it has a minus sign to negate the return value. Thus the result is backwards: negative if $a2 > $b2 and positive if $a2 $b2. The effect is a descending sort on the values after the hyphens. To be absolutely explicit about everything you could write that line as $compare1 = strnatcmp($a1, $b1); if ($compare1 < 0) { // $a1 < $b1 return -1; } else if ($compare1 > 0) { // $a1 > $b1 return 1; } // $compare1 == 0 and $a1 == $b1 $compare2 = strnatcmp($a2, $b2); if ($compare2 < 0) { // $a2 < $b2 return 1; // opposite result } else if ($compare2 > 0) { // $a2 > $b2 return -1; // opposite result } else { return 0; }
-
Clearly OP doesn't have the understanding or the inclination to let us help him.
-
Storing file modification date in database
requinix replied to NotionCommotion's topic in PHP Coding Help
To me it depends on what the date represents. If it's an actual piece of relevant data then you should put it in the database, but if it's just an artifact of the file itself then leave it with the file. So probably the former. -
If it's your own content then that deals with the more problematic restrictions, but you still can't scrape their site to get what you need. The API does provide a way, but it requires generating access tokens by logging into their site; there's no indication how long those tokens are good for (just an ominous warning that they might expire in the future) so you will probably have to re-login to keep the feed working indefinitely. So here's what I propose: You take the officially-supported API route. Make an application according to their guidelines, and to alleviate most of the burden of the API you can use a third-party library to do the communication parts, then use their /users/self/media/recent endpoint to get the images. Yes, it will take you a little longer, yes, it's not as simple as scraping, but that's the method they require so that's what you'll need to do.
-
Okay, see, now we've got a bit of a problem: Instagram doesn't like people doing what you're doing. Their Terms of Service specifically disallows crawling media (General Condition #9), their API policy says you can't "simply display User Content" without permission (General Terms #16), and the less precise "Platform Policy" list in their documentation says you can't crawl media without users' consent or automate requests (#4, #5). And on a more technical note, their API doesn't provide a way for you to access user media without them specifically logging into Instagram. As far as I can tell. I'm not sure there are any alternatives open to you...