Page 1 of 1

can somone please tel me what's wrong with this statement...

Posted: Thu Oct 19, 2006 4:00 pm
by garry27

Code: Select all

if (isset($_POST['day']) && isset ($_POST['month'])  && isset ($_POST['year']) && isset ($_POST['heading']))
Parse error: parse error, unexpected ')' in /... on line 28


[/quote]

Posted: Thu Oct 19, 2006 4:07 pm
by volka

Code: Select all

<?php
if (isset($_POST['day']) && isset ($_POST['month'])  && isset ($_POST['year']) && isset ($_POST['heading']))  {
}
?>
no parse errors. The error must be before this line of code.

p.s.: can also be written as

Code: Select all

if ( isset($_POST['day'], $_POST['month'], $_POST['year'], $_POST['heading']) )

Posted: Thu Oct 19, 2006 5:11 pm
by garry27
thanks volka.

the problem was a rogue bracket that escaped off the screen.


when i try to use the code to verify the date using check date, i get this error

Warning: checkdate() expects parameter 1 to be long, string given in functions.php on line 34

do you know how i can fix it?

Code: Select all

if (!checkdate($day, $month, $year))   //line 34
    echo 'wrong date';

Posted: Thu Oct 19, 2006 5:18 pm
by volka
I guess you have

Code: Select all

$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
a) why making new variables?
b) all parameters in _POST(_GET are strings (or arrays)
try

Code: Select all

if ( !checkdate((int)$_POST['day'], (int)$_POST['month'], (int)$_POST['year']) ) {
	echo 'wrong date';
}

Posted: Thu Oct 19, 2006 5:53 pm
by garry27
err pass lol. i didn't know you could do it that way but i guest it kind of makes sense.

i started using the post method since i kept getting index errors when i passed more than a couple of variables to a function and it kind of stuck

thanks again!

Posted: Thu Oct 19, 2006 7:34 pm
by John Cartwright
volka wrote:
p.s.: can also be written as

Code: Select all

if ( isset($_POST['day'], $_POST['month'], $_POST['year'], $_POST['heading']) )
Learn something new everyday.. cool :)