-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Are you specifically supposed to use rand() or can you use something else? For rand() you have to loop for however many you want (like with a for loop) but as you generate numbers only keep ones you haven't used before. That means multiple calls to rand(), not just reusing the same value from one call. While this seems like a good solution, it can be very slow (imagine if you have to generate a set of 10 numbers from 1-10 - that last one could take a while to finish) and you could accidentally hit an infinite loop (if you tried to get 10 numbers from 1-9). A better solution is to generate an array of all the numbers you can choose from, like using range, then a] If you need them in random order, shuffle that array and extract however many you want, or b] If you don't need random order, like your examples show, randomly choose numbers from the array (whose algorithm is much more effective than trying to rand() your way through it).
-
Don't put SQL in your URLs. Doesn't matter if it's only executed if authenticated, doesn't matter if you include a hash to validate the string, don't do it. If you need to insert data, pass the data by itself. ahk2sql.php?key=01010AuthenticationKey0101010&action=test&id=1&channel=23&status=3
-
You can also do a pcntl_signal_dispatch after the sleep: SIGINT will interrupt the sleep but not be acted upon unless you dispatch or use ticks.
-
That part has nothing to do with OOP, for the record. Strings
-
Need help on my my php code. Need to convert Metric Conversion?
requinix replied to love19801's topic in PHP Coding Help
Not working how? You can't just post code somewhere and tell people to fix it. -
Your thoughts on what that might mean?
-
Where are you doing this?
- 11 replies
-
- mod_rewrite
- apache
-
(and 2 more)
Tagged with:
-
That would be exactly what I said to use.
- 11 replies
-
- mod_rewrite
- apache
-
(and 2 more)
Tagged with:
-
If you really want to use Google's search, do it the right way: Custom Search, which also has an API.
- 5 replies
-
- preg_match
-
(and 2 more)
Tagged with:
-
You output the phrase before you increment. At the end of the script you've incremented but it's too late to change the message you were showing.
-
No, but it should be trivial for your coder to find the source code for get(), getfile(), and getuser() to determine how those work.
-
Nothing that looks obvious to me. Basic debugging steps: find out the assorted values, from variables and files and function calls, and compare them to what the code is expecting to see.
-
Multiple conditions in MySQL query (including date)
requinix replied to happypete's topic in MySQL Help
AND has higher precedence than OR. That means you actually wrote something more like SELECT * FROM data WHERE (incident = '1') OR (incident = '2') OR (incident = '3' AND (DATE(date) BETWEEN 2013-08-19 AND 2013-10-04))Which isn't what you want. Use parentheses to change the outcome, or use IN and reduce the expression to a simpler X AND Y. SELECT * FROM data WHERE incident IN ('1', '2', '3') AND (DATE(date) BETWEEN 2013-08-19 AND 2013-10-04) -
How does your thing work? AJAX? Regular form submission? How do you determine there's an error? How do you pass along the error message? Need to know more. As for the highlighting itself, highlighted how? CSS's background, border, and/or outline properties are probably what you're looking for.
-
Start learning. Are you familiar with the phrase "when all you have is a hammer, everything looks like a nail"? Wanting to make a counter and applying your knowledge of files to it is not the answer. Instead you should be wondering what the best method for the counters is, and that would be a database.
-
Don't use a file. Use a database for it. Then you can keep counters for as many things as you want.
-
Rather than "disable" the link, add an onclick handler that cancels the event. jQuery? .click(function(e) { e.preventDefault(); })
-
Show us what you tried.
-
As soon as you allow people to write custom PHP code that interacts with yours, the security of your application is lost entirely. My advice: document a set of APIs (interfaces) and rules custom code must follow, then allow them to submit it to you for a manual screening and approval process.
-
What are the values of txtPDate and txtPTime that don't work?
-
How do I identify if a number starts with a zero?
requinix replied to Fluoresce's topic in PHP Coding Help
If we're going to just go straight to the answer without caring why this problem apparently exists, After checking that the page number isn't empty $page[0] == "0" -
SEO and the canonical tag post
requinix replied to Riparian's topic in PHPFreaks.com Website Feedback
Help with what? How to add it to your HTML? Your PHP? Questions about it in general? -
How do I identify if a number starts with a zero?
requinix replied to Fluoresce's topic in PHP Coding Help
Why do you care? It's just a number. -
how to get the array contents and serialize data
requinix replied to new_member's topic in PHP Coding Help
The page I linked to has a number of examples on how to use foreach. No you're not because that's a syntax error. Because you're trying to output two different things. Try posting your complete code this time.