Hi,
I have a form that contains amongst others a text-field where users
should enter their year of birth.
<input type="text" name="year_of_birth">
Within the php script that parses the info, I try to check if a valid
birth-date was given, using the checkdate function. This function
expects integers as parameters, so I tought converting the text to an
integer value would work.
checkdate (1, 1, (int)$_POST["year_of_birth"])
However, this doesn't work, and I cannot seem to find out why... Any clues?
cheers,
E.T. 4 1878
Erik T. wrote: Within the php script that parses the info, I try to check if a valid birth-date was given, using the checkdate function. This function expects integers as parameters, so I tought converting the text to an integer value would work.
checkdate (1, 1, (int)$_POST["year_of_birth"])
No explicit casting required, PHP will take care of this automatically.
However, this doesn't work, and I cannot seem to find out why... Any clues?
It doesn't work as it always returns 0/1 or throws an error?
More info required, including your OS.
JW
Janwillem Borleffs wrote: Erik T. wrote:
Within the php script that parses the info, I try to check if a valid birth-date was given, using the checkdate function. This function expects integers as parameters, so I tought converting the text to an integer value would work.
checkdate (1, 1, (int)$_POST["year_of_birth"])
No explicit casting required, PHP will take care of this automatically.
Without the casting, I get :
Warning: checkdate() expects parameter 3 to be long, string given in
ledenform.php on line 49
Line 49 looks like this:
if ( checkdate ( $_POST["geboortemaand"] , $_POST["geboortedag"],
$_POST["geboortejaar"] ) )
With the typecast, I don't get an error, but checkdate always results as
FALSE.
However, this doesn't work, and I cannot seem to find out why... Any clues?
It doesn't work as it always returns 0/1 or throws an error?
More info required, including your OS.
I'm hosting this at my provider. php_info result: http://www.akindovzw.be/info.php
Erik T. wrote: Without the casting, I get :
Warning: checkdate() expects parameter 3 to be long, string given in ledenform.php on line 49
This means that $_POST["geboortejaar"] does not start with a digit, but
probably with a white space character.
With the typecast, I don't get an error, but checkdate always results as FALSE.
When your try to cast a string to an integer and the string doesn't start
with a digit, the result will be 0, which is why checkdate() always returns
false.
Try to apply trim() to $_POST["geboortejaar"] before using it and have a
close look at its value when the problem persists.
JW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: J. Campbell |
last post by:
I'm a novice with c/c++ and have been reading Eckel's book. I'd like
some feedback on using this method. What I need to do is treat a
string as numeric data. I know how to write functions to...
|
by: CoolPint |
last post by:
Can anyone clearly explain the difference between constant reference to
pointers and reference to constant pointers?
What is const int * & ?
Is it a constant reference to a pointer to an...
|
by: Ben |
last post by:
Hi all,
I'm not yet good at thinking the right way in c++ so although I could
solve this problem, I'm not sure if they way I'm thinking of is the best
way to do it. I need a data type or class...
|
by: akickdoe22 |
last post by:
Please help me finish this program. i have completed the addition and
the subtraction parts, but i am stuck on the multiplication and
division. any suggestions, hints, code, anyhting. it's not a...
|
by: GRoll21 |
last post by:
I have a program here that asks the number of students surveyed. then
it will ask how many movies each student has watched. After thats been
collected it does functions to find the average, median,...
|
by: Kemal Ozan |
last post by:
Hi,
I am studying K&R book. On the multidimensional Arrays chapter they
say
"int (*daytab)
is a pointer to an array of 13 integers. The parenthesis are necessary
since brackets have higher...
|
by: chrisstankevitz |
last post by:
This code does not compile on gcc 3.4.4. Should it?
Thanks for your help,
Chris
//================
#include <set>
int main()
|
by: yang__lee |
last post by:
Hi,
You all know typedef
typedef struct g
{
int a;
int b;
} google;
|
by: Julia |
last post by:
Hi, there,
In C programming, for pointer, I saw two programming styles:
one is connecting '*' with variable, like, 'int *i';
the other is connecting '*' with data type, like, 'int* i'
I...
|
by: beagle197 |
last post by:
Folks,
Attempting to q-sort an array of int pairs, e.g. {{0,1}, {0, 0}, ...}
allocated using malloc/calloc, but the arguments I'm passing to qsort
are producing the incorrect results (see...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |