Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. .josh

    preg_match

    I see a number of issues with your regex, for example, one problem I see is that your patterns aren't accounting for newlines and whitespace between html tags. But rather than try to make your regex work, you instead use a DOM parser for this.
  2. So, some debugging 101 here.. you got an error that was essentially the result the variable not being within the scope of the function. So you updated your function declaration and now you are getting another error, which basically means you aren't passing to test what it expects. To me, this sounds like you likely essentially have the same issue before, except backing up the chain a notch. So, where/how are you calling test()? Did you update where you are calling it to have it actually pass a Database type object when you call it? If so, are you calling test() within some other function, and $database isn't exposed to it, in the same way it wasn't exposed here? Follow the trail, make sure $database is actually exposed, same as you already did here.
  3. Good lord you never give up do you. It must be tiring being you.
  4. I gave a random example to make a point that you don't know what the context is. Instead, you deliberately try to sidestep the point in a vain attempt to try and tear me down. You really do have issues man. As far as everybody in this community is concerned, you are the unwanted troll, and you know it.
  5. Different...what? Domain? I assume that's what you meant, because if the parent/child pages were on the same domain, they could share the cookies no problem (assuming you are setting the cookies to root domain name with no subdomain or path). So, if you meant that they are on diff domains, then the iframed page cannot read the cookies from the parent page, as this is considered cross-site scripting. To get around this, you can do the following: On the parent page: - read the cookies on parent page - append cookies as url params to the iframe url - generate the iframe with the url w/ the params. Then on the iframed page: - read url params from the url - store them in cookies (or do whatever w/ them). Note that the iframe page will store them in its own cookies scoped for that domain, which would be separate cookies from the parent page's domain.
  6. getCurrentPosition makes an asynchronous call to a service to determine location (assuming user accepts the popup prompt to allow it). So, you can't just assign it to x and get immediate results. It's just like doing an AJAX call where you have a callback function (success) when results are returned. So, you need to refactor your code to wait for success (or error) to be called. You can use pretty much any AJAX tutorial / script for tips/principles on how to work with async calls.
  7. One example of how this could be legit: maybe OP is looking for something to use in his editor's find box or w/ grep or something to find occurrences in files to help narrow down stuff he needs to search for. Maybe that is the case, maybe it is not; without context we do not know. Therefore it seems to me the best (first) response would be "What is this for? Provide some context." And yet I don't see that from anybody. Failing that, it seems to me the best response would be to provide the asked-for solution, under the assumption that OP's reasons, while unknown, are legitimate. Failing that, I'd keep my mouth shut, because telling someone something isn't the right tool for the job when I don't know what the job is, sounds like a pretty fucking stupid thing to say.
  8. In that example, there is no difference. http://php.net/manual/en/language.types.string.php for reference on the difference between single vs. double quotes.
  9. Yep, that is exactly my job. Or was, so take it for what it's worth. But I know exactly what I'm talking about when I'm pointing out that same behavior in you. You're a really smart guy and bring a lot of good knowledge and best practices to the table. But that's not a free pass to be an asshat to people. "Dr. House" types generally don't stick around and make real friends, despite what the TV shows portray. If you want to be more welcomed in the community, phase out the "you suck" vibe. You seem to have no issues being public about that, so I have no issues being public with this.
  10. To be clear, what requinix is really saying is you need to stop being so negative. 99% of your posts involve saying someone or something is "stupid" (pick a better negative word if you like). Flip a coin: heads you explain why, tails you just bitch.
  11. I don't hate you. I just don't like your attitude about jQuery. More importantly, I don't like how that attitude manifests in your posts, how you look down on people who use it or even mention it. You talk about all these not-so-smart people who call themselves programmers but can't write a line of javascript because they are wasting their time with jQuery, and I don't necessarily disagree with you, but running around pointing this out and how you aren't one of those not-so-smart people doesn't help the situation. All it does is make you sound like a pretentious, elitist asshat. You weren't really interested in helping OP out. All you really wanted to do was get on your soapbox and wag your finger at OP about jQuery, and then you threw out a few half-hearted words pointing vaguely in the right direction to try to justify it. This makes you look like a pretentious, elitist asshat offering up no actual solution. If you are truly here to help and stick to your (misguided) anti-jQuery principles, then help end this pandemic of stupidity by posting a pure js solution and explaining to the OP how it works and why it is a better solution. Otherwise, don't post at all, because as Dr. House taught us, people only tolerate pretentious, elitist asshats if they also provide actual solutions.
  12. Hey I was a js "purist" for many years too, I know all about it. And I still advocate learning vanilla before frameworks. But I now also advocate learning them and using them, as well.
  13. Still anti-jQuery eh? You do know that jQuery is js right? The solution you offered up would be the same syntax, even the "jQuery" way, because jQuery is js. If you are coding vanilla js properly, under the hood it's going to be the exact same as jQuery. The only benefit not using it is for example if you have a simple site with minimal js needs in which case jQuery or the like is extra bloat. Not that it's *that* big a deal, what with ability for things to be cached and all.. I do appreciate someone who likes the vanilla way.. lord knows I've been having much trouble trying to hire someone who actually knows vanilla js.. but you're only hurting yourself by not learning frameworks like jQuery. What if you come across a client willing to throw lots of money at you to fix something or dev something but requires knowledge of jQuery? Sure would be a shame turning that down.. Or..what if they hire you to do something for them and you do it the vanilla way and they're all like "Uh.. we have jQuery on the site.. what's with all this extra unnecessary code?" Are you gonna argue with them your (misguided) principles?
  14. .josh

    regex &,

    str_replace matches for exactly what you specify, no patterns (no regex). The first argument of str_replace can either be a string or an array. This is fine, because you aren't trying to match for any patterns. $var = str_replace(array(',','&'),'',$var);
  15. .josh

    regex &,

    Replace them with what? Also, you probably only really need to use str_replace not regex.
  16. This isn't a javascript problem either. It's a browser setting problem. Go to File > Page Setup and File > Print.. and make sure relevant settings are enabled (e.g. make sure Page Setup > Format & Options > Options > Print Background (colors & images) is checked). If all those look good, check your printer settings from whatever software came with your printer. IOW basically it sounds like somehow your printer settings have been changed to "color saving" or "mobile" type options.
  17. You can't use variables in a regex literal. You need to create a new RexExp object to do it. Example: var hints = 'foobar'; var myRegExp = new RegExp(hints+"\\s=\\s'(.+?)';"); console.log(myRegExp); // output: /foobar\s=\s'(.+?)';/ Also note the necessity to double escape backslashes.
  18. Also, adding the / delimiters should have gotten rid of the warning. So if it's still not working, then that's a different issue and your code probably wasn't working as intended even with eregi. For starters, you are providing an empty string as the 2nd arg. that is the "source" string to match stuff from, in both eregi and preg_match. Your pattern isn't going to match anything in an empty string.. Also, you didn't make the preg_match version case-insensitive (read the sticky link). Beyond that.. you're going to have to provide more details than "not working".
  19. I envision a future where everybody will actually read stickies and the world will be a better place. Then I wake up and laugh at that absurd fantasy. http://forums.phpfreaks.com/topic/268091-ereg-and-deprecated-error/
  20. it's very easy finding someone to work one-on-one. I suspect what you really mean is it's hard to find someone to work one-on-one with the compensation you are offering for said service.
  21. Variables aren't parsed inside single quotes. You need to use double quotes or break out of the single quotes: $_SMS = '353871111111'; $homepage = file_get_contents('https://www.somedomain.com/secure/messenger/formpost/SendSMS.aspx?username=myusername&account=%%%%%%%&password=password&recipient='.$_SMS.'&body=test&plaintext=1 ');
  22. lioslios that's not what you originally asked, not that you were being very clear to begin with, nor are you being entirely clear now. But in any case, we're not here to do your work for you. I've given you more than enough to point you in the right direction. You need to make an effort to do it yourself. If you get stuck on a specific thing, show what you've tried and what's wrong with it and we'll try to help. But If you want someone to do your work for you, I suggest you offer to pay for it (in the freelance section or on a freelance site).
  23. /* * @param $time string 24 hour time 'hh:mm' * @param $numParts int number of parts to split day cycle by * @return int day part */ function getDayPart($time, $numParts) { $numSeconds = 0; $secondsPerDay=24*60*60; $time=explode(':',$time); $numSeconds+=$time[0]*60*60; $numSeconds+=$time[1]*60; return floor(($numSeconds/$secondsPerDay)*$numParts)+1; }
  24. Okay you're right, thanks for pointing me to that; learn somethin' new every day.
  25. Yes, it is technically true that a user could input some bad js but since it's just echoing back to the same user, there's no real danger. After all, the user can just straight up js console whatever they want on the site to begin with. Cross-site scripting becomes a danger when you take user input and then allow that to be displayed to all visitors. So for example, if he were to take that posted info and store it in a db or something and then retrieve that info and display it generically on a page to everybody, that would make for potential cross-site scripting. One example of this is posting comments on a blog. Or forum posts on a thread. But near as I can tell, that is not the case in this scenario; this scenario involves echoing back out that info only to the user who just entered it in.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.