|
nbv4 posted:is there a more elegant way to do this?: When this is absolutely neccesary I go with ${$variable} = "whatever"; . I'd have to see a bigger section of your code to see if there was an easier/cleaner way around it (which there usually is).
|
# ¿ Apr 4, 2008 13:45 |
|
|
# ¿ May 8, 2024 15:21 |
|
Hobo posted:This is a more general question rather than a what's wrong with this code question. Follow the path of the form being submitted and you'll find where phpBB is handling the request, from there just input your own login code. The action attribute of the login form will say something like "login.php?step=2" then just find that part of login.php and hey presto, you can use the login.
|
# ¿ Apr 15, 2008 18:35 |
|
Hobo posted:What do I do about the SID that phpBB3 passes? Not sure how it generates that. If you're just hijacking the login so you can log yourself in elsewhere you don't need to follow that. You want it so you login you user to your main site as well as phpbb when they login? Well just find where phpbb logs in and add your own login code to that section, no need to follow phpBB's lead.
|
# ¿ Apr 15, 2008 19:40 |
|
LastCaress posted:Thanks, it worked, except for this line that doesn't return the clube name :\ Because it needs to be $getclub['name'] you've left out the quotes again. You have to use ' ' here rather than " " because of how the variable is called in the string.
|
# ¿ Apr 21, 2008 16:40 |
|
sc0tty posted:I've just started to look into PHP and I don't have a whole lot of programming experience, just some basic Java background. I'm sure there is a basic solution, so here it goes. You want array_values() php:<? $my_array = array (0 => 'Mike', 1 => 'Rob', 2 => 'Jeff', 3 => 'Tom'); //do whatever with $my_array[1] and then remove it from the array with unset($my_array[1]) $my_array = array_values($my_array); //Produces array = ([0] => Mike, 1 => Jeff, 2 => Tom); ?>
|
# ¿ Apr 28, 2008 10:24 |
|
The problem I've always found with =="" and empty() checks is that accidentally a user could hit the space bar when filling in a certain field which tricks both checks and means they haven't filled a required field in. So I always use if (str_replace(" ", "", $_POST['my_test'])=="") { error(); } when it's something really important.
|
# ¿ May 10, 2008 09:12 |
|
Kaluza-Klein posted:Yes, I can get those. I will have to query for the table field names, and if I don't have a $_POST to match it then it gets set to 0. Can you not do php:<?php //ice cream flavour chooser if (isset($_POST['checkboxes'])) { $to_check = unserialize($_POST['checkboxes']); foreach ($to_check as $flavour) { if (isset($_POST[$flavour])) { //doWhateverYouNeedToDo if checkbox is selected } else { //checkbox wasnt selected } } } $checkboxes = array ("Chocolate", "Vanilla", "Pastis"); echo '<form action="flavour_picker.php" method="POST" />'; foreach ($checkboxes as $checkbox) { echo $checkbox.'<input type="checkbox" name="'.$checkbox.'" />'; } echo '<input type="hidden" name="checkboxes" value="'.serialize($checkboxes).'" />'; echo '<input type="submit" name="submit" value="Submit" />'; echo '</form>'; ?>
|
# ¿ May 12, 2008 11:50 |
|
raej posted:I can't seem to find a good tutorial on how to enter a birth date in a user registration form. I'm not sure how I should store it in my database, or how to parse it to that format. I generally do three input boxes that already have MM DD YYYY in them as it takes less time to write parsing from different possible entry types to a timestamp. Use mktime() to change the input(s) you get from the form into a timestamp and then store it as a TIME (or maybe DATETIME?) in your database.
|
# ¿ May 12, 2008 17:56 |
|
duz posted:Why store a date as a TIME in your database? Why not store it as, I don't know, a DATE? I've never really heard of a datestamp before have you?
|
# ¿ May 12, 2008 18:29 |
|
duz posted:No, which is why I said DATE. The reason I store as a timestamp rather than using MySQLs inbuilt DATE type is because I personally find it easier to manipulate with php. Apologies, it's been so long since I used DATE that I'd forgotten it wasn't just another timestamp type.
|
# ¿ May 12, 2008 23:07 |
|
It's the === 0.php:<? function format_title($string) { $bit_array = array('The ' => ', The', 'A ' => ', A', 'An ' => ', An'); foreach ($bit_array as $prev => $new) { if (strpos($string, $prev)!==FALSE) { $string = (strpos($string, $prev)==0) ? ltrim($string, $prev) . $new : $string; } } return $string; } ?>
|
# ¿ May 19, 2008 01:56 |
|
nbv4 posted:Thats not quite as comprehensive as I'd like. Anyways, I found airnav.com, which is 100% comprehensive for american airports, which is about as good and I'm going to find I'm afraid. To be honest you're best off using Google Maps. If you notice that searching "KBOS" or "LAX" or "LGW" in Google Maps brings up the airport in question it's jut matter of using the API to get the latitude and longitude (or whatever information you're looking for). Much simpler than parsing a page of tables (which the airnav.com page is) to extract data.
|
# ¿ May 26, 2008 01:29 |
|
bt_escm posted:This would be so much better as a regular expression Although I think considering the user is so new to php that he thought splitting a string required some sort of loop, substr() is a better method than reg exps.
|
# ¿ May 26, 2008 12:08 |
|
You know I'm as willing to stick up for PHP as just about anyone when the going gets tough but I've just come across something that is such complete idiocy that I can't even begin to fathom why whoever wrote it is even allowed to continue existing. I think we all accepted a long time ago that PHPs core functions were a bit loopy and zany, like a very inconsistent clown. For instance today I became annoyed once more in PHPs assumption that I never want to preserve keys in my arrays. Excuse me sir, you want to preserve keys in array_reverse()? Well you better flag it because obviously it sense to not preserve them by default! Then today after crafting quite a handsome depthSort() function that will sort an array of arrays based on a consistent internal key and testing it using associative and non-associative keys such as: php:<? $thisarr = array ('Ben' => array ('Happy' => 12, 'Sad' => 20), 'Rob' => array ('Happy' => 10, 'Sad' => 22), 'Mike' => array ('Happy' => 5, 'Sad' => 100)); $thisarr = depthSort($thisarr, "Happy"); print_r($thisarr); ?> Array ( [6] => Array ( [Total] => 4 [Correct] => 2 ) [11] => Array ( [Total] => 4 [Correct] => 2 ) [10] => Array ( [Total] => 4 [Correct] => 2 ) [7] => Array ( [Total] => 4 [Correct] => 2 ) [3] => Array ( [Total] => 3 [Correct] => 2 ) [8] => Array ( [Total] => 4 [Correct] => 1 ) [1] => Array ( [Total] => 4 [Correct] => 0 ) [9] => Array ( [Total] => 3 [Correct] => 2 ) [2] => Array ( [Total] => 4 [Correct] => 3 ) [5] => Array ( [Total] => 3 [Correct] => 1 ) [4] => Array ( [Total] => 3 [Correct] => 2 ) ) After having it not work for a while and trying to figure out what the problem is, I head over to php.net to take a look at some of the internal functions that depthSort() uses to see if I can find the problem. Low and behold: array_multisort() can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions. Associative (string) keys will be maintained, but numeric keys will be re-indexed. I just can't fathom why anyone thought this would be a good idea? Why is it that they've decided that numeric keys are completely useless and no would ever use them associatively? I mean there has to be a reason doesn't there? Please can someone explain to me why someone lacked such basic sense as to automatically re-index an array thats being sorted by an integer based key? Gah sometimes PHP.
|
# ¿ Jul 9, 2008 15:28 |
|
functional posted:The reason is that all PHP arrays are associative, but 'unkeyed' arrays typically rely on keyed values to determine order. It wouldn't make sense for me to create $a=Array('Z','Y','X') and have $a[0] return the same value before and after the sort. Good point well made. If only they'd give me the option though like they do with all of their other barmy array functions I'd be happy.
|
# ¿ Jul 9, 2008 20:28 |
|
|
# ¿ May 8, 2024 15:21 |
|
Put ob_start(); as the first line of the page and ob_end_flush(); as the last one. Should work.
|
# ¿ Jul 14, 2008 17:01 |