-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
you just burned yourself real bad in the SEO world.
-
no, I mean passing $_GET to your function instead of "GET" and then trying to get "GET" to turn into $_GET. function validateIfFilled($method, $fields) { $exploded=explode(",",$fields); foreach($exploded as $field){ if(empty($method[trim($field)])){ return false; } } return true; }; // pass the $_GET array as an array (not some "GET" string) if(!validateIfFilled($_GET, "email, password, address"))
-
reflection and forking are a couple of more "archaic" php things you can learn.
-
fyi this... if ($row['game_id']='$i') ...always evaluates true. = is the assignment operator. == is the comparison operator. Also, '$i' will assign the literal string '$i'. If you want to compare it to the value of the $i variable, you need to use double quotes. PHP does not parse variables in single quotes. Better yet, don't wrap it in quotes at all, since it is not necessary and is technically less efficient. if ($row['game_id']==$i) But on the note of $i...what exactly is your intention with $i and that condition? Because as it stands now, for each iteration of the loop, you... - set it to 1 - check if $row['game_id'] equals one (pending fixes above) - increment $i by 1 So something isn't adding up right here. If it is "working" for you as it is right now, then there is no point in having that $i stuff at all. But if you fix the condition as I have mentioned...then either the assignment or increment is pointless, as they cancel each other out.
-
We're here to help you learn something, not to do your work for you. Read some tutorials, make an effort to learn. If you get stuck with something in particular then feel free to ask. If you aren't interested in doing that, then hire someone to do it for you.
-
Fetching the File content, via file_get_contents
.josh replied to abhi_madhani's topic in PHP Coding Help
http://www.checkupdown.com/status/E403.html There are any number of reasons you could be getting that error but the short answer is that for whatever reason, the server is denying access to that page. It is possible that the server has script to detect that it is another server making the request (instead of a browser). You may have to get around it by faking any number of things, from headers to cookies to...anyways, you'd have to fake it by getting by setting stuff and getting contents with cURL instead of file_get_contents(). Or the URL could just be forbidden because that's how the directory/file permission is set. Have you tried to go to the URL in $source in your browser? -
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
-
@Maq: He's talking about some tutorials from a loong time ago. At one point in time a looong time ago there was a crash that resulted in a lot of stuff being lost forever. We did manage to salvage a sql dump with some of them and put them back up but not all of them. And then there were some that we salvaged but didn't put back up because they were too old or too poor in quality or people just didn't feel like it. Anyways, either Dan or Ron gave me a sql dump of the old tutorials table they managed to recover so that I could attempt to recover some of the tuts. It was pretty much fucked but I still happen to have it on my server. I threw together a quick script to view what there is...it's by no means a complete list (a LOT of stuff was destroyed) and even for what there is, it is severely mangled, but hey, feel free to peruse... you can go to www dot crayonviolent dot com slash old_phpf_tuts p.s. - don't make fun of my shit, I didn't exactly try to make it pretty, just somewhat legible.
-
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.