Error Checking On Date
I am writing a script that checks a date that was submitted from the previous form. In cold fusion where is a function called Isdate(variable) and if it came back false, then you kick out an error. I found the checkdate function, but you have to break the date into a Day Month and Year variables. Is there another way to check the date that I'm just not seeing?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Checking Date
if i use date() in php to get date, im getting date that my computer has right? wen i change that date of my computer, the date that i get from the function date() not be accurate. what php function i can use where i can get accurate date.
Checking Date
mysql query thur php, would this be correct to see if date submitted was 10 or more minutes ago date_submitted <=(NOW() - 3600)
Checking Date
I have a form where user must enter the year ($year), month ($month) and day ($day). What I want to do then if check and see if this date is in the future. If it's in the past I want to print an error message, if it's in the future then it's ok.
Checking For Valid Date
got a form where one needs to input a date. basically i created 3 textboxes $day, $month & $year into which one puts the numbers. first of all i limited the number of characters to 2,2 & 4 respectively (html) and created the following code: PHP Code: function check_date($day, $month, $year) { if ( (($month%2 != 0) and ($month <= 7) or ($month%2 == 0) and ($month >= 8) and ($month <= 12)) and ($day > 31) ){ $res = 0; } elseif ( ( ($month%2 == 0) and ($month <= 6) or (($month == 9) or ($month == 11)) ) and ($day > 30) ){ $res = 0; } elseif ( (($month == 2) and ($year%4 != 0) and ($day > 28)) or (($month == 2) and ($year%4 == 0) and ($day > 29)) ){ $res = 0; } else { $res = ($year.$month.$day); } return $res;} questions: 1. how do i make sure that people can only input numerical data? (at the moment the database will give an error message, but i would like to put one in there myself: "only numbers allowed" or so...) 2. in the $year people could enter something like 4-5, or 4+5, etc. -how can i control that really there are four numbers put in (without having to say that the value needs to be between lets say 1900 and 2050), and how do i get round people adding or substracting values by error? 3. is the code above anywhere near appropriate, or is there a faster way?
Checking The First Date Entry
In my database I have 2 fields (month and year). In the month field is the full month names (January through to December). In the Year field there are entries of 2006 and 2007 as there are only 2 years worth. I would like to be able to search through the fields find out what the first month and year entry is and display them inside a drop down menu through to the latest month (September 2007 down to the earliest) - but the latest month is not going to be the newest entry inside the database, it needs to be the month we are in (real time).
Checking For Valid Date Input
If a date is entered in a form with MMDDYY, how do I check if this input field is a valid date. Is there a php function to do this?
Checking For Time Date Conflicts
I am writing a new script. It is to simulate a booking system for a company. What i gotta do is check that a slot is taken by another driver. So if London to Manchester is 9:00am to 4:00pm and driver Bill is booked on 02/02/2002. If i try and book Driver Mike for the 10:00am to 5:00pm on 02/02/2002 it should let me know that the bus is alredy been given to Bill. How would i go about checking for this schedule conflict?
Error Checking
I have a classic problem: things run properly on my test server but don't work on the live server (different PHP version, different master Apache config, etc...) which I do not admin. In particular, for 'security reason' the access to the error.log file has long been disabled and I don't get any message on screen. Things just don't happen the way they should. I've tried putting various takes on this in my .htaccess to no avail: php_flag display_errors on php_value error_log /home/dargaud/logs/error.log # Nothing there php_value error_reporting E_ALL php_flag html_errors on php_flag log_errors on php_flag track_errors on What else can I try to troubleshoot issues without admin rights on the server ?
Group Error Checking
Need to check a group of form inputs and want to run them in a group instead of separate statements. This is what i have so far and no luck any suggestions. I just put the form fields as variables in these to test and this is a far as I got before I realized this may not be the best way. Any suggestions? Code:
Validation & Error Checking Broken?
I'm validating a simple form for input via post ($PHP_SELF). Near the end I check for username and password. I'm using simple if, elseif, else statements. I require them to enter password twice and check that they match. Problem is script doesn't valide past username input and I dont know why!! If you don't enter a password it doesn't do the validation anymore, it just dies for some reason. I would greatly appreciate anyones help, I've stared at this thing for hours and hours. Here is code...
Form Input Error Checking
Have a form field being inserted, needs to only allow an integer value through. Which function do I want to use to check the passed var to see if there are any non-integer values present? PHP Code:
Error Checking Custom Forms
I am writing software that allows users to create custom html forms...when they place the forms on their pages using a display function the site visitor can fill them out. The info is passed to a processing page...it all works dandy if there are no errors. My question is, if there ARE errors what would be the best wasy to redirect the user back to the form..with the POST data in there. I have looked through the posts regarding headers and fsockopen and stuff like that....but I am not sure how to implement this. I can grab the $_SERVER['HTTP_REFERER'] from the form page....so I can send them back to the correct page. But I am unclear on the most efficient way to repopulate the form with the information they have submitted...in other words...how can I pass the data back to the form after realizing it had errors.
Even After Proper Error Checking, I Still Get PHP Warnings
I've this class method, which makes sure I've got a variable that is a resource: function close() { if (is_resource($this->datastoreResultsPointer)) { mysql_free_result($this->datastoreResultsPointer); mysql_close(); } } all the same, I'm getting these PHP errors: Warning: mysql_free_result(): 286 is not a valid MySQL result resource in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/McDatastoreResultsMySql.php on line 89 Warning: mysql_close(): no MySQL-Link resource supplied in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/McDatastoreResultsMySql.php on line 90
Error Checking For Unique Value In Database Table?
I am inserting data into user table which contains 5 fields, sounds simple enough normally but 2 of the fields are designated as UNIQUE. If someone does enter a value which already exists, how do I capture this specific error? Would it make more sense to actually run a SELECT query first and if that returned a result, then I use that for error checking and don't run insert until select returns nothing?
Do Professional PHP Programmers Use Error Checking In Their Code?
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting language. The idea, apparently, is that the PHP interpreter writes all the error messages that are needed, and that I shouldn't write such code myself. I was given the impression that if I needed extensive error checking, or strict typing, then I should use a real language, like Java, but if I'm going to use a scripting language like PHP or Ruby, then I should leave errors to the interpreter, since the whole point of using scripting languages is speed of development. Has anyone else heard this argument, and do you agree with it? I'm wondering how other PHP programmers handle error messages. Check everything or leave it to the PHP interpreter to tell you when there is an error? Which of these two functions is better, the one with error checking or the one without? function getWeblogEntries() { $query = "SELECT * FROM weblogs"; $result = mysql_query($query); $howManyWeblogEntries = mysql_num_rows($result); for ($i=0; $i < $howManyWeblogEntries; $i++) { $row = getRow($result); extract($row); echo "<h1>$headline</h1>"; echo "<h7>$date</h7>"; echo "<div class="mainContent">$mainContent</div>"; } } function getWeblogEntries() { $query = "SELECT * FROM weblogs"; $result = mysql_query($query); if ($result) { $howManyWeblogEntries = mysql_num_rows($result); for ($i=0; $i < $howManyWeblogEntries; $i++) { $row = getRow($result); if (is_array($row)) { extract($row); echo "<h1>$headline</h1>"; echo "<h7>$date</h7>"; echo "<div class="mainContent">$mainContent</div>"; } else { reportError("In getWeblogEntries, the function getRow failed to return an array on the $i iteration."); } } } else { reportError("In getWeblogEntries, the query to the database failed."); } }
Error Checking/code Comparison Tools
does anyone have a cool/free/cheap tool that they use for error-checking that would allow you to e.g. copy code from two different pages and find where they are different? I have some code that seems to work in one page but not in another and I can't find the difference. I could just copy and paste but then I wouldn't really learn anything.
Problems With Error Checking / Control Of POST Variables
I have a small form that on button press submits to a PHP file for further processing into a database. I have to change the script as it allows blank / nothing to be submitted to the database. The intention is that if any of the two form fields are blank (empty) then the page is resent stating that they have to fill in all the fields to post (to a database). If I deliberately leave the fields blank and submit the form, querying the database shows that both fields are zero / null - so nothing was entered in to the database. However, if I use an echo command to see what is going on (before the data is entered into a database) I get the $TheName field with a "1" and the $TheComment field with an unknown entry (it doesn't echo anything to the screen - but it's not empty). The code I've used to test this is: $TheName = $_POST[gbName]; $TheComment = $_POST[gbComment]; if (($TheName = NULL) or ($TheComment = NULL)) { echo 'Quick error check running:<BR>' echo "Name: $TheName<BR>"; echo "Comment: $TheComment"; exit; } This does NOT execute as these fields are not empty. It only runs if I change to: if (($TheName = !NULL) or ($TheComment = !NULL)) Which is pointless as it will always execute with genuine entries. Using the amended code below: if (($TheName = !NULL) or ($TheComment = !NULL)) { echo 'Quick error check running:<BR>' } echo "Name: $TheName<BR>"; echo "Comment: $TheComment"; I get the result that both the echoed lines are displayed as blank (no "1").
PHP & CURL Installation Error (checking For Curl_easy_perform In-lcurl)
I'm trying to install the latest PHP4 version from the scratch. The configure string is following: ../configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl --enable-exif --enable-mbsting=all --with-gd --with-openssl --with-zlib-dir=/usr --with-zlib Everything goes well until the cURL should be configured. At that point, I will encounter an error like this: checking for CURL support... yes checking for CURL in default path... found in /usr checking for cURL 7.9.8 or greater... libcurl 7.12.1 checking for curl_easy_perform in -lcurl... no configure: error: There is something wrong. Please check config.log for more information. OK, let's check out the config.log: [root@finnpower php-4.3.10]# tail config.log #line 20458 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char curl_easy_perform(); int main() { curl_easy_perform() ; return 0; } Following cURL packages are installed: curl-7.12.1-1 curl-devel-7.12.1-1 In general, I have Fedora Core 3 installed with self-compiled Apache 2... almost with PHP 4.3.10 too.
Date In Apache2's Error Log When Error Caused By PHP
I've noticed since moving from Apache1/mod_php4/linux to Apache2/mod_php5/linux that when an error is produced by PHP and put in the error_log, the date is no longer logged as well: Apache1/php4/linux example in Apache error_log: [Thu Jan 8 15:06:52 2004] [error] PHP Warning: opendir(/foo/bar/): failed to open dir: No such file or directory in /blah/something/listing.html on line 84 Apache2/php5/linux example in Apache error_log: [client 1.2.3.4] PHP Notice: Undefined variable: browserline in /foo/bar/zing.html on line 18 Is there any way to restore this, either at PHP or Apache level?
Last Date Updated Syntax Error
I tried embedding this in an XHTML file, then changed it to last4.php, but get a syntax error. What am I doing wrong? <?php $last_modified = filemtime("last4.php"); print("Page Last Updated: "); print(date("m/j/y h:i", $last_modified)); ?>...
Effective Due Date? Timestamp? FATAL Error.
I'm building a library with php, and want to create a way for the return date for an item to automatically be 14 days after they are checked out. I had hoped to use something like: $Check_Out_Date=TIMESTAMP[(8)]; and then manipulate that with substrings and whatnot, until i could put it back together as 2 weeks later. Unfortunately I'm getting a FATAL error, with this.
Preg_match() Error, Match Only Valid Date In Mm/dd Format.
I am trying to create a function that will match only valid date in mm/ dd format. (Month in, 01, 02, ..., 09, 10, 11, 12 and Dates in 01, 02, ..., 11, 12, ..., 30, 31). I am trying this code, but it fails to work. The error is :- PHP Warning: preg_match(): Compilation failed: unmatched parentheses at offset 15 in /home/wizard/regexDateTime.php on line xx The code is here.
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
"unexpected Error In Date()"
Could anybody explain to me the cause of an unexpected error in date() after calling the function several times.
Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code: <select name="day"> <option value="1">1</option> <option value="2">2</option> ....... <option value="31">31</option> </select> <select name="month"> <option value="01"> Jan </option> <option value="02"> Feb </option> ..... </select> <select name="year"> <option value="2002">2002 </option> <option value="2003">2003</option> </select> When I select and click submit in form. I will have 3 variable : $day, $month and $year How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.
Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a href="http://www.mytuneslive.com/ameshkin69/"> following page.</a> Here is the code. As you can see, it is just making the date the current time. The values in the database are UNIX timestamp, and the DATE() function is used to convert from UNIX to readable date. Can <td width="55%" align="left" valign="top"><?php $row_comment['timestamp'] = date("n d Y g:i A");.....
Read Today's Date Print Tomorrow's Date
I've got a small script that writes a random number and the date to a text file. Then the script opens this text file and if date = date from this text file something must happen. If something happened this script must open this text file again and replace it with a new random number and tomorrow's date. <?php $date = date("d-m-Y"); mt_srand((double)microtime()*10000000000); $num=mt_rand(0, 20); if ($num == $num && $date == "$tomorrowdate") { echo"$num -- $date";} else echo " ";?> So if the script gets activated on the 05-05-2003 it must write tomorrow's date into the text file (06-05-2003). How will I get tomorrow's date today?
Help: Date Function Not Returning Correct Date & Time
I have just notices that the date() function is not returning the correct date/time on my "server". I am running apache2 on my winxp pro laptop. My system clock is set to the correct date, time and timezone, get the results returned by date() are 11 hours behind.
PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last Sunday, and the Sunday before that? For example: Today is Thursday, August 18, 2004 (2004-08-18). I would like to have the following variables: $this_past_sunday = 2004-08-14 $two_sundays_ago = 2004-08-07 $three_sundays_ago = 2004-07-31 etc. etc.
Save Date To Table Field Date Type
I have a calendar picker on a form that fills a text box with XX/XX/XXXX date format. If I run a insert statement the date field in the database shows 0000-00-00. If i change the field type to varchar the correct format displays. What is the correct way to save a date to a mysql database? Furthermore to query on the date how about a select * from db_name where servicedate >= $startdate and servicedate >= $enddate I supose this will not work Any pointers?
Date Dropdown From Mysql Date Entries
For the PHP gurus out there, here is what I want to do: create a dropdown list of available dates from a mysql database date entries. But the dropdown/s should have 3 separate fields in month, day and year which in effect shows only those months, days and years that have corresponding entries from the database. Planning to use this in the archive section of an online news publication so people can select issues to view via dropdown list that have corresponding entries only.
Start Date - End Date = Number Of Days
I have a starting date for var 1 and today’s date for var 2. I need to calculate how many days are between those two dates. 02/24/03(today) - 01/14/2002(start date) = number of days. In theory this is easy but there are many instances were I could get an inaccurate answer. For example one consideration is that some months have 30 days others have 31. exc. My question is, is there an easier way to solve this problem other than using endless if statments to error handle all possible instances? Does PHP4 have any built in functions that could calculate this formula correctly?
UNIX Mktime To MySQL Date Or Date
A form that sends a starting date and an ending date. I have figured out how to tell the difference between the two and even rip the difference into an array because I need to compare the individual dates against a mySQL database to pull results from a particular date in a series. This is no problem. My problem is that teh mySQL database uses DATE as a field definition and this can not be changed. I managed to pull the date differences using some cleaver mktime stuff but no I do not know how to get this 1072242000 into this 2003-12-24... Is there a function that reverses the mktime result into a usable date format? I would take anything at this point and I can explode and then array it to get what I want - but there has to be something. Code:
Formatting Date From MYSQL Date Field
i've got a date field in my table, but the default format is YYYY-MM-DD... is there any way i can pull the date out of the database and format it differently... like DD.MM.YYYY or like April 13, 2003?
Counting Days From $date To Current Date
how to count the time between two variable dates? Such as someone inputting 6/8/1991 in a form and it comparing that to todays date... then getting the number of seconds elapsed... I know I have to use the mktime() function to get the seconds.. but not quite sure how.
Date() Gives Me Yesterday's Date And Not Today's - Why?
$result[$i]->record_entered contains the current date as set up by MySQL (entered as "now()"). I verified that in the database the date is "now()", which in this case will be "2/9/2006". However, when viewing the page using the display: Code: ( php )
Begin Date And End Date, But No Weekends!
I am making a system to plan my work days. If i begin on a project on 01-10-2007, and the project is 100 hour and i work 10 hours a day, it will cost 10 days for me too work. The answer is simple, project is done @ 10-10-2007, but i dont work in the weekend. So it must be 12-10-2007, i got the following script;, but it aint working right. Because when the begin date and end date is more then 2 weeks, and more than 2 weekends, it doenst count the weekends good. Can someone help me, or is there somebody with a better solution? I am working two days on it, but i cant get it right <?php $begin_date = strtotime( date( '2007-10-01' ) ); $hours = 100; $workdays = 10; $total_days = $hours / $workdays; $total_days *= (60 * 60 * 24); $weekend = $total_days / 7 * 2; $enddate = $begin_date + $total_days + $weekend; if( date('D', $enddate ) == 'Sat' ) { echo 'End date <b>' . date('d-m-Y', $enddate + (2*86400)) . '</b> 2 days<br /><br />'; } elseif( date('D', $enddate ) == 'Sun' ) { echo 'End date <b>' . date('d-m-Y', $enddate + (1*86400)) . '</b> 1 day<br /><br />'; } else { echo 'End date <b>' . date('d-m-Y', $enddate) . '</b><br /><br />'; } ?>
Date Conversions ( Date, Mktime )
I have a date in three pieces dd mm yyyy. I'm just wondering the best way to convert this for inserting into a DATETIME field and then back again when displaying it. I have tried date, strtotime mktime but it keeps inserting a blank date. i.e. 00:00:00 00:00... I've been looking through the php manual but I can't seem to get this working. Also would I be better off using the UNIX_TIMESTAMP function?
Check Date Is Not Before Current Date
I need to validate a date entered to make sure it isnt before the current date. I have managed to this in Javascript but not sure how to do this in PHP when the value is submitted.
Date Time Not Accurate For Date();
echo "date=".date('Y-m-d h:i:s'); date=2007-11-15 15:48:14 the clock is the accurate at here..showing only 3pm ..while now my pc showing 11.51pm(localtime)
URL Checking?
how do you check if a browser came from a specific URL??
Checking For XSS ?
Does the check below ensure that the files are originating from my server, i.e. to prevent or detect any type of XSS ? Or is the HTTP_HOST easily spoofed ? function test ($refer) { if (!stristr($refer, $_SERVER["HTTP_HOST"])) { die(); } else { } } test ($_SERVER["HTTP_HOST"]);
IP Checking
I have to do this for security measures on a script I am doing: To ensure the authenticity of the HTTP requests you should only accept requests from the following IP addresses: 80.87.132.0/26 (ie .0 -> .63) is there a simple way to do a range of IPs ie IF $ipaddress == 80.87.132.* If not does anyone have a good function for this?
Checking %'s
Is there a built in function to check if a value is a certain % of a different value? Like: If($Value < 10% $value2) sort of thing ? Or do i have to work out the 10% first then check against that?
IP Checking
I have a rating system, and its supposed to let people vote only once but right now I can vote 50 times in a row if I want, and I dont know why its letting me vote multiple times, here is my code:
Put Today's Date Into A MySQL "date" Formated Field
My MySQL table has a field that is set as type "date." I need to get today's date, and insert it into that field. The default for that MySQL field is 2006-00-00. I know about the date() function. I have tried date("Y-m-d") and date("U"), neither worked. The date field was just filed with all zeros. Can anybody point me in the right direction?
Spell Checking
How can i spell check without including the aspell or pspell libraries ( can't include them because i'm on a virtual host ). I don't mind if its an external service. Spellchecker.net was great, expect now you have to pay for it.
|