Jump to content

Moron

Members
  • Posts

    369
  • Joined

  • Last visited

Everything posted by Moron

  1. Okay, I want two fields on the opening page of my Leave Management form: Employee Number and Password. Password will be their Social Security Number. Therefore, the SSN they enter as password must match the Employee Number. Both are in the same database table. Is there a simple way to do this? I seriously don't need any encryption or anything fancy like that or any dealings with an htaccess file or whatever. This field must match that one. That's all.
  2. Hey, check it out. This returns the right results: [code] (LH.[LYR] = '$last' AND LH.[Lmo] >= '07') OR (LH.[LYR] = '$last' + 1  AND LH.[Lmo] < '07') [/code] But does anyone see a problem with it?
  3. Did you mean to put this twice in a row? [code] $last + 1 . $last + 1 . [/code]
  4. I also tried replacing just this part: [code] ((LH.[LYR] = '$last' AND LH.[Lmo] >= '07') OR (LH.[LYR] = '" . $last + 1 . $last + 1 . "' AND LH.[Lmo] < '07')) [/code] No go. It gives four major sql errors. Thanks for the help, though. My syntax is probably just hosed somewhere.
  5. Hitman6003, Thanks a ton, bit it keeps giving me this: [quote][b]Warning: mssql_query() [function.mssql-query]: message: Line 1: Incorrect syntax near '1'. (severity 15) in E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php on line 285 Warning: mssql_query() [function.mssql-query]: message: Unclosed quotation mark before the character string ')) ORDER BY LH.[LYR] desc, LH.[Lmo] desc, LH.[Lda] desc'. (severity 15) in E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php on line 285 Warning: mssql_query() [function.mssql-query]: Query failed in E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php on line 285 Warning: mssql_fetch_assoc(): supplied argument is not a valid MS SQL-result resource in E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php on line 286 [/b][/quote]
  6. [quote author=craygo link=topic=106085.msg424051#msg424051 date=1156864364] I work with this also. Does your fiscal year start july 1st?? If your date is august 3, 2006 will it be fiscal year 2007 or 2006?? Where is $curr_year, $curr_month, $curr_day coming from?? Is it just todays date?? Is what you are trying to do is find out if a particular date is in the current fiscal year?? Ray [/quote] Yes, our fiscal year starts July 1. We're in fiscal year 2007 right now. [code] if(($curr_month ==6 && $curr_day >= 1) || $curr_month >6){ $last = $curr_year; }else{ $last = $curr_year - 1; } $curr_month = date('m'); $curr_day = date('d'); $curr_year = date('Y'); [/code] On the last question, no, I want to pull records from the previous July 1 and forward. The query is doing this now, but it isn't "fiscal year sensitive." It's saying that if [Lmo] (Leave Month) is >= 07, etc... This hard wiring won't work after we hit January (01).
  7. Thanks, guys. Before the query (it's MS SQL, by the way), is... [code] //Define year of current fiscal year if(($curr_month ==6 && $curr_day >= 1) || $curr_month >6){ $last = $curr_year; }else{ $last = $curr_year - 1; } //Define month to start with if ($last == $curr_year) { $monlast = 07; }else{ $monlast = 12; } //Define day to break on if ($last >= $curr_year){ $daypoint = 01; }else{ $daypoint = 31; } [/code] The query works perfectly, BUT... it won't when January comes around with the month hardcoded as ">= 07" because January, being month 01, won't fit that criteria. I basically need a way to make the query fiscal year-sensitive. Any help is greatly appreciated!
  8. [quote] $RESULTDS=mssql_query("SELECT DISTINCT LH.[Employee Number], LH.[Lmo], LH.[Lda], LH.[LYR], LH.[Hours], LH.[Leave Code], M2.[HRYRAT], M2.[EMPNO], M2.[MANLAP], M2.[MANLAC], M2.[MANLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[NAMEMI], M2.[NAMEL], M2.[NAMEF] FROM LEAVHST LH INNER JOIN MASTERL2 M2 ON LH.[Employee Number]=M2.EMPNO WHERE M2.[EMPNO] = '".$_POST['employeenumber']."' and [b]LH.[LYR] >= '$last'[/b]  and [b]LH.[Lda] >= '01'[/b] and [b]LH.[Lmo] >= '07'[/b]  ORDER BY LH.[LYR] desc, LH.[Lmo] desc, LH.[Lda] desc"); $RESULT=mssql_fetch_assoc($RESULTDS);[/quote] Okay, as of right now, this is pulling exactly what I want it to pull, records on or after July 1, 2006, the start of our fiscal year (note that [b]$last[/b] determines the last year in which July 1 occurred, but I didn't see the need to include the code here). Anyway, it works now, but come January, the month will NOT be ">= 07" anymore. I tried this: [code] if ($last == $curr_year) { $monlast = 07; }else{ $monlast = 12; } [/code] I can echo it and it works fine, BUT, if I put [b]LH.[Lmo] >= '$monlast'[/b] in the query, the entire query crashes. Can anyone tell me a better way of going about this -OR- tell me why $monlast crashes the code?
  9. [quote author=hitman6003 link=topic=105970.msg423554#msg423554 date=1156797547] what format are you storing the date in your database? [/quote] It's Month (2-digit), Day (2-digit), and Year (4-digit). Thanks!
  10. [quote author=hitman6003 link=topic=105970.msg423534#msg423534 date=1156795125] [code]$combodate = mktime(null, null, null, $RESULT['Lmo'], $RESULT['Lda'], $RESULT['LYR']); $lastjuly1 = mktime(null, null, null, 7, 1, $RESULT['LYR'] - 1); echo '$combodate = ' . $combodate . ' which is: ' . date("Y-m-d", $combodate) . "<br />"; echo '$lastjuly1 = ' . $lastjuly1 . ' which is: ' . date("Y-m-d", $lastjuly1);[/code] [/quote] Thanks. This code works, but how do I incorporate it into the while satement? In other words, I only want to display records from the previous July 1 of the fiscal year ($last).
  11. [quote] $combodate = "$RESULT[LYR]$RESULT[Lmo]$RESULT[Lda]"; [b]//combine year, month, date into a string.[/b] $combodatecode = strtotime($combodate); [b]//convert to UNIX timestamp.[/b] $lastjuly1 = date($last,0701); [b]//"$last" is the last year in which July 1 existed. I didn't include it here.[/b] $lastjulycode = strtotime($lastjuly1); [b]//convert to timestamp.[/b] echo "<td>"; echo $RESULT['Lmo']; echo "/"; echo $RESULT['Lda']; echo "/"; echo $RESULT['LYR']; echo "</td>"; [/quote] Okey-dokey. All of the above functions work because I can echo them and get a date or a timestamp, respectively. Here's the kicker.... if I echo $combodate, it seems to pull the date of a random record. If I leave it out, the above Lmo, Lda, and LYR lines pull records perfectly. It almost seems like I need to restrict records that don't exist yet until after $RESULT is called. I tried... [code] if ($combodatecode >= $lastjulycode)  { echo "<td>"; echo $RESULT['Lmo']; echo "/"; echo $RESULT['Lda']; echo "/"; echo $RESULT['LYR']; echo "</td>"; } [/code] No go. It pulled two records when it normally (and should) pull eight. I also tried this inside the while loop. No go. Ideas?
  12. [quote author=HeyRay2 link=topic=105615.msg422006#msg422006 date=1156526391] Changing this line... [code] $num_rows = mssql_num_rows($result['EMPNO']); [/code] ...to this... [code] $num_rows = mssql_num_rows($RESULTDS); [/code] ...should get you on the right track... ;) [/quote] Yep. It works. Thanks! :)
  13. Temporarily type more text where you think the symbol is appearing. That will at least confirm whether you're pinpointing the right place or not.
  14. I've always gotten around this by making the text an image. I use the font/color/size I want in Windows Paint, then crop it out and make the background transparent with another program. That way, the text (image) will be presented in your page, whether the viewer has your font or not.
  15. [quote] $RESULTDS=mssql_query("SELECT DISTINCT LH.[Employee Number], LH.[Lmo], LH.[Lda], LH.[LYR], LH.[Hours], LH.[Leave Code], M2.[HRYRAT], M2.[EMPNO], M2.[MANLAP], M2.[MANLAC], M2.[MANLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[NAMEMI], M2.[NAMEL], M2.[NAMEF] FROM LEAVHST LH INNER JOIN MASTERL2 M2 ON LH.[Employee Number]=M2.EMPNO WHERE M2.[EMPNO] = '".$_POST['employeenumber']."'  and LH.[LYR] >= '$last'  and LH.[Lda] >= '01' and LH.[Lmo] >= '07' ORDER BY LH.[LYR] desc, LH.[Lmo] desc, LH.[Lda] desc"); $RESULT=mssql_fetch_assoc($RESULTDS); [b]$num_rows = mssql_num_rows($result['EMPNO']); echo "$num_rows Rows\n";[/b] [/quote] The query works fine. The part I put in [b]bold[/b] gives this error: [quote] [b]Warning:[/b] mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in [b]E:\User\Inetpub\wwwroot\PHPLeaveTime\leaveprocess.php[/b] on line [b]221[/b] Rows[/quote]
  16. I'm working on an employee leave program. The employee puts the employee number in and all sorts of wonderful things happen!  :o But..... if they put in an invalid (nonexistent) employee number or just some gobbledegook, how can I give them a nice, clean "invalid entry" notice as opposed to SQL errors all over the page?
  17. Can someone please point me in the right direction on this? I want authentication where an employee enters their employee number and the password is their Social Security number, which of course must match the employee number in the database. I only want this on the front end. Once they're in, they can do pretty much whatever they want.
  18. [quote author=AndyB link=topic=105392.msg421062#msg421062 date=1156370483] The answer to the first question exactly as asked is 'No, except without a great deal of trouble'. http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm might be what you're looking for. [/quote] Thanks, Andy. You came through yet again! I'm working on an employee leave program in PHP (as many of you know). The page automatically displays leave for the current fiscal year. I want them to be able to click Show History/Hide History and have it dynamically appear on the page. I think this script will do the trick. :)
  19. Can ShowDiv() open a separate HTML (PHP, in this case) page within the original page? Conversely, can HideDiv() hide it again? If so, I can't seem to find the code for doing this.
  20. [quote author=lessthanthree link=topic=105102.msg420771#msg420771 date=1156348366] Wouldn't that just be a simple SQL query? [code] mysql_query("SELECT * FROM history WHERE `empcode` = '".$_SESSION["empcode"]."'"); [/code] If you originally obtaining the empcode value from $_GET don't forget to clean the value and check the data is matching what you're expecting, else you're open to people injecting mallicious code into your script. [/quote] I added that line to my query, so the query now reads.... [code]$RESULTDS=mssql_query("SELECT DISTINCT LH.[Employee Number], LH.[Lmo], LH.[Lda], LH.[LYR], LH.[Hours], LH.[Leave Code], M2.[HRYRAT], M2.[EMPNO], M2.[MANLAP], M2.[MANLAC], M2.[MANLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[MSKLAB], M2.[MSKLTC], M2.[NAMEMI], M2.[NAMEL], M2.[NAMEF] FROM LEAVHST LH INNER JOIN MASTERL2 M2 ON LH.[Employee Number]=M2.EMPNO WHERE M2.[EMPNO] = '".$_POST['employeenumber']."' and 'empcode' = '".$_SESSION["empcode"]."' ORDER BY LH.[LYR] desc, LH.[Lmo] desc, LH.[Lda] desc"); $RESULT=mssql_fetch_assoc($RESULTDS); $HOURSRESULT=mssql_fetch_assoc($RESULTDS); [/code] This section doesn't pull anything: [code] <CENTER> <font size="3" color="#ff0000" face="arial"><b> <?php echo $RESULT['NAMEF']; ?> <?php echo $RESULT['NAMEMI']; ?> <?php echo $RESULT['NAMEL']; ?> <?php echo " - "; ?> <?php echo $RESULT['EMPNO']; ?> [/code] So what have I failed to do?
  21. [quote author=448191 link=topic=105102.msg420725#msg420725 date=1156345465] Directly assign $_SESSION['empcode'], there's no need to copy $empcode for it. [/quote] That worked, too.  :) My next hair-puller is to figure out how to pull records based on the passed $empcode variable.
  22. [quote author=448191 link=topic=105102.msg420641#msg420641 date=1156339018] Your second page is ok, the first is not. [code] <?php session_start(); $_SESSION['empcode']=$empcode; ?>[/code] '$empcode' doesn't work because everything within single quotes is treated as a string. Leave them. Also leave session_register(), you don't need it. [/quote] Many thanks! That worked. Now, though, I'm getting.... [quote][b]Warning:[/b] Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in [b]Unknown[/b] on line [b]0[/b] [/quote] I set the following two lines in the php.ini file as follows: session.bug_compat_42 = off session.bug_compat_warn = 0 I then stopped and restarted the Default Web Site, but the warning still comes back. Two steps forward, one step back! :)
  23. More info..... On my first page, I have this at the top: [code] <?php session_start();  $_SESSION['empcode']='$empcode'; session_register("empcode"); ?> [/code] On the second page, I have this at the top: [code] <?php session_start(); $empcode = $_SESSION['empcode']; echo $empcode; ?> [/code] On the second page called, where I put [b]echo $empcode;[/b] as a test, it's displaying [i]$empcode[/i] instead of displaying the [b]value[/b] of $empcode. If I echo it on the first page, it properly displays the employee number.
  24. [quote author=Woolf link=topic=105102.msg419650#msg419650 date=1156192586] You could use sessions. [list] [*]Put session_start(); at the top of your pages [*]When someone submits the form, save the variable like this: $_SESSION['employee_num'] = $employee_num. Where $employee_num is the variable that you have when someone submits the form. [*]To recall the ID number on another page, use $_SESSION['employee_num'] (e.g. $employee_num = $_SESSION['employee_num']) [/list] [/quote] One question: I know that $_session_start(); has to be declared at the top of the page before any HTML code, but the variable I'll be using hasn't been defined yet at that point. So.... can I put $_SESSION further down my page after the variable has been created or does it also have to be at the top?
  25. I have a form where someone enters their employee number, then it returns a page with leave history (some of you have already hashed this out with me). Once the second page displays, I want them to be able to click for more history, BUT....I don't want them to have to re-enter their employee number. So the question is, how do I pass an already-existing variable to the next page?
×
×
  • 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.