-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Why not just pass the array to the function to begin with?
-
You can... - Put it in a hidden field as mjdamato suggested. This will make it available as either a GET or POST variable, depending on what method you use for your form. - Append it to the form action's URL. This will make it available as a GET variable. - Start a session variable, holding that information. This will make it available as a SESSION variable, without depending on it being passed again from the client. In and of themselves, none of these are particularly the "best" way to do it, though if you are following some kind of convention in your coding, you might wanna stick with one way over mixing and matching.
-
Need help slightly altering this pretty simple script...
.josh replied to asmith6's topic in PHP Coding Help
You can't do this with php, as it is server-side. You have to do it client-side with javascript. Example: var d = new Date() var gmtHoursOffset = -d.getTimezoneOffset()/60; This will give you the +/- hours from GMT, relative to user. So for instance if you are in CST timezone, gmtHoursOffset would be "-6". Easy enough to get it if you are doing something like processing a form...just include the value as a hidden field. -
exec() will let you execute commands from command line from within script.
-
Need help slightly altering this pretty simple script...
.josh replied to asmith6's topic in PHP Coding Help
Time is based on the server's local time. So if it's showing 5hrs "earlier" than your time that means your server is in another time zone than you. You will have to adjust the script accordingly if you want it to display in your time. You can do this by doing the math manually or else use date_default_timezone_set() -
cron job
-
Helped need to get the value,id of the item clicked in an iframe
.josh replied to bindiya's topic in Javascript Help
is the iframe content on the same domain as the parent? If not, you cannot access that content. -
The only thing I technically see "wrong" with it is that \w matches more than just letters. It also matches numbers and underscores. Also \d technically will match more than straight numbers. But other than that, that should return true as expected, at least for "abcd12". To be more explicit you should use return /^[a-zA-Z]{4,}[0-9]{2,}$/.test(text); Perhaps you should first explain what "it doesn't work" means to you, and also perhaps show some more code....is that all of your (relevant) code?
-
utoh, Phil is tryin' to booty call
-
fyi you should be doing if ($do == true) { = is assignment operator, == is equality operator.
-
In your query ...GROUP BY some_column
-
Okay so first off, you are getting the error because a regex pattern is supposed to be wrapped in a delimiter. When you do "/books/" you are expecting to match for "/books/" but what is really happening is preg_match() is using the / as the delimiter and matching for "books". But with "/5" it's trying to take the / as the delimiter and you don't have the matching ending delimiter. You can use most any non-alphanumeric character as the delimiter, such as the / as I have just told you. But since you are working with URLs, I suggest you pick a delimiter that isn't /. So for $pattern, if you want to match for "/books/", $pattern should really be for example "~/books/~" and ~ is the delimiter. Same with "/5" : use "~/5~" 2nd thing. If you are just looking for exact strings within a string instead of patterns, you shouldn't be using regex, as it is less efficient. For instance there is no pattern in "/books/" it's a static string. Regex is for matching something that follows a pattern. Instead, use something like stripos() to check if the string exists in the URL (and with stripos() you don't use delimiters) Here is an example of what you should be doing: function find_urls ($list,$patterns) { if (!is_array($list)) $list = array($list); if (!is_array($patterns)) $patterns = array($patterns); $matches = array(); foreach ($list as $url) { foreach ($patterns as $pattern) { if (stripos($url,$pattern) !== false) $matches[] = $url; } } return $matches; } example // array of URLs $list = array('http://www.somesite.com/books/blah','url','blah.com/5','url','url'); // array of all the patterns you want to match $patterns = array('/books/','/5'); // get matching urls $matched_urls = find_urls($list,$patterns); // output echo "<pre>"; print_r($matched_urls); output Array ( [0] => http://www.somesite.com/books/blah [1] => blah.com/5 )
-
$string .= (substr($string,-1) == '-') ? '' : '-'; $string = preg_replace('~\s+~',' ',$string);
-
You only need to have connection code on a page where you are actually wanting to make use of a database. Judging by his code, he has his connection code, authenticates the user with it, and if everything is valid, he starts a session variable. Then on subsequent pages he checks if that session variable exists. You do not need to have database connection code on every page for this. Sessions and databases are two different things.
-
If you want to include more than one line of code in a condition you must wrap it in { ... } <?php session_start(); if ($_SESSION['username']) { echo "Welcome, ".$_SESSION['username']."! <br><a href='logout.php'>Logout!</a>"; } else { ?> <a href='register.php'>Register?</a> <form action='login.php' method="post"> Username: <input type="text" name="username"> <br> Password: <input type="password" name="password"> <br> <input type="submit" value="Log in"> </form> <?php } ?>
-
Your problem is on line 42
-
What Type of Trends and Businesses Can We Expect in Web 3.0 ?
.josh replied to chaseman's topic in Miscellaneous
Well like I said, I personally do not completely disagree with labeling web eras - I just have minor beefs and differences in opinion about where those mile markers should be placed. But then, everybody does. With marketing, it basically boils down to someone having the balls to place and declare a marker and then see how many people agree with it - IOW success is measured by popularity. As you can see all over the place, making decisions based on popularity isn't always the correct path, but you can't please everybody all the time and overall "majority rules" is about the fairest thing you can do most the time. Example: I can scream all day that the sky is blue and 99 people can scream it is red and I can be absolutely right and they can all be terribly wrong but if 99 out of 100 people want to structure living together around the notion that the sky is red, it makes more sense for me to STFU or GTFO. -
What Type of Trends and Businesses Can We Expect in Web 3.0 ?
.josh replied to chaseman's topic in Miscellaneous
But I am thinking in global terms....If you have a website and 100 people are using it and then suddenly 1000 people are using it, yes, that is significant. However, the website itself is still the same site, offering the same things, just to more people. I do not disagree that throwing more people into the mix gives more potential to spark change. But to say that throwing more people into the mix is the change that pushes us from Web 2.0 to Web 3.0 is not accurate, it does not justify relabeling of the site or experience. But that's exactly it... you are going from web 2.0 to web 2.0 being used more globally - being used by more people. You are not doing something that justifies renaming web 2.0 to web 3.0. Well yes, that is more or less exactly what I'm saying. You will find that the more technical people are (people who actually do the coding, programmers, etc...) the more instances you will see of people lol'ing about this whole "Web 2.0" label to begin with, for exactly this reason. "Web 2.0" is a marketing term, something the sales people labeled the current web "experience" as a gimmick. And to an extent I will not bitch about it being labeled as such. You are right, change is a gradual process. We occasionally take "snapshot" looks at how things currently are and label them accordingly. That's how it is with everything. Look at music for instance. All music is put into generic "genre" bucket(s) but you know if you get nit-picky about it, most music is a bit more ambiguous and can't perfectly fit into one bucket. And then moving up, music is put into broader categories like "90's music, 80's music, 70's music etc..." and people think of each decade as being predominantly one genre over the other. For example with 60's to 70's music most people think "hippie music", even though you know if you start looking at it more in a more granular way, There are a lot of songs and artists during that time that are not "hippie music" and there was a lot of evolution in the music industry that had nothing to do with hippies at all. The overall point I'm trying to make here is that yes, change is gradual but in order to make categories and labels like "Web 2.0" or "Web 3.0" you have to abstract out details and individual steps in the change and look for "mile markers" so to speak. Yes, the fact that FB can be utilized by people all over the world vs. only English speakers is a significant thing but it brings the same Web 2.0 experience to more people, not create a new Web 3.0 experience for everybody. And again, throwing more people into the mix will most likely act as a catalyst for new ideas and changes that will eventually lead to a "Web 3.0" mile marker, but throwing more people into the mix in and of itself is not a top level mile marker. If it helps, think of it in terms software versions. The (simplified) convention of software versions is that each major marker is measured by Widget X and then "minor" updates are measured by "Widget X.Y". All kinds of little things are added between Widget 1.0 and Widget 2.0 and sometimes released as 1.1 or 1.4 or whatever but the "snapshot" is going from 1.0 to 2.0. Applying this concept to "Web X.0", the ability to make websites multi-lingual would be the equivalent of saying we have gone from Web 2.0 to Web 2.1 or Web 2.5 to 2.6 or whatever. This is the primary difference between computers and abstracting code and humans abstracting ideas. With computers, yes you are abstracting, but in the end, everything is accounted for. With humans, in order to abstract, we must find predominant patterns and disregard the rest to feasibly look forward. That is not to say that things are totally lost, it's just that we simply consider only the most predominant things when trying to analyze and predict. -
What Type of Trends and Businesses Can We Expect in Web 3.0 ?
.josh replied to chaseman's topic in Miscellaneous
If a year from now FB seamlessly works in all languages, what does that really mean? All it means is that more people will have access to the same Web 2.0 experience. Absolutely nothing changes for myself or anybody else that is currently able to use FB. You aren't talking about coming up with a new tool or a new way of experiencing the web. All you are talking about is making a tool work for more people. This isn't a new Web 3.0 experience, it's just a more efficient Web 2.0 experience broadened to cater to more people. And I more or less agree with this (the "less" part really comes into play when I disagree with you (perhaps unintentionally) sanctioning monopolies, but that's a different topic altogether), however bringing everybody closer together does not really equate to a new experience. It just means more people showing up to the party. But it's still the same party. Now, if the party did not previously have alcohol and all these new people brought some booze, well that's probably going to result in a new "Web 3.0" experience. You are right, more often than not the underlying technology goes hand-in-hand with what we would ultimately call a "Web X.0" experience. But the act of people showing up and even bringing some new tools into the mix in and of itself does not equate to said experience. Someone in the existing party could have easily thought to bring alcohol, sort of thing. We as humans like to categorize things. In order to do this, we must reduce and abstract into shorter terms and labels so that we can see a bigger picture. Like with a puzzle. Each piece is needed to complete the picture. But when you finish it and are looking at the picture, you are no longer thinking about it from an individual-piece perspective. This doesn't mean pieces of a puzzle disappear, it just means that you are now looking at it in broader terms and not thinking about those individual pieces any more. A program being able to work in any language is a feature, an individual piece. It is something we will eventually come to expect from all programs everywhere, and will not in any way actually define a given program. We actually to a degree already expect this of programs, especially on the web...we just currently don't do a very good job at it. And on that note... Yes, this has been a big stumbling block for people for a long time now. All languages have very specific rules and exceptions and limits to vocabulary (notwithstanding new words being made as technology and ideas etc.. progress). Point is, at its core, any language is the same as a computer language, and with the right logic and lookup tables, it can be very easily translated, even the intent, as long as the language itself is used properly. So the problem is not so much being able to translate from one language to another in it's "proper" form. The problem is that most (if not all) people themselves fail to properly use a given language 100% of the time. I think a good next step for trying to create a digital Rosetta stone is to work on a program that will try to correct and guide people into writing something properly to begin with. Basically a better spelling/grammar checker/suggester for languages. Something that will look at a given string and spit out errors to the user and force them to fix their spelling/grammar errors and try to reform it more properly in their own language and have the user work with that to eventually write something properly and then run it through a translator. I am not suggesting that industries/companies that expect you to be in front of a full monitor and keyboard and mouse are going to outright die out. I am just suggesting that a desktop medium will no longer be the major focus. Try to visualize never ever going on the internet ever again unless its from a mobile phone. Now visualize if everybody did the same thing. Who really stands to lose the most out of this? Okay sure, there are going to have to be a lot of changes from a lot of people - changes that are already taking place. Wordpress will focus on making a mobile version of itself. Templates will be mobile based instead of big-screen desktop based. Apps, plugins, widgets, etc... will all continue to be made, just focused on mobile devices rather than desktop devices. IOW I don't think anybody who makes their money off the internet is really gonna lose their job over it, as long as they are willing to shift their focus a bit. --- And of course, all of this that we've been talking about is just speculation based on one trend. Who knows what tomorrow will bring? Maybe next year someone will create a chip to implant into people that will remove the need for a wallet-full of id cards and cash cards etc... and will let you close your eyes and access some 3d internet or hallucinate driving directions (I mean come on, how cool would it be to see big arrows magically appear on the road where you are supposed to turn, little HUD display in your eyeball showing stats for various things around you, etc...) or just think about someone and chip calls someone else and all you have to do is talk or even just think about talking and it sends it to someone else's brain and they "hear" you talking. Internet in your head sort of thing. Science fiction of today is science reality of tomorrow. The more I sit here and think about the future, as long as I base my thoughts around three assumptions: a) There is no such thing as impossible, we just haven't figured out how to do it yet b) We are not destroyed (zombies, AI, war, meteor, rapture, etc...) It is inevitable that the internet will completely cease to exist in its current form. And if I were to try and give an ETA based on my amazing powers of observation* about rate of discovery/innovation vs. rate of what I like to call "all the b.s. involved in withholding said discoveries/innovations from the public in order to maximize profits", I think it's highly possible the internet as we know it will cease to exist within the current generation's lifetime. *No I have not steadfastly gathered data and no I will not do so or present data. Feel free to disregard anything I see because of this, but I must warn you, my ability to detect patterns and trends really is amazing. For instance, I predict a 94.3% probability that you will drink something within the next 24 hours. BE AMAZED. -
What Type of Trends and Businesses Can We Expect in Web 3.0 ?
.josh replied to chaseman's topic in Miscellaneous
All of this is tongue-in-cheek though. Zombie apocalypse will render all of this moot. -
What Type of Trends and Businesses Can We Expect in Web 3.0 ?
.josh replied to chaseman's topic in Miscellaneous
I think even though efforts are being made to "concentrate on translation, the semantics and making the internet more global and not localized and separated in geographical areas," I'm gonna have to disagree with this being called "Web 3.0". IMO this is more of an "under the hood" thing that will just make this "Web 2.0" thing (and future "things") better. These things you mentioned are underlying technologies, the things that will make "Web X.0" work (better). Look at how we even program. Object Oriented Programming. What is the central theme of OOP? Take something, find a pattern, abstract it away. IMO this is what we are doing now with making technologies talk to each other better. Abstracting away the technology from the humans so that it can work without human differences. Make the technology global to make the end product local. IMO people aren't going to officially start calling something "Web 3.0" until someone thinks of something that is more visible and tangible. It's like with clothes. There have been innovations in the materials and machines and processes used to create the clothing to make better quality, cheaper stuff more efficiently. While we do praise these things, we (usually) give it little to no consideration when putting a label on fashion styles. It is part of it yes, but it's not the part we really look at when defining on a common level what it is. New clothing styles are created. And there's some overarching theme going on from year to year, decade to decade, generation to generation. Dress lengths have gotten shorter. More buttons, less buttons. Sleeves and no sleeves. Colors and "themes". And the list of form and function on a visual level goes on and on. And snapshots of these decades and even eras are what we would recognize as the "Web X.0" of the clothing industry. Currently the web predominantly focuses on being in front of a full desktop monitor with a full keyboard and a mouse. Over the years we have seen this focus shift to being more mobile-friendly. I think based on this trend, we will eventually see a web that puts most of its focus on being communicated and presented from phones and other (small) mobile devices. I think this is because the vast majority of the population is not really interested in living their lives in a chair in front of a computer. I think people want the internet to be a tool put in the palm of their hand that they can use to enhance their real-life experience, not replace it. People basically want a magic wand to wave and make shit happen. So we see mobile phone technology being developed to act more like a mobile computer that can be used as a phone. IMO we can't even rightfully call a mobile phone a "phone" anymore, because it does so much more than just let you talk to people. We have a million apps floating around that do a million things. Most are somewhat entertaining at best, useless at worst. But then there are a lot that are useful, that truly fit into our notion of having a magic wand. For instance, utilizing GPS and internet technologies to show me on my phone a map of where I am and where other things are. "Where are the 5 closest gas stations to me and how much is their current price of gas?" "I need new shoes, show me the 5 closest places that sell shoes and what sales they have going on." "What movies are playing and when?" You can sit in front of a computer and find these things out. You can go to individual websites or even websites that will aggregate and present that data for you. But that requires sitting in front of your computer, living in front of your computer. Phones can already do these things now, so I can drive around and see I need gas and find out where's the best place to go while I am out living. I can go out shopping and do research in the field for where to go for the best deals. I can hook up with a chica and decide to take her out to the movies or whether to even bring it up without having to commit to actually going to the movie theater. IMO this is what the next big "thing" with the web will be about - focusing on what we can do to enhance our real-life experiences instead of creating virtual ones. So the question is, what more will our electric magic wands do in the future, that we can rightfully declare it the "Web 3.0" experience? All of these things can and will use technology that is ambiguous on the global level, but the use for it will be local - where you are standing right now and what's around you. -
What actually happens after php interpreter parses code?
.josh replied to blacktie524's topic in Miscellaneous
Trolls do all the actual legwork. They receive instructions for doing things like open db connection so they run to the db to fetch whatever info you ask (or throw information into it, etc...). Nobody likes trolls, you see them stirring up shit on forums all the time, but we put up with them because they are vital for making the internet work. Also they are kind of funny sometimes. -
Force new topics to have code in them??
.josh replied to cunoodle2's topic in PHPFreaks.com Website Feedback
We could spend all day coming up with legitimate questions that do not require the posting of code. I agree that it is annoying when someone asks for help and doesn't bother to make the effort to provide relevant details, but there's no way we can really automate qualifying posted content like that within an acceptable margin of accuracy. Anyways, when I walk into a thread and see that someone clearly hasn't made an effort to properly explain a problem and give details, I usually walk right back out the door. I'm not here to help people overcome lack of common sense, and I know from experience that 9/10 times you will be spending much of the time just trying to wrestle info out of someone and get them to stop being retarded about listening to you, than actually fixing the problem. The overall point here is that most people don't "forget" to do things like post relevant code/details. They simply don't do it because they don't think about it at all. Or they somehow think you're psychic. We have posted general rules and guidelines for making posts and even doing it the smart way. We even up until recently w/ forum upgrade had in big bolded red letters a link to the rules/guidelines right above the post button (it got lost in the forum recent forum upgrade and needs to be added back). If people don't bother with that, they aren't going to bother with this other stuff. To sum up, I think I can speak for most people here in saying that we aren't interested in helping people who can't be bothered to help themselves or make an effort on their end. We're here to teach, not do people's work for them, and the more we hand-hold them, the more we promote the notion of not making an effort on their end. -
Most Optimised way of Blocking Whole Country...
.josh replied to natasha_thomas's topic in Miscellaneous
"deny from all" That will ensure they are all blocked