-
Posts
31,575 -
Joined
-
Last visited
-
Days Won
77
Content Type
Profiles
Forums
Events
Posts posted by justsomeguy
-
-
It would be more efficient for lookups to only store the list of the blocked IPs, the list of all IPs could be retrieved from the IP column in the posts table. Again, some forums also choose to store which IPs an account was created with or at various other points (account activation, login, etc). As an admin I can see the IP on every post here, for example, and can use some tools to see all of the activity associated with a certain IP, like which users posted using it or who registered an account using it. The list of blocked IPs should be its own table only listing those that are blocked, because it's going to need to be looked up fairly frequently and you'd want to keep that as small as possible.
-
You can find the user's IP address and other information in the $_SERVER array:
-
An IP address blacklist is one option, although it's not difficult to get around it. Most forums will record the IP address any time someone creates an account, posts a message, etc, and then there are tools to look up how a particular IP address has used the forum and things to maybe require admin approval for a certain IP or just block them entirely. The first step is saving the IP when people use your site, and then you can build the other tools that use the IPs.
-
Add a return statement before the recursive call. You want to return the value of the recursive function.
- 1
-
That's a pretty vague question. And why are you trying to define a function within another function?
-
Try it and see what happens.
You can use array indices with a string to access different characters of it, e.g.:
$string = 'some string'; $string[4] = '-'; echo $string;
But you're trying to use an array index which is a string:
$string = 'some string'; $string['r'] = '!';
While it shouldn't be hard to figure out which character in that string is in the 4th position, it doesn't make much sense to try and figure out which character is in the rth position.
- 1
-
Because you're trying to access or set things like $result['rgb']['r'], where $result['rgb'] is a string. You probably meant to make it an array instead of a string.
-
Like most programming languages, there's documentation:
-
It looks like captcha_sa is already a global variable, so just set it with the new value.
- 1
-
Have a global object or something where you can save properties or methods that should be usable by anything.
-
Are you suggesting that the .js file extension is just a file accounting convenience and has no effect on whether Javascript is run?
The browser doesn't care what the filename is, just make sure it's right:
<script type="application/javascript" src="image.jpg"></script>
The browser isn't going to complain about an extension, have you ever seen an error message like that? It's going to download the file you tell it to and treat it like you're telling it to treat it, the browser assumes that the programmer knows what they're doing. If the file has an extension that PHP is configured to handle, then when your browser sends a request for the file the web server will send it to PHP and send the output to the browser, like with any other request.
Are there any additional security problems associated with setting the server to run javascript (.js) files with PHP?It's not a security problem, just efficiency. There's no reason to have PHP try to parse a bunch of file types that will almost never have PHP code in them. I just use .js.php when I want to indicate a PHP file that should output Javascript.
By way of confirmation, may I use the same require_once() function as many times and places as I like during the same browser session with good confidence that it will be included/required only once?That's what it's for.
- 1
-
Requesting a Javascript file isn't going to run any PHP code unless the web server is configured to send .js files to PHP. You could name the file with a .php extension if you need to dynamically create Javascript code for whatever reason.
- 1
-
If you use include_once or require_once to include files in PHP then it will only include the same file once even if there are multiple include statements. Hopefully you have a main PHP include file that your other PHP files include that defines various global functions and variables, and that would be the place to include any file that you want available on any other page.
- 1
-
You can either submit the form, get the form values with PHP, query the database, and show a new page with a new form with the data, or use Javascript to send an ajax request to PHP to get the database results and then display them on the page again.
-
I don't think I understand your question. You've designed a class but you don't know how to use the class you've designed?
-
Any database supports multi-user access, the database will let several different applications connect at once.
savable with different filenamesI don't know what you mean, what are you saving?
We need a text input header area, wherein text inputted will populate across pagesThat's what a database is for. Have page to update the header text in the database, and the other pages should get the text from the database and display it.
- 1
-
It might depend on your environment. If you're using Microsoft servers with .NET on the backend, then you might have SQL Server available. If it's a server with PHP on the backend then MySQL/MariaDB would be most popular.
-
You can use a single query with a join, you only need to use recursion if the replies can be nested under each other.
If it only shows one record from the database then there's probably an error. mysql_query does not show errors from MySQL, you need to check and display them yourself. The entire mysql extension is also removed in the current version of PHP, I would suggest switching to PDO or mysqli.
-
This forum is not your code writing service, we are here to teach people how to do it themselves. If you want the two events on the same element then put the two events on the same element.
-
If replies are only nested one level deep then using a join would let you get everything with a single query. Otherwise you need to put the second query in the loop for the first, and that's going to cause problems with scaling if you need to run 200+ queries to show that page.
-
Javascript running in a browser only has access to the current document. Trying to do anything else would be a series of hacks. You could put a bunch of hidden iframes or something on the page to point to different pages if they're on the same domain and try to access things through that. A much simpler and more useful solution would be to store your data in a database instead of in HTML files.
Depending on what the purpose is, you can save the various values in localStorage or sessionStorage to access on other pages.
- 1
-
You save the return value from setTimeout, and use clearTimeout to cancel it.
obj.src = obj.src + "?" + Math.random();
That's going to produce something like this:
/home/tux/Prog/Medias/Images/calib1.png?123?456?789?...
A URL shouldn't have more than 1 question mark.
-
SQL doesn't have a way to say "group by every 6 months", you just have to explicitly tell it what you want.
-
What specifically happens or doesn't happen when you submit that? Are there error messages?
Help me pls
in JavaScript
Posted
Because by the time that event handler runs, i is set to something else. It doesn't use the value that i had when you assigned the event handler, it uses the current value of i, whatever that is. You can use a closure to pass i as a new variable and use the value of that instead.
Now that makes an anonymous function that executes immediately (IIFE), which you pass the value of i, and inside the function it uses idx for the parameter. The IIFE returns a function which uses the value of idx, that returned function gets assigned as the click handler.