-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
You cannot return the list from the uList function. AJAX is asynchronous (it's the first 'A') which means it's not executing like a normal function call but will execute eventually and somewhere else. Instead of calling uList() and then doing something with the return value, give uList() a function to call when it's ready. function uList(callback) { $.ajax({ type: "POST", url: "techs.php", success: callback }); } uList(function(users) { // do something with users console.log(users); });
-
Calculate poisson probability percentage in php
requinix replied to runnerjp's topic in PHP Coding Help
I'm going to copy/paste from the source: /********************************************************************** Cumulative Distribution Function POIsson distribution Function Calculates any one parameter of the Poisson distribution given values for the others. Arguments WHICH --> Integer indicating which argument value is to be calculated from the others. Legal range: 1..3 iwhich = 1 : Calculate P and Q from S and XLAM iwhich = 2 : Calculate A from P,Q and XLAM iwhich = 3 : Calculate XLAM from P,Q and S P <--> The cumulation from 0 to S of the poisson density. Input range: [0,1]. Q <--> 1-P. Input range: (0, 1]. P + Q = 1.0. S <--> Upper limit of cumulation of the Poisson. Input range: [0, +infinity). Search range: [0,1E100] XLAM <--> Mean of the Poisson distribution. Input range: [0, +infinity). Search range: [0,1E100] STATUS <-- 0 if calculation completed correctly -I if input parameter number I is out of range 1 if answer appears to be lower than lowest search bound 2 if answer appears to be higher than greatest search bound 3 if P + Q .ne. 1 BOUND <-- Undefined if STATUS is 0 Bound exceeded by parameter number I if STATUS is negative. Lower search bound if STATUS is 1. Upper search bound if STATUS is 2. Method Formula 26.4.21 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the computation of the cumulative distribution function to that of computing a chi-square, hence an incomplete gamma function. Cumulative distribution function (P) is calculated directly. Computation of other parameters involve a seach for a value that produces the desired value of P. The search relies on the monotinicity of P with the other parameter. **********************************************************************/If $which == 1,- $par1 is the S value - $par2 is the XLAM value If $which == 2, - $par1 is the P value (and Q is 1-P) - $par2 is the XLAM value If $which == 3, - $par1 is the S value - $par2 is the P value (and Q is 1-P) -
Trigger causes insert to say column doesn't exist.
requinix replied to sKunKbad's topic in MySQL Help
Obviously it does exist. What is the exact error message? You've made sure that with those exact table structures and that exact trigger you're getting the same error, right? I think so but it's not clear. It sounds like you are turning a "insert a record into d_records" operation into a "create a record thing by inserting rows into d_records and h_records" operation. Or it could be that h_records is some sort of history or auditing table and you want inserts to be sort of mirrored? Or I don't know. Either way I think (not knowing your situation) I would go with a stored procedure; triggers that cause side effects in other tables and not because of something like foreign key relations feel icky to me. Too automagical. It's entirely non-obvious that inserting into d_records will also insert into h_records, but that's also due to what triggers are so... Eh, opinion. -
Trigger causes insert to say column doesn't exist.
requinix replied to sKunKbad's topic in MySQL Help
Behavior like this with a trigger? Ew. How about a stored procedure instead? -
...Yes? It wouldn't be very nice if you checked out a local copy of a remote branch and it wasn't up to date.
-
allow_url_include is about trying to do stuff like include("http://..."), which is never acceptable. It doesn't matter here. What if you try equivalent code using cURL instead?
-
need help with a strange behaviour in php
requinix replied to shan2batman's topic in PHP Coding Help
Try this: First, get rid of the stupid error_reporting(0);That tells PHP to ignore any possible errors. Then try your script and see anything happens. If not, just before the echo on line 79 add a line header("Content-Type: text/html");Then look for an error message telling you it failed because of output somewhere. -
need help with a strange behaviour in php
requinix replied to shan2batman's topic in PHP Coding Help
Forget the developer tools. They show you what the browser interpreted in the HTML. Look at the HTML source of the page to see what PHP actually did. Also, -
If I may translate that, If you mean the ternary operator ? : then the answer is, While possible, in this case you shouldn't. That's more appropriate if you have "if ($condition) $var = $value; else $var = $other_value;". Your if has two statements in that else so it's really just better to leave it as is. And this is coming from someone who generally does use shorthand.
-
selecting user info if 2 rows in mysql exist
requinix replied to unistake's topic in PHP Coding Help
I, preferring to avoid subqueries whenever possible, would do two JOINs SELECT ml.* FROM mail_list ml JOIN rosters r1 ON ml.Code = r1.Code AND r1.SectorDate = '2016-01-04' JOIN rosters r2 ON ml.Code = r2.Code AND r2.SectorDate = '2016-01-24' unless there are multiple rows in rosters for each Code/SectorDate pair... -
Get rid of the @ on that fopen and look for error messages.
-
Why bother encoding it if you're just going to decode it?
-
$data is a string. You can't do ->items on it.
-
If you want true Word docs then I'd mention phpdocx. Not free. At my work we needed to convert HTML into something editable for our users to download, checked out options, and went with phpdocx. Does the job well enough. However, if you're running PHP from a Windows box, and don't have a problem installing Office on it too, then you can use COM to "script" Word into opening up HTML files and re-saving them.
-
Your form is sending the data to the thank you page. For validation to work the form must be sending the data to the page where the validation is running. So a) Make your form page do the validation (which it's doing now) as well as process the form b) Make your form go to the thank you page (which it's doing now) and have the thank you page do the validation (a) is easier because (b) means that you have to find a way to shuffle the data from the thank you page to the form in case of problems.
-
It is executing in the proper order: https://3v4l.org/7lALJ.
-
Splitting a string based on the last instance of a character
requinix replied to sn00pers's topic in PHP Coding Help
Please don't. You'll encourage me to never post stuff like that again. I only ever use it with really, really simple stuff. Like $variable && function_call($variable);or isset($array["value"]) && $obj->property = $array["value"];You can see what it's doing at a quick glance. No thinking involved. That thing with the regex and the list() is too complicated: you have to think "okay, what is preg_match() returning and what are the values in $match and why is list() skipping the first array value" and it's just a hassle. -
Splitting a string based on the last instance of a character
requinix replied to sn00pers's topic in PHP Coding Help
Don't use it as a matter of practice. It's just a clever way of doing two commands at once; if the regex failed then $ip and $port would be undefined. You know $x && $y? $y doesn't get evaluated unless $x is true, and if $x is false then it does not. And since preg_match() returns 1 (which is "true") if it matches, the assignment only gets evaluated if the regex matched. -
Because the code on your machine is not the exact same code you posted here. Even more so because FatalErrorException is not a built-in class to PHP, which means there is some other code somewhere that defines and throws it.
-
The code you have posted executes just fine: https://3v4l.org/VgRDX
-
Splitting a string based on the last instance of a character
requinix replied to sn00pers's topic in PHP Coding Help
Here's a quick one: preg_match('/^(.*)\d+)$/', "2001:db8:a0b:12f0::1:25", $match) && list(, $ip, $port) = $match;(I was deliberately avoiding doing this with my first answer) -
Do you mean, like, where is the most appropriate place in code to set it? There isn't anything in there that's clearly "this is a point where the user has chosen a particular language", but the closest would be where you check $_GET. if (isset($_GET['language']) && self::is_language_supported($db, $config, $_GET['language'])) { // setcookie(...) return $_GET['language']; }
-
Splitting a string based on the last instance of a character
requinix replied to sn00pers's topic in PHP Coding Help
Not being able to think of any nicer solution, I'd go with substr() and strrpos(). $ipport = "2001:db8:a0b:12f0::1:25"; $p = strrpos($ipport, ":"); $ip = substr($ipport, 0, $p); $port = substr($ipport, $p + 1); -
Then the error message is incorrect. Or the error message is referring to some other code that isn't what you posted.
-
That is not possible: (1) the index is actually "sessionvar" and (2) you did an empty check just before. What is your real code?