Re: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread 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: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread John W. 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 = ... line. 

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. 

---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:[EMAIL PROTECTED]
 Sent: Wednesday, March 05, 2003 12:34 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] date functions (generates parse error)
 
 
 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




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



Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread David Rice
Here is the whole code of my function

Whenever i run it, it say's there is a parse error on line 6, can't see what 
is the problem
the format of $weekstart (as it is stored in the Database) is -MM-DD

=
?
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;

}

_
Stay in touch with absent friends - get MSN Messenger 
http://messenger.msn.co.uk

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


Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread 1LT John W. Holmes
 Here is the whole code of my function

 Whenever i run it, it say's there is a parse error on line 6, can't see
what
 is the problem
 the format of $weekstart (as it is stored in the Database) is -MM-DD

 =
 ?
 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;

 }

I cut and pasted your exact code here and didn't get a parse error.

---John Holmes...


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