-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
elseif conditional expression evaluates to TRUE when it should not?
requinix replied to terungwa's topic in PHP Coding Help
It's not redundant because you needed to distinguish between an empty string (0) and input that fails the pattern constraint (100). I was pointing out the = single equals sign. That means assignment, even inside an if condition, so when the next bit of code executes (the regex check) $string will always be "". It should be a == comparison. -
How to merge several product lines into one
requinix replied to dennis-fedco's topic in PHP Coding Help
I suggest you get an explanation from the user(s) as to why they want that change. Seems to me like the biggest gain is that they can use the "main" parameters to find all products, without caring very much about the specialized parameters. If that's the case then you can change the procedure a little bit as a compromise between the existing system and their desired changes: let them select the main input parameters to start, and optionally allow them to choose a product line and then the specialized parameters for that product. As to the technical questions, it'd help to know how the system is architected - like the overall flow to the code (like does it use MVC to any extent), where code is loaded from (like is it a bunch of included files or a bunch of autoloaded classes), and the structure of the files themselves (like whether the HTML output is located inline with PHP code or segregated). -
elseif conditional expression evaluates to TRUE when it should not?
requinix replied to terungwa's topic in PHP Coding Help
if ($string = '') -
empty() only works on expressions, such as function calls, as of PHP 5.5. Guess you're using 5.4 or 5.3 (hopefully nothing earlier than that). The easiest solution is simply to not use empty() in those situations. You should also make sure the PHP version you're using to develop and test with is the same version as is actually on your live site. To avoid this kind of problem in the future.
-
First, you need CURLOPT_RETURNTRANSFER. Then $data will be a string and you won't get output immediately. You might already have done this for all I know. There's a lot of manual work you could do to support encoding types. Don't do that. Instead use CURLOPT_ENCODING: cURL will not only set the Accept-Encoding header for you but automatically decode the content as well. $url = 'http://myurl.com'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_ENCODING, ""); $data = curl_exec($ch);
-
If you're using a ton of variables then you're going to need a ton of =0s. Any particular reason you have to zero them out? What's your code, in case there is an easy way?
-
Ah, I thought you needed another join... Right, and ORDER BY pts DESC, wins desc, `2` desc, `1` desc, `0` desc, heat asc(maybe heat desc, don't know the values) will do exactly that. Sorting goes left to right in that list until the values don't match, so if pts, wins, 2, 1, and 0 all match then it'll end up sorting by heat; if they don't then heat doesn't matter because one of those others determined the sort order.
-
JOIN that heat table in and add the heat column as the last thing to sort by.
-
I know you don't like regular expressions, Jacques, but this is one case where a regex definitely can do it. Strings and parenthesized expressions make it a bit trickier but it's still possible. '/\bprintf\("([^"\\\\]|\\\\.)*"([^\'"()]*|([\'"])([^\3\\\\]|\\\\.)*\3|\((?2)*\))*\);/'1. Word boundary 2. "printf(" 3. An opening double quote, the contents of the string (accounting for escape sequences), and the closing double quote 4. Some amount of a) stuff that isn't a quote or parenthesis, b) a quoted string like in #3, or c) parentheses that recurses back up to #4. 5. ");"
-
I'd use in_array. elseif (in_array($subcategory_id, array(400, 450, 500, 760)))There are cleverer tactics though, depending on the rest of your code...
-
Decoding Quoted-Printable MIME attachment corrupted zip file
requinix replied to mcfloyd's topic in PHP Coding Help
$attachmentParts = explode("\n", $currentPart->getContent()); will cause problems if the newline is a \r\n. Try $attachmentParts = preg_split('/\r\n?|\n/', $currentPart->getContent()); -
That is an incredibly vague description. Need to know a lot more than that. Oh, and post whatever code you've written so far.
-
1. Make phone_number private 2. Write __get/set to get and set that value 3. Write __call to provide the filtering or whatever support
-
Version 3 (latest, I believe) works with SQL Server 2005 or later. The version of IIS doesn't matter for the driver itself.
-
I'm positive there is. Can you post the CREATE TABLE statement for the table? You can use a SHOW CREATE TABLE _AAPL to get it. Maybe with a couple rows of sample data to see how it's being used? It'd also help to know some of the kinds of queries you're running against it.
-
Think again.
-
I don't see any logic errors. I do see a typo in your SQL. Unless I'm mistakne, of coures.
-
Right. Same question, same answer: use a regular to send the inputfield value to PHP, then PHP can figure out the value of $one and put it in outputfield's value directly. And then when you have that working you can learn about AJAX, which lets you send stuff from Javascript directly to PHP, read the response directly, and do whatever it wants, without having to use a form that will (re)load the page.
-
You can't mix and match Javascript and PHP like that. For now use a regular and get it working. Then learn about AJAX and you'll be able to do this the way you want.
-
Fatal error: Call to undefined function tidy_repair_string()
requinix replied to terungwa's topic in PHP Coding Help
It is not. Not really. You have to have the tidy extension installed on your server. -
Off the top of my head, SELECT AVG(IF(/* date in range 10 */, volume, NULL)) AS range10, AVG(IF(/* date in range 21 */, volume, NULL)) AS range21, AVG(IF(/* date in range 50 */, volume, NULL)) AS range50, (etc) FROM _AAPL WHERE /* date within the widest range you're counting */Because AVG() will completely ignore NULL values. But... are you using a table for each stock quote? That's not good.
-
Conditional Logic set on onbeforeunload event
requinix replied to n1concepts's topic in Javascript Help
Or you could call process() regardless of everything and in there decide whether to show the cancellation notice. <script type="text/javascript"> // Process to advise member by leaving page without clicking "Submit Record" button, canceled the entire process / update function process() { if (viewer == jscheck) { window.open('http://www.domain/canceled.html', '_blank'); self.blur(); } } </script>Because now, all you're doing is at the moment the page loads, deciding whether to define the process() function or not based on variables whose values can't possibly have been changed because the page only just now loaded. -
It's a pretty straightforward process: 1. Record their email somewhere in a database table as well as an empty value for the date they were last sent the digest 2. Record the various options they're subscribing to in a(nother) database table 3. Set up something on your server to automatically execute PHP code every week - look for "cron" or "scheduled tasks" or whatever 4. Make the PHP code send the newsletter by looking up each member and their preferences, then by looking up all the new jobs that (a) match the preferences and (b) were posted after the last digest was sent 5. Update that last digest date when you send each email Before you do all that, though, you should make sure you have emailing set up on your server. Use PHPMailer or another PHP emailing library to make and send the emails (they will do it better than you can) and check that you receive them (and aren't being marked as spam). You may have to change your mail settings to go through an email server, like Gmail, for everything to work.