-
Posts
15,232 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Alright, so long as you know that this only works on Windows. $last_mod = filectime("fname");You're telling it to look for a file named "fname". The $_POST array contains the value you need.
-
can i use .htaccess for a web service authentication?
requinix replied to jolirvarez1's topic in Applications
You didn't even try to copy and paste your question here. Why should I bother going to another forum just to see what your question is? The answer is "probably". -
PHP Odd Question (Not really sure what this is called..?)
requinix replied to Stalingrad's topic in PHP Coding Help
It's mostly a change to your query. In SQL a GROUP BY allows you to "combine" similar items (however you want to define that) and lets you use aggregate functions like COUNT() to give you information about each grouping. $query = "SELECT *, COUNT(1) AS count FROM uitems WHERE username='$showusername' AND location='1' GROUP BY theitemid";That will group items together according to the theitemid, and return back a column named "count" containing the number of items in each group. In your example it will be 2 for the gem and 1 for everything else; if it's not 1 then display the x? alongside the item. As for the JOIN, you really should learn to use it. Using nested queries like you're doing now is almost always a Bad Thing. Also you should avoid using SELECT *s unless you actually do want all of the information in the table (which you don't here). Try this: SELECT u.uitemid, i.name, i.image FROM uitems u JOIN items i ON u.theitemid = i.itemid WHERE u.username = '$showusername' AND u.location = 1 GROUP BY i.theitemid[edit] With this you only need the one loop. [/edit] But there's a problem. I think the uitemid is unique to each uitem? GROUP BY won't let you get more than one value for each group of rows: you'll get some uitemid for one of the two gems and you can't know which one it was for. So that impacts the link you output. -
[edit] filectime() is not the creation time of the file. The "c" stands for "change", specifically the change time of the file's inode. Which is not the same as the "m"odification time. It's filesystem stuff. Linux filesystems don't really keep track of the creation time so there's no way to get that there. On Windows filectime() might return a value that's the same as the creation time.
-
Right. But you could just put them in an array instead of a string: $words = array("register", "bal", "menu", "etc");[edit] And even if you didn't want to do that, you would have to use explode() (which you've shown you know about) not str_split().
-
Like how? Generating the list of options?
-
We're not going to do it for you but we'll gladly help you through the problem. Speaking of, what is the problem?
-
Why use regular expressions at all? in_array does what you (apparently) need.
-
Whether PHP generated the HTML or not doesn't matter: all the browser sees is the output. So in other words just add the CSS like you expect it should go. If that's not working then let us see what you have.
-
Maybe there's a different font that looks close.
-
Store column/row coordinates, and only the ones that actually have data. That way there's really no limit on how many rows or columns there are besides the ones you may (arbitrarily) impose yourself. I've never had to tackle the problem of storing different types of data as one logical unit (ie, A2 is "Books" while B2 is 12) but the best solution I know is like col | row | type | strval | intval | floatval ----+-----+------+------------+--------+--------- 2 | 1 | str | staff | | 3 | 1 | str | students | | 4 | 1 | str | professors | | 1 | 2 | str | Books | | 2 | 2 | int | | 12 | 3 | 2 | int | | 3 | ...(You'd need to include a reference to the "spreadsheet" each piece of data belongs in.) A SUM would be a matter of -- column SELECT SUM(intval + floatval) FROM table WHERE spreadsheet = (wherever) AND col = (column) AND type IN ("int", "float") -- row SELECT SUM(intval + floatval) FROM table WHERE spreadsheet = (wherever) AND row = (row) AND type IN ("int", "float")Formulas would be handled a little differently: you'd store a "formula" somewhere and use that to calculate the cell's value. You could store that value in the same table as the other data but then you'd have to worry about recalculating it if the source numbers changed.
- 2 replies
-
- php
- application
-
(and 1 more)
Tagged with:
-
CIM works in a different way than AIM. You don't send billing information as part of the transaction: you create a profile ahead of time (perhaps a few lines of code above...) and then submit a transaction against that profile. Is there a specific reason for switching to CIM? Maybe you want customers to create billing profiles?
-
There is memcache and there's memcached. memcached is the better one to use as it's more recent and supports more features.
-
Speaking of tokenizing, this problem is a form of the LCS problem with one key difference: if the two characters do not match then the new value is 0. Oh, and you can immediately return success if you hit five matching characters. l e l e p h o n e +---+---+---+---+---+---+---+---+---+ l | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | +---+---+---+---+---+---+---+---+---+ l | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | +---+---+---+---+---+---+---+---+---+ e | 0 | 2 | 0 | 2 | 0 | 0 | 0 | 0 | 1 | +---+---+---+---+---+---+---+---+---+ p | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | +---+---+---+---+---+---+---+---+---+ h | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 0 | 0 | +---+---+---+---+---+---+---+---+---+ o | 0 | 0 | 0 | 0 | 0 | 0 | 5*| | | +---+---+---+---+---+---+---+---+---+ b a a c c b +---+---+---+---+---+---+ a | 0 | 1 | 1 | 0 | 0 | 0 | +---+---+---+---+---+---+ a | 0 | 1 | 2 | 0 | 0 | 0 | +---+---+---+---+---+---+ a | 0 | 1 | 2 | 0 | 0 | 0 | +---+---+---+---+---+---+ c | 0 | 0 | 0 | 3 | 1 | 0 | +---+---+---+---+---+---+ c | 0 | 0 | 0 | 1 | 4 | 0 | +---+---+---+---+---+---+ c | 0 | 0 | 0 | 1 | 2 | 0 | +---+---+---+---+---+---+ c | 0 | 0 | 0 | 1 | 2 | 0 | +---+---+---+---+---+---+ c | 0 | 0 | 0 | 1 | 2 | 0 | +---+---+---+---+---+---+ Plenty of room for optimizations too. [edit] Better examples.
-
-
There's also prepared statements to consider, which would actually be perfect for this.
-
Any errors?
-
Can't you just move the loop down to a point where $fileop has its values?
-
So what was the code you tried? I assume it went inside successFunction()?
-
If you can make sure that the input doesn't contain a certain character, either by validating it or removing any found, and pretty much any character will do, then you can do something like /([^#]{5}).*?\#.*?\1/It tries to find five characters on the left of a # then the same five on the right. You'd match it against the string $input . "#" . $found_match. However the simplest way would be a couple nested loops - not so bad when you consider how few passes they would make. $input = "test12345"; $found_matches = array("west1298", "test1278"); foreach ($found_matches as $match) { for ($i = 0, $ilen = strlen($input); $i + 5 <= $ilen; $i++) { if (strpos($match, substr($input, $i, 5)) !== false) { // found a match } } }
-
If you have a small number like that, sure.
-
It'd help to know why Chrome isn't liking that page. Hit F12, go to the Network tab at the bottom, and refresh the index.html page. A row should pop up there showing what Chrome requested and what IIS responded with. Click it for details and make sure the little Headers tab is open. What does it show?
-
For short search strings you can WHERE field LIKE "%test1%" OR field LIKE "%est12%" OR field LIKE "%st123%" OR field LIKE "%t1234%" OR field LIKE "%12345%"(ie, a bunch of LIKEs over each set of five consecutive characters) A variation of that would be using a kind of index table with two columns: a WHERE field = "test1" OR field = "est12" OR field = "st123" OR field = "t1234" OR field = "12345"The difference is that this query would perform a lot faster (if you index that one field) and allow you to search on longer strings.
-
Why this reg exp for mobile number does not work?
requinix replied to mostafatalebi's topic in Regex Help
You need the $. Your expression says "at least one of [09] and then only one [0-9]". Does that sound right? [edit] And when you say "09 is fixed" do you mean literally 09 or either 0 or 9? Because your expression says the latter. -
It's a large XML file. You may have tried searching before it was fully downloaded.