Jump to content

linus72982

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by linus72982

  1. That would work for two tiers worth of loops, but this can possibly have 5, 10, 20 even. This is a script to find replies and then it calls itself to find replies of replies, and calls again to find replies of replies of replies, etc. Once it exhausts each reply tier, it should continue the previously started for loops (iterating x times where x is the amount of numReplies from the database) to find subsequent replies and then it will find replies of those replies, that sort of thing. The problem I'm having is that all the values I want to identify a specific for loop keep changing because I'm calling the same function over and over. I'm thinking what my answer here might be is to somehow count the number of "tiers" of replies down I go and back up a counter every time a for loop ends. Then I can have all of my useful variables be arrays with the pointer as the keys, that way I'll have unique variables for each "instance" of the function? Gah, it's very complicated and I'm having a hard time organizing it in my head. I'll post the actual script when I get home to see if we can't work something out. Thanks for all the help. -Adam
  2. So, I have what I think is an odd question. I have a function that contains a for loop. Within that for loop, it checks for a new condition and if it is true, it calls the very function it's already in. So, within the for loop inside of function "a", it can call function "a" with new arguments which will then start a new for loop to be "nested" to the previous for loop, in a way. My problem is trying to keep the values of the variables so that once the new for loop (or loops) finish, the previous for loop won't be stopped up by the new variable values that have since changed. Make sense? So, two questions: 1. How do I lock in values that make them unique to that very call of that function and keep them unique through further iterated versions? 2. I imagine, in theory, that for loops stay in memory in state as a new "instance" of that same for loop runs through, right? Basically, is what I'm doing possible in that a for loop calls itself, in essence, to create a new "instance" of that for loop, then when it finishes, have the previous loop continue iterating? For question #1, I've already thought about using variable variables, but that doesn't work because every time the function is called, the variable variable will change to new values based on the new arguments and instantiating the function again. I'm kind of looking for a way to make unique "instances" of a method that don't mess with future calls to that method and where future calls don't mess with currently iterating loops in that method. Phew, I think I confused myself. Thanks for any help.
  3. I wouldn't think so, the same way that: $foo = 'bar'; $bar = '1234'; echo $foo; // this would echo 'bar' echo ${$foo}; // this would echo '1234' // at least as far as I understand it Or am I wrong about this? I guess I can check after I get home from work, can't do it here.
  4. I know how to use $$ and ${} to use variable variables, but how would I get the same functionality out of a variable that is storing an object name? I have a function that is passed the name of an array of objects. As you can guess, that name will change based on which portion of the program is calling the function. How would I use variable variables of objects in this instance? Would it just be: $this->${$objArrayName}->threadName = etc; ? To make sure I'm not being misunderstood, I have 3 arrays of objects (replies, mainThreads, and stickies) and depending on which name I pass the function, I want it to use $this->replies OR $this->mainThreads OR $this->stickies to apply properties of those objects to. Thanks for any help. -Adam
  5. Put the message into a variable, drop it in a session or pass it with get/post, put that variable in between the starting and ending tags of the <textarea> or in the value= portion of an input text box - voila. Let me know if you don't know how to do this, we'll get it figured out. I didn't just do it for you because that was a lot of code to look through, it might help if you shorten then down to the exact part where the message is contained and then the exact part where you want it to show up and I'll show you how to do it.
  6. Just add in a counter to your while statement, like this: $i = 1; WHILE STATEMENT { etc $i++;} Then you can pass the value of $i with a hidden form value, like this: <input type="hidden" name="numSelects" value="<?php echo $i; ?>" /> Now, in your program, just pull the value of $_POST['numSelects'] and you have the number of times it iterated.
  7. Everywhere I look for an answer to this there is a page and a half explanation about time zones and DST and different functions and unix epochs, gah. I made a login script that logs the gmmktime of when the user registered and there are now a bunch of members so I can't just go change the script, I definitely need a way to convert these timestamps to the date AND time that the timestamp was set, preferably in an easy to use way such as an array with "month" "day" "year" AND "time" in EST. Does anyone know of a way to do this? Every one I come across either converts it to just a date or to just grabs the time and makes it super confusing as to what it is converting to and questions what arguments were sent with gmmktime when it was set (hint: none were sent with it.) Thanks for any help.
  8. Well, it's not "supposed" to cut at the end, it is "supposed" to cut right where it is, buttons don't have to be in a form, especially buttons that just act like links. That will probably fix the problem though, so I suppose I'll do it as a concession to Microsoft being a tool. Form is not supposed to incur line breaks.
  9. My CSS works in FF, but not in IE - gee, never seen a post start with that Anyway, I just have a simple div that wraps 3 input buttons, the width of the div is correct to fit the buttons (includes the border width, etc) and the div is margin auto'd to center. Well, in IE, the second and third buttons show up centered below the first. No matter how wide I make the containing div, they still show up under, so I don't think it is a width problem. Is there an IE bug with this that I don't know about? For reference, here is the CSS: #logOptionButtons { width: 305px; margin: 0px auto; text-align: center; clear: both; margin-top: 5px; } and here's the content: <div id="logOptionButtons"> <input type="checkbox" id="rememberMe" name="rememberMe" checked="checked" value="remember" /> &nbsp <label for="rememberMe">Remember Me</label><br /> <input type="hidden" value="login" name="processType" /> <input type="submit" value="Login" class="loginButton" /> </form> <button type="button" class="loginButton" onClick="window.location='<?php echo HOME_PAGE.REGISTER_PAGE; ?>'">Register</button> <button type="button" class="loginButton" style="width:125px;" onClick="window.location='<?php echo HOME_PAGE.FORGOTPWORD_PAGE; ?>'">Forgot Password</button> </div> Any ideas?
  10. Thanks for all the info. Yeah, I might have to try to grab some of those books. Taking a class isn't out of the realm of possibility as I'm in the Air Force and it's free to take college classes. I wish there were an easy-to-understand internet tutorial about all of this - so much easier and cheaper than books
  11. Every tutorial I find on Object Oriented Design Patterns are full of industry terms and are dripping with theory with very few practical examples. Can anyone point me to a tutorial that is easy to read and might even use actual PHP examples? Also, should I be worried about good design for small projects like forums or login systems, etc? I keep doing them with OO code but with procedural thought process (this goes to this and then it does this and goes back, etc,) and I just don't understand the abstract concepts behind good design. The internet has let me down - am I really going to have to go take a college class on this to understand? Thanks for any help. -Adam
  12. Okay, I got it to work, finally. I kept messing around with quotes and single quotes and such and finally got the right combination. It might be that I finally added an insert for every column instead of just the ones I wanted to update, perhaps it was an issue with them requiring notnull and me not putting anything in (thus null?) Anyway: $query = "INSERT INTO ".TABLE_NAME." (handle,fName,lName,email,userLevel,loggedIn,password,banned,dateJoined,dateLastLogin,validated,validationCode) VALUES ('".$properties['username']."','0','0','".$properties['email']."','$userLevel',0,'".$properties['password']."',0,'$time',0,'$validated','$validationCode')"; Thanks for the help.
  13. When I add an if to check if !$result and then die with a message, I get the message - so the query is coming back false. If that's the case, shouldn't a mysql_error show up? It isn't.
  14. Nope, no go on any of these. What are the rules about using variables within a query? Do you have to encase all variables with ' ' or just string variables?
  15. I have a newUser function in a class (database) that attempts to input all the post data from a registration (after it validates it all of course). Here is my function: public function newUser($properties, $validated, $userLevel, $validationCode) { $qualityControl = new QualityControl; $properties = $this->escapeString($_POST); $properties['password'] = $qualityControl->encryptData($properties['password']); $time = gmmktime(); $query = "INSERT INTO 'TABLE_NAME' (handle, email, userLevel, password, banned, dateJoined, validated, validtionCode) VALUES ('$properties[username]','$properties[email]','$userLevel','$properties[password]',0,'$time','$validated','$validationCode')"; return mysql_query($query, $this->connection); } I am getting an error in that my query is not inserting, no errors come up with mysql_error if I toss that in after the query and this function appears to run fine as it returns and the rest of the script is run. I have a feeling it has to do with either my sql syntax or the escapeString function. Escape string is a function that is "supposed" to escape a string passed to it or iterate through an entire array it is passed, here is the code for it: private function escapeString($data) { if (is_array($data)) { foreach ($data as &$value) $value = mysql_real_escape_string($value); return $data; } return mysql_real_escape_string($data); } If there error isn't in either of these two areas, it might be the encryptData function? All it is doing is md5ing + salting the password and returning the result. Here is that function if you need it: return md5(SALT.$data); Very simple, I don't think the error is there. The globals I'm using are all defined correctly so that shouldn't be a problem either. I've been looking at it for the past hour and can't figure out why my stuff won't get into the database. Oh, here's the beginning of the database class that opens the database and such, I'm not getting any errors from it. class Database { var $connection; public function __construct() { $qualityControl = new QualityControl; $this->connection = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die(mysql_error()); mysql_select_db(DB_NAME, $this->connection) or die(mysql_error()); } Thank you for any help! Also, please excuse some of the sloppiness like the error handling not being graceful, etc, I usually pretty that stuff up after I'm done with the script. -Adam
  16. Thanks, and yes, I meant just the symbols on the number keys. I'll try it out.
  17. I am building a new site for forums that has a high population of old people and they wouldn't appreciate me not allowing their simple passwords, so I search and search and everything I found on google requires complexity. So, if anyone can help with a regex that does the following, I'd appreciate it: 1. Can contain only letters, numbers, and symbols (just the normal symbols, no unicode or slashes, etc) 2. Cannot contain spaces 3. Must be 8-16 characters in length That's it, no other complexity required. Thanks for any help.
  18. You can use \ to "escape" characters, even quotes. Whatever comes after the \ is "ignored" or hidden so you can use quotes within quotes. Yours would be this: onclick='document.getElementById(\'rev$clicker\').style.display=\'block\';'/> That escape should only work for the php parse as by the time it gets to the browser and js takes over, the slashes should have been processed and tossed.
  19. I'm not quite sure why you have "position:absolute" in your style tag as you don't seem to be positioning it anywhere (you don't need it for vertical-align to work) and you don't seem to be using it for child positioning. Position:absolute takes the item out of the normal flow of the page which has the effect of making the rest of the page content think it isn't even there. If you take out that position tag, things should line up like they're supposed to. If you really must keep the position style in there for whatever reason, just add a left padding to your text tag that is the width of the calendar image (ie - wrap the text in a span like this: <span style="padding-left:20px;">TEXT</span>)
  20. I was going off the assumption you had a fixed pixel width wrapper div like 90% of the websites out there, it's rare you see a full page width page anymore. Well, if you have a full page, the percentages will still work for you.
  21. How many pixels are left after you minus the 200 from the first div? Just make the width that number. Or, you could make the first div a percentage (like width: 20%) and make the second div the "rest of the percentage", IE: width: 80%.
  22. Working links would help to know what you're wanting.
  23. Actually, I just read up on it and learned that != is viable in a query, so, nvm.
  24. You're also missing the closing semicolon in the php within the value attribute of the input tag. And I believe you should have quotes around the array keys in the second line. Also, not going to break anything, but you should use <br /> instead of <br> And of course, like the poster above said, you need to end your input tag with "/>"
  25. Yeah, I see where I made my mistake, glad you got it working
×
×
  • 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.