Maq
Administrators-
Posts
9,363 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Maq
-
Check the session variable to see if a registered user is logged in before you increment the vote count. If they're not then throw an error message.
-
Try this, an example from the manual: isEmptyDir($dir){ return (($files = scandir($dir)) && count($files) } ?>
-
Yes, but you should be fixing your errors before putting your code live. They are still exploitable and a security concern.
-
That's great to hear, it's nice to see threads like this.
-
I see, but doesn't the ORDER BY and GROUP BY take care of that? My logic is that if you're ordering by 'ID DESC', which orders the list greatest to least by ID, and 'GROUP BY Sport', which would rid duplicates, then you wouldn't need to use MAX() because these 2 clauses assume that.
-
Isn't that essentially the same query I gave him?
-
Check a value for one key in a multi-dimensional array
Maq replied to haku's topic in PHP Coding Help
Not to my knowledge, the shortest code is probably almost the same as what you already have: foreach($arr as $a) if($a['age'] == 3) echo $a['name']; The only other thing I can think of would be using the array_search() function and passing the returned key to the array, but I think you would still have to have some kind of iteration. Something like: echo $arr[array_search(3, $arr)]; -
That too One more thing, use tags. Improves readability.
-
Kind of. You would have to match on those characters and patterns. It would look something like: $html = "bold textclick me"; $pattern = "~^(.*)(.*)~i"; preg_match_all($pattern, $html, $matches); echo "Bold: " . $matches[1][0] . " href: " . $matches[2][0]; ?> - The (.*) will capture any 0 or more characters in that position and add it to the $matches array. - The '\s', takes care of whitespace. - I had to escape the '.' because they are special characters (wildcards). So by escaping them, the pattern will take the dots as literal dots. - The tildes (~) are my delimiters and you need them around your pattern. - Finally the 'i' flag is for case-insensitivity. For more information read the tutorial here on phpfreaks - Regular Expressions (Part1) - Basic Syntax. You should also take a look at the function documentation from the manual - preg_match_all.
-
I don't think 'fight' would be the best word, maybe swallow whole? Sorry Pug, but I'm sure you would serve as a delicious hors ‘d orderve.
-
You can accomplish this with either file_get_contents or cURL and preg_match_all. If you do a search in either here, or the PHP Regex section, you should be able to find helpful threads and similar ideas that will assist you. Good luck.
-
There's one on phpfreaks but it's database driven, which is worth learning and better in the long run anyway. PHP Basic Pagination
-
You should have thrown the Grizzly Bear in the mix. I mean look at their advantages: Even though the Polar Bear is bigger, I think the Grizzly would take it out. It's like fighting a 300 lb. fat kid who gasses in less than a minute, render him useless. I vote for the Kodiak.
-
So you've checked user id in the database to make sure it's not being updated? (SELECT * from users WHERE id = 31) If not, how do you know the table isn't being updated? Doesn't make any sense. I guess I'm missing something. If the query was invalid then the error reporting would display an error for you mysql_query call. I guess you can add the or die clause to see if your query is failing: (make sure to take it out when we're done) $query=mysql_query($_rs) or die(mysql_query()); By the way, if you are using a single table you don't need to have the format 'table'.'field', you can just do 'field'.
-
At first, I thought Polar bear. I remember hearing they are the biggest predatory bears on the planet, then, after reading this, I change my answer to Kodiak, good thing I didn't vote yet.
-
Echo out '$_rs' to ensure the correct values, if any, are being passed to the '_updateparticipant.php' script.
-
Help with finding a tutorial? Here's one, with what looks like, some good documentation. http://arshaw.com/fullcalendar/docs/
-
I understand the concern about the hyphen, but why would it be necessary to add a bang to the end?. Gotcha now, I was being a little dense earlier. Thx CV.
-
This makes the minimal 2, did you have a specific setting? Try this: if(preg_match("/^[a-z\d][\w-.]{1,14}/ i", $user) )
-
[SOLVED] Hey - question about design of specific part of Blog.
Maq replied to mY.sweeT.shadoW's topic in Application Design
Would you mind sharing for future references? Also, please mark as solved, bottom left right above "quick reply". -
So if you hard code that value in, you still get incorrect dates? Try this and tell me what you get. $i=1; $startDate = "01-06-2009"; echo $startDate; echo " "; $finishDate = "30-06-2009"; echo $finishDate; echo " "; $startDate = date("d-m-Y", strtotime("$startDate +$i Day")); echo $startDate; echo " "; $finishDate = date("d-m-Y", strtotime("$finishDate +$i Day")); echo $finishDate; echo " "; ?> My output:
-
Yes, it is a reserved word - http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html You need to put backticks around it (`Index`), rather than single quotes.
-
Works fine for me, tried $i=1; and $i=5. How are you initializing $i?
-
Like we said, you should have your dates as type 'DATE' or 'TIMESTAMP' so you can perform logical operations like this.