RE: date functions (generates parse error)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:haloplayer@hotmail.com]
> Sent: Wednesday, March 05, 2003 12:34 PM
> To: holmes072000@charter.net; php-db@lists.php.net
> Subject: Re:  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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux