Jump to content

TOA

Members
  • Posts

    623
  • Joined

  • Last visited

Everything posted by TOA

  1. Right before all that. It just takes the posted values and makes userVals out of it. I got it though, you replied just as I figured it out. Thanks for your response
  2. Hi. I need some help. I don't know if I've just been staring at this for too long or what, but I can't figure out how to make the form below sticky (and by that I mean the values stay if there is an error and redirect). I get lost in all the arrays Here's the code for my form: $num = intval($_SESSION['num']); if (isset($_SESSION['PlanError'])) { echo "$_SESSION[PlanError]<br />"; } echo "<form action='' method='POST'>"; for ($i=1; $i < $num + 1; $i++) { <table> <tr><th>General Plan Info</th><th>Supplemental Benefits</th></tr> <tr><td class="half">Plan Name <input type="text" name="<?php echo 'P['.$i.'][name]';?>" value="<?php checkArraySticky('1', 'name'); ?>" /><br /> </table> } echo '<input type="submit" name="continue" value=" Continue " class="button" /><input type="submit" name="save" value=" Save and finish later " class="button" />'; echo "</form>"; There's a few more fields in there, but they're not needed for the example, they all work the same way. So as you can see, the user post's a number from another script and this takes it and shows that many versions of it. So all the inputs are arrays like $P[1][name] for example (meaning plan 1 name) I just can't figure out how to make it sticky. I tried throwing everything in a session but can't get it to work. Here's what I tried to make it sticky: function checkArraySticky($num, $value) { if (isset($_SESSION['userVals']['P'][$num][$value])) { echo $_SESSION['userVals']['P'][$num][$value]; } } Any suggestions? *** EDIT *** Nevermind, that worked, I just wasn't calling the function right
  3. Didn't read it carefully enough. Post removed by me
  4. If I understand you correctly, I think this is what you need UPDATE highscores SET score='$ChangeScore' WHERE player='$PlayerToChangeScore' Luck
  5. Hmmm, well thats not what I wanted to hear I'll look into that post-haste Thank you much sir
  6. Hey guys, Here's my scenario: return the avg length of time between logins for all of a companies users combined. (Trying to answer the question "How often do my users login to their accounts"?) Here's my table I'm using: CREATE TABLE IF NOT EXISTS `IPlog` ( `IP_ID` int(11) NOT NULL auto_increment, `IP` int(10) unsigned NOT NULL, `UserName` text collate utf8_unicode_ci NOT NULL, `Time_Stamp` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`IP_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=574 ; When a user logs in, I grab an IP, mark a timestamp and consider that a login. I'm not storing a loggout, because I don't need it to be detailed, just as close a ballpark as I can get. I've considered adding it, and if it's necessary I will but for our uses, it's not that important. I've tried this code which returns a result, but I'm almost 100% sure it's not the right result SELECT SEC_TO_TIME(AVG(TIMESTAMPDIFF(SECOND, `t1`.`Time_Stamp`, `t2`.`Time_Stamp`))) AS Average FROM `IPlog` AS `t1` JOIN `IPlog` AS `t2` ON `t2`.`IP_ID`=`t1`.`IP_ID`+1 INNER JOIN User ON t1.UserName=User.UserName WHERE User.Emplr_ID='1' I tested, and added the IP_ID into the SELECT, and it's only comparing 2 timestamps. Pretty sure it's because of the +1 in there but if I don't have it in it returns 0 because its comparing angainst itself. (my best guess) The forum I found the base of this code used it and prefaced it with:it had to be successive ids, but I can't think of how to switch it. Also, if I change this INNER JOIN User ON t1.UserName=User.UserName to this INNER JOIN User ON t2.UserName=User.UserName I get differing results 11:42:52 11:16:10 Any help would be appreciated. I'm not sure if I'm getting the right result or not, and how to get it if I'm not. Thanks
  7. Just realized $row in this line should be $row[0]. Wouldn't let me edit previous post.
  8. You need to do something with that resource id, such as using mysql_fetch_assoc() or mysql_fetch_row() to get the actual value. Add this after your query: $row = mysql_fetch_row($memid); And change this line: mkdir('profiles/'.$memid, 0777); To this: mkdir('profiles/'.$row, 0777); That should work, hope it helps
  9. Ok, well I didn't get a chance to talk to our admin today, but I think the remaining problem is that I need to get that file into the server somehow, which is what started me on this expedition in the first place. As I stated a few posts ago, I got things working through a script, but not the local admin area. I'll mark it solved
  10. Not enough info How does it not work? Do you have error reporting on?
  11. There's other ways, but here's one: $sql = "SELECT Email FROM your_table WHERE ID='$id'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $to = $row['Email']; }
  12. Yes, exactly Yes, $to would be the returned value from the db
  13. Your table would have fields ID and Email, and whatever else you want. Each of your links would include a variable in the url -- the unique id from the db table. Then in your php script, grab the number sent $id = $_GET['id'] Then query the db for that email SELECT Email FROM Your_Table WHERE ID='$id' Then use that returned value in the mail function Hope that makes sense
  14. That would work. Your link would send a unique ID to the php form which goes to get the email associated with that ID from the db.
  15. I get this error with both: #2 - File 'C:/Documents and Settings/my_comp_name/Desktop/Sample CSV File2.txt' not found (Errcode: 2) file should be in the server side Yeah, I tried earlier to find where to put the file locally, but couldn't, not sure where the admin has it. I tried every level on my web server, so the mysql server must be somewhere else Thanks for the help
  16. Thanks for the reply Wish I could find it I'm not the admin so if the file was on my desktop for example, it would be "C:\Documents and Settings\my_comp_name\Desktop\my_file_name.ext"? I tried that just now and got the same file not found error
  17. Ok, so I got this to work from a script LOAD DATA LOCAL INFILE 'Sample CSV File2.txt' INTO TABLE CCReporting FIELDS TERMINATED BY ',' (`a bunch of fields`, @open, `Closed Date`, `a few more fields`) SET `Opened Date` = DATE_FORMAT(STR_TO_DATE(@open, '%m/%d/%Y'), '%Y/%m/%d'); So instead of using phpmyadmin to import I would use the script. But I would still like to learn how to do it in the admin section, just so I know. If anyone can help me with that, I'd love to know. I'm going to leave this unsolved for just a bit longer until I get this working correctly for both values, and to see if anyone has an answer. Thanks
  18. Update: I can use the LOAD DATA radio button on the phpmyadmin import tab to successfully import data, but without using the SET to change any data like I need to. I can use the sql tab to write the full statement, but can't get my file to the right place. I get Error 2: File not found. For the life of me, I can't find where to put my file. Suggestions? Am I doing something wrong? Thanks for reading Oh and here's the statement I'm working with: (table names/unused field names have been changed to protect the innocent) LOAD DATA LOCAL INFILE 'Sample CSV File2.txt' INTO TABLE CCReporting FIELDS TERMINATED BY ',' (`a bunch of fields`, `Opened Date`, `Closed Date`, `a few more fields`) SET `Opened Date` = DATE_FORMAT(STR_TO_DATE(`Opened Date`, '%m/%d/%Y'), '%Y/%m/%d'); I'll need to figure out how to change two fields, but I'll cross that bridge after I get it to work on one
  19. So I've done some reading and it looks like the SET option is what I'm looking for. I also read that the set statement can't be used in phpmyadmin, but must be entered through the command line...is this correct? I see no place to enter it or am I missing something Thanks for the help so far
  20. I wasn't but I'll look into it right now. That's close to what I had thought of doing if I found no answer, except I hadn't thought of using the extra field. That's an interesting thought. I see how that could work. Would the LOAD DATA [LOCAL] INFILE method be the better/more acceptable way? Thanks for the leads
  21. Hey guys, hoping you can help.. Here's my dilemna: We get a dump from a vendor in csv format. I use a mysql database, they don't; so, they format the date as MM/DD/YYYY and I obviouosly need it as YYYY/MM/DD to store in the db. My original thought was to write a script that takes the date and reformats, then inputs into db instead of doing an import... then I thought mysql might have an inherent function to do this so I looked and nothing jumped out at me as an obvious answer. So I thought I'd ask around and see if: Is there a built in way (in mysql) to alter the format of a date while I'm importing? Hope this makes sense.
  22. First issue. Any time you want something "on the fly" so you say, you need ajax. I'm not the guy to help you with that. Second issue. You got it right. That creates an array called name, which you can use just like any other array. In your processing, do this: if ($_POST['name']) { // says if something was posted foreach ($_POST['name'] as $key => $value) {// says for each thing posted in the names array do something //your stuff here ($key will be the input name, $value the users submission } } Hope that helps *Sorry for the double post, meant to edit the first post and accidentally quoted it instead*
  23. What happens when you run it? My guess is nothing because you have errors turned off In your first if statement, your checking if a resource_ID is greater than 0 and you need to be checking the num_rows returned from the query. replace this: if(@mysql_query($query) > 0) { With this: $res=@mysql_query($query); if (mysql_num_rows($res) > 0 ) { I think that's what you're looking for, if I read your post right.
  24. Weird, that all looks fine at a quick glance. You could try putting braces in the ifs, like: if (!empty($_POST['color'])) { do your stuff here } You could also try removing the concatenations and do it like this: $arr[] = "color = '$_POST[color]'"; but to be honest, it should have worked either way. Dreamweaver can be touchy though so you never know
×
×
  • 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.