-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
PUT and DELETE method not supported on IIS server
requinix replied to Forgerbours's topic in Microsoft IIS
Does the error page mention WebDAV anywhere? -
jQuery. Or another Javascript framework. You're getting into the realm of things that are awkward and tedious to do in plain Javascript. For example, what you're looking for in jQuery is done with $(".testclass").html("result here");
-
For crying out loud, how can it be so difficult to explain this... Let's try pure algebra. Can you handle algebra? I hope so. Some variables: B = bet amount O = odds of winning P = net profit W = amount paid out to the winner Some equations: P = W - B (profit is the winnings less the bet amount) W = B * O + B (winnings is the bet amount paid out by the odds, plus the original bet back) Let's combine those two equations: P = (B * O + B) - B P = B * O Okay? So the net profit is the bet amount multiplied by the odds. Now let's rearrange it so that the equation solves B (what you want to know) in terms of P (a known amount) and O (also a known amount). B = P / O Now let's plug in some values. P = 30 O = 5/2 = 2.5 B = 30 / 2.5 B = 12 What is not clear about that?
-
You keep saying $42 but the question, as far as I can tell, has always been "what is the bet amount to get a profit of $30?" Which bsmither and I have both told you is simply profit / odds. The fact that he receives $42 is moot.
-
$12 is right... Not sure what the $42 is for? Profit of $30, which means 2.50 * $bet = $30. Because you can ignore the +$bet part because that's just him getting his money back. 30 / 2.50 = 12.
-
What keys do you have on that table? Do a SHOW CREATE TABLE $table if you're not sure. More than one key? Sounds like you're violating one key (that isn't the description), triggering the ON DUPLICATE KEY, but then violating the description key with the new value.
-
"Until 1 post" would probably be fine. I wouldn't go for the "until X days" because I've seen spammers sign up days, even months in advance of their first post.
-
Registration CAPTCHA broke. It's disabled for now but they're trying to fix it.
-
Yes, in general (depends if your hosting allows it), but there are very few reasons why you should ever do that. What do you need it to do?
-
I suggest actually learning PHP so you'll understand what the code is doing and can figure out answers like "remove the parts you don't want" on your own. echo $ImStore->get_permalink( "shopping-cart", true, false, $post->post_parent );
-
Those figures only show anything if there is a PHP process running at the very same second you get to that page. For a low-traffic site that may be a rare occurrence. Create a script with something like a sleep(100) so it runs for a long time, go to it in your browser, and reload the CPanel page.
-
Proxies. Configure your browser to use one of the millions of free proxies located around the world.
-
Don't rely on the time ranges (presumably 6-8, 8-12, 12-5, 5- to know what they did. What if someone clocked out for lunch after noon? What if they needed to leave early, like 3pm, for a doctor's appointment? What if they came in late, like 9am, or had to work late, like until 10pm?
-
You aren't using date or time properly, probably because you don't know what they do. Read the documentation. When you get the date and time into the right form, the next problem is your query. The date and time will be strings, and strings in queries need quotes. In fact this seems to be another place where you don't quite know what you're working with. After you fix the quotes and the other syntax error, you may find that it's returning far more "alerts" than you wanted it to - your condition says that the date is in the past or the time of day is earlier in the day (which says nothing about the date itself) or that the alert hasn't been sent yet.
-
What's the code? Did you put the £ right in the code? Was the file saved using UTF-8 encoding?
-
If you have to use .call then there's not much you can do because you're forcing yourself to call the function manually. And if you're doing that you might as well just pass e and the string at that time. Anything I can think of involves using more code so that you can use less code - pointless. What's wrong with .proxy? You could use it with event.data like $('#tt').on('click', $.proxy(test.init, test), 'some text as extra param'); var test = { init: function(e) { e.preventDefault(); console.log(e); console.log(e.data); } };Or write a wrapper like test.on('#tt', 'click', 'init', 'some text as extra param'); var test = { init: function(e) { e.preventDefault(); console.log(e); console.log(e.data); }, on: function(selector, event, handler, data) { $(selector).on(event, $.proxy(test[handler], test), data); } };(or for that matter, write a wrapper that uses the .call method)
-
->clientid is null so that's not it. [edit] Oh, the general syntax? Yes, if you decode JSON to an object (the default) then you'd use lots of ->s. [/edit] Starting at ThisUserID and working backwards, - That's the value and the key is "name" - "name" is part of an object in the "customfield" array - "customfield" is an array in the "customfields" object - "customfields" is part of an object in the "product" array - "product" is an array in the "products" object - "products" is at the top level Reversing that gives you the path. $arr->products->product[0]->customfields->customfield[0]->nameThere are two arrays in there. You need to consider whether they will have any objects inside them at all, whether there is only ever one, or whether there could be more than one.
-
I derived this monstrosity for work*: we had arbitrary HTML and I needed to cut it down to a certain number of words, not counting headings, and preserving as much markup as possible. Slightly redacted. For regular use, one would probably want to make a couple adjustments like removing the check for "foo_" and "foohead" (both indicating heading markup). /** * Truncate raw content * * @param mixed $content * @param int $words * @param bool $headings * @return array */ private static function truncateRaw($content, $words, $headings = false) { if(is_array($content)) { $ret = array('content' => array(), 'remaining' => $words); foreach($content as $key => $value) { if($ret['remaining'] <= 0) { if($ret['remaining'] == 0) { $ret['content'][$key] = '...'; } break; } $remaining = $value->truncate($ret['remaining'], $headings); $ret['content'][$key] = $value; $ret['remaining'] = $remaining; } return $ret; } else { $ret = array('content' => '', 'remaining' => $words); if($words <= 0) { return $ret; } // some special content has html comments explicitly marking a preview area if(($pos1 = strpos($content, '<!-- BEGIN PREVIEW -->')) !== false && ($pos2 = strpos($content, '<!-- END PREVIEW -->', $pos1)) !== false) { // 22 for strlen('<!-- BEGIN PREVIEW -->') $len = $pos2 - $pos1 - 22; $ret['content'] = trim(substr($content, $pos1 + 22, $len)); $ret['remaining'] = 0; } else { // cut the text in a way to preserve html tag structure $pieces = preg_split('#(</?(\w+).*?>)#is', $content, -1, PREG_SPLIT_DELIM_CAPTURE); // comes in triplets $excerpt = array(); $tags = array(); $header = 0; // counter for tag depth in headers $state = 0; // piece A: 0=text // piece B: 1=html tag // piece C: 2=open tag name, 3=opening tag name of header, 4=self-closing tag, 5=closing tag name // // A B C // +----+------+------------------------+ // | 0 -|-> 1 -|-> 2 if opening tag -|-> 0 and header++ (if header>0) // +----+------+------------------------+ // | 0 -|-> 1 -|-> 3 if opening header -|-> 0 and header++ // +----+------+------------------------+ // | 0 -|-> 1 -|-> 4 if self-closing -|-> 0 // +----+------+------------------------+ // | 0 -|-> 1 -|-> 5 if closing tag -|-> 0 and header-- (if header>0) // +----+------+------------------------+ // // break text if header==0, otherwise only increase word count // // h1 h2 h1 h0 // 013 0 12 0 15 015 014 012 0 15 0 // <p class="foo_header">Header <b>Text</b> </p> <br /> <p>Content</p> // ^ header ^ not header foreach($pieces as $piece) { // 0. text if($state == 0) { if($header) { if($headings) { $cut = self::cutWords($piece, $ret['remaining']); $excerpt[] = $cut['content']; $ret['remaining'] = $cut['remaining']; } else { $excerpt[] = $piece; $ret['remaining'] -= self::countWords($piece); } } else { $cut = self::cutWords($piece, $ret['remaining']); $excerpt[] = $cut['content']; $ret['remaining'] = $cut['remaining']; if($ret['remaining'] <= 0) { break; } } $state = 1; } // 1. html tag else if($state == 1) { // logic is easier to write in reverse order if($piece[1] == '/') { // closing // closing tag logic will decide when to add itself to the excerpt $state = 5; } else if(substr($piece, -2, 1) == '/') { // self-closing $excerpt[] = $piece; $state = 4; } else if(strlen($piece) >= 3 && $piece[1] == 'h' && ctype_digit($piece[2])) { // normal header $excerpt[] = $piece; $state = 3; } else if(strpos($piece, 'foo_') !== false || strpos($piece, 'foohead') !== false) { // old header $excerpt[] = $piece; $state = 3; } else { // text $excerpt[] = $piece; $state = 2; } } // 2. opening tag else if($state == 2) { $header && $header++; $tags[] = $piece; $state = 0; } // 3. opening header else if($state == 3) { $header++; $tags[] = $piece; $state = 0; } // 4. self-closing else if($state == 4) { $state = 0; } // 5. closing tag else if($state == 5) { $header && $header--; while($tags && $tag = array_pop($tags)) { $excerpt[] = "</{$tag}>"; if($tag == $piece) { break; } } $state = 0; } } // clean up any unclosed tags while($tags && $tag = array_pop($tags)) { $excerpt[] = "</{$tag}>"; } $ret['content'] = implode('', $excerpt); } return $ret; } }The most important thing was that it put tags onto a stack in order to close them out properly when the content gets cut inside multiple tags - I had to deal with things like ULs and tables. OR, instead of all this crazy work deciding how to get a summary: ask the writer to write one. Seriously. It's so much easier and their summary will be nicer than one you come up with automatically. * I don't normally like sharing stuff done for my job, IP rights and whatnot, but we're fairly lax and this is one of those times when there can be significant benefit to the community.
-
No, what you did was tell PHP where it should search for files when you try to include them. Completely different thing.
-
With just ->item, SimpleXML will always get the first element named "item". Use $xmlappend->addChild to create a new item each time, put that in a variable, and add the title and URL to that.
-
Go for an MP4 (which is just a "container" for stuff) using H.264 video and AAC or MP3 audio. Not sure how you did the conversion but make sure you're converting to those formats. Could be you converted without audio, or to an audio codec not supported by WMP or the browser. Is the MOV (preferably) or MP4 (to see what's wrong) online somewhere we can see? Very wrong.
-
Is this not something you can just do manually? Not many good reasons why you should be able to execute arbitrary SQL files on a regular basis. Fewer that require you to use PHP instead of, say, a cronjob.
-
Accessing Values with in a Simple Multidimensional Array?
requinix replied to CoolHandLuke's topic in PHP Coding Help
The firstColor is inside the color array which is inside the $m_array array. $m_array["color"]["firstColor"] -
checking array of data against a database
requinix replied to imperialized's topic in PHP Coding Help
There is an easier way: make sure the tag column is unique and do an INSERT IGNORE with all the tags at once. INSERT IGNORE INTO blogTags (tag) VALUES ("tag1", "tag2", "tag3")which will be easier to do without prepared statements.