Re: date functions (generates parse error)

Re: date functions (generates parse error)

am 05.03.2003 18:33:57 von David Rice

Sorry, I forgot to add the part at the bottom where I am calling the
function

============================================================ =====

function tips($weekstart){

$start = date('Ymd',strtotime($weekstart));

  $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start +
INTERVAL 6 DAY) ORDER BY staffid";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)){

if ( isset ( $tips ) ){

if (isset ( $tips[$row[staffid]] ) ){

$hours = $row[finish] - $row[start];
$tips[$row[staffid]] = $tips[$row[staffid]] + $hours;

}

else{

$tips[$row[staffid]] = $row[finish] - $row[start];

}
}

else{

$tips = array('$row[staffid]' =>( $row[finish] - $row[start] ) );

}

}

return $tips;

}

function dbconnect(){
mysql_connect("localhost", "filterseveuk", "godisadj");
mysql_select_db("filterseveuk");
}

dbconnect();
$date = "2003-03-02";

var_dump(tips($date));
?>

____________________________________________________________ _____
Express yourself with cool emoticons http://messenger.msn.co.uk


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: date functions (generates parse error)

am 05.03.2003 19:22:07 von John Holmes

This is very weird. What are you using to create this code?

If you remove all of the spaces (?) before $query, the code doesn't give
a parse error. It shouldn't give one either way, though, if those are
spaces or a tab before your $query =3D ... line.=20

Even if you remove all of the text and only leave , and those
"spaces", PHP will spit something like:

Notice: Use of undefined constant - assumed ' ' in
c:\inetpub\wwwroot\test.php on line 3

So, the fix is to remove those characters and replace them with spaces
or tabs.=20

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -----Original Message-----
> From: David Rice [mailto:haloplayer@hotmail.com]
> Sent: Wednesday, March 05, 2003 12:34 PM
> To: holmes072000@charter.net; php-db@lists.php.net
> Subject: Re: [PHP-DB] date functions (generates parse error)
>=20
>=20
> Sorry, I forgot to add the part at the bottom where I am calling the
> function
>=20
> =
==================== =====3D=
==================== =====3D=
===============3D
>=20
> > function tips($weekstart){
>=20
> $start =3D date('Ymd',strtotime($weekstart));
>=20
> =A0 $query =3D "SELECT * FROM Rota WHERE date >=3D $start and date =
<=3D
> ($start +
> INTERVAL 6 DAY) ORDER BY staffid";
> $result =3D mysql_query($query);
> while ($row =3D mysql_fetch_array($result)){
>=20
> if ( isset ( $tips ) ){
>=20
> if (isset ( $tips[$row[staffid]] ) ){
>=20
> $hours =3D $row[finish] - $row[start];
> $tips[$row[staffid]] =3D
$tips[$row[staffid]] +
> $hours;
>=20
> }
>=20
> else{
>=20
> $tips[$row[staffid]] =3D $row[finish] -
$row[start];
>=20
> }
> }
>=20
> else{
>=20
> $tips =3D array('$row[staffid]' =3D>( $row[finish] -
> $row[start] ) );
>=20
> }
>=20
> }
>=20
> return $tips;
>=20
> }
>=20
> function dbconnect(){
> mysql_connect("localhost", "filterseveuk", "godisadj");
> mysql_select_db("filterseveuk");
> }
>=20
> dbconnect();
> $date =3D "2003-03-02";
>=20
> var_dump(tips($date));
> ?>
>=20
> ____________________________________________________________ _____
> Express yourself with cool emoticons http://messenger.msn.co.uk
>=20
>=20
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php