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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

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

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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']) )
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

Post 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';
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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';
}
garry27
Forum Commoner
Posts: 90
Joined: Sat Oct 14, 2006 1:50 pm

Post 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!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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 :)
Post Reply