[PHP] date problem

2013-01-03 Thread Marc Fromm
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date(m/d/Y, strtotime($jes))  date(m/d/Y, strtotime(WSOFFBEGIN)) )
{
$error =  MUST begin after  . WSOFFBEGIN . \n;
}

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc


RE: [PHP] date problem

2013-01-03 Thread Marc Fromm
Thanks for the reply.

Every example on comparing dates in PHP that I found uses the strtotime 
function which I am using.  What other type can I use?

When is this example below supposed to work?

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your second date coming from a mysql database (date fields)
$dateB = '2007-04-14 15:23';
if(strtotimehttp://www.php.net/strtotime($dateA)  
strtotimehttp://www.php.net/strtotime($dateB)){
// bla bla
}

Thanks


From: Serge Fonville [mailto:serge.fonvi...@gmail.com]
Sent: Thursday, January 03, 2013 2:05 PM
To: Marc Fromm
Cc: php-general@lists.php.net
Subject: Re: [PHP] date problem

Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table

2013/1/3 Marc Fromm marc.fr...@wwu.edumailto:marc.fr...@wwu.edu
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date(m/d/Y, strtotime($jes))  date(m/d/Y, strtotime(WSOFFBEGIN)) )
{
$error =  MUST begin after  . WSOFFBEGIN . \n;
}

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc



RE: [PHP] date problem

2013-01-03 Thread Marc Fromm
Thanks Jonathan. I removed the date() syntax function and it works.

From: Jonathan Sundquist [mailto:jsundqu...@gmail.com]
Sent: Thursday, January 03, 2013 2:16 PM
To: Marc Fromm
Cc: Serge Fonville; php-general@lists.php.net
Subject: Re: [PHP] date problem

Marc,

When you take a date and do a strtotime you are converting it to an int which 
you can compare to each other much easier. So for your above example you would 
be best doing.


define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( strtotime($jes)  strtotime(WSOFFBEGIN) )
{
$error =  MUST begin after  . WSOFFBEGIN . \n;
}
On Thu, Jan 3, 2013 at 4:12 PM, Marc Fromm 
marc.fr...@wwu.edumailto:marc.fr...@wwu.edu wrote:
Thanks for the reply.

Every example on comparing dates in PHP that I found uses the strtotime 
function which I am using.  What other type can I use?

When is this example below supposed to work?

// your first date coming from a mysql database (date fields)
$dateA = '2008-03-01 13:34';
// your second date coming from a mysql database (date fields)
$dateB = '2007-04-14 15:23';
if(strtotimehttp://www.php.net/strtotime($dateA)  
strtotimehttp://www.php.net/strtotime($dateB)){
// bla bla
}

Thanks


From: Serge Fonville 
[mailto:serge.fonvi...@gmail.commailto:serge.fonvi...@gmail.com]
Sent: Thursday, January 03, 2013 2:05 PM
To: Marc Fromm
Cc: php-general@lists.php.netmailto:php-general@lists.php.net
Subject: Re: [PHP] date problem

Hi.

date returns a string

You should compare a different type for bigger/smaller than

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2013/1/3 Marc Fromm 
marc.fr...@wwu.edumailto:marc.fr...@wwu.edumailto:marc.fr...@wwu.edumailto:marc.fr...@wwu.edu
I am comparing to dates.

define('WSOFFBEGIN','09/16/2012');
$jes = 01/03/2012;

if ( date(m/d/Y, strtotime($jes))  date(m/d/Y, strtotime(WSOFFBEGIN)) )
{
$error =  MUST begin after  . WSOFFBEGIN . \n;
}

I cannot figure out why the $error is being assigned inside the if statement, 
since the statement should be false. 01/03/2012 is not less than 09/16/2012.

Marc



RE: [PHP] compare dates

2011-12-01 Thread Marc Fromm
Thanks. I'm stuck using 5.1.6. Matijn reply worked by using the unix timestamp.

-Original Message-
From: Maciek Sokolewicz [mailto:tula...@gmail.com] On Behalf Of Maciek 
Sokolewicz
Sent: Thursday, December 01, 2011 12:57 PM
To: Marc Fromm
Cc: Floyd Resler
Subject: Re: [PHP] compare dates

On 01-12-2011 02:17, Floyd Resler wrote:

 On Nov 30, 2011, at 5:04 PM, Matijn Woudt wrote:

 On Wed, Nov 30, 2011 at 11:00 PM, Marc Frommmarc.fr...@wwu.edu  wrote:
 I'm puzzled why the if statement executes as true when the first date 
 (job_closedate) is not less than the second date (now).
 The if statement claims that 12/02/2011 is less than 11/30/2011.

 if (date(m/d/Y,strtotime($jobs_closedate))= 
 date(m/d/Y,strtotime(now))){

 You're comparing strings here, try to compare the unix timestamp:

 if (strtotime($jobs_closedate)= strtotime(now)){

 That'll probably do what you want..

 Matijn


 Another way to do it would be:
 if(strtotime($jobs_closedate)=time()) { }

 or

 if(date(Y-m-d,strtotime($job_closedate))=date(Y-m-d,time()) { }

 Take care,
 Floyd


As of PHP 5.2.2 direct comparison of DateTime objects is also possible. So:
$closeDate = new DateTime($jobs_closedate); $now = new DateTime('now'); 
if($closeDate  $now) {
echo $closeDate-format('m/d/Y'); // output in US date format
echo $now-format('m/d/Y'); // output in US date format
$error .= The close date must be later than today's date,  . 
$now-format('m/d/Y') . \n;
}

This, IMO is a lot prettier.
- Tul



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



[PHP] compare dates

2011-11-30 Thread Marc Fromm
I'm puzzled why the if statement executes as true when the first date 
(job_closedate) is not less than the second date (now).
The if statement claims that 12/02/2011 is less than 11/30/2011.

if (date(m/d/Y,strtotime($jobs_closedate)) = 
date(m/d/Y,strtotime(now))){

echo date(m/d/Y,strtotime($jobs_closedate)); // displays - 
12/02/2011
echo date(m/d/Y,strtotime(now)); // 
displays - 11/30/2011

$error.=The close date must be later than 
today's date,  . date(m/d/Y,strtotime(now)) . .\n;
}

If the first date is 11/16/2011 the if statement also executes as true which 
is correct since 11/16/2011 is less than 11/30/2011.

Marc


[PHP] checking dates not working

2011-11-10 Thread Marc Fromm
I have this bit of code to see if a date is greater or equal to a set date.

echo(date(m/d/Y,strtotime($jobs_effective_start)));// displays entered date 
of 01/03/2012
echo(date(m/d/Y,strtotime(WSOFFBEGIN))); // displays set date of 09/16/2011

if (!(date(m/d/Y,strtotime($jobs_effective_start)) =  
date(m/d/Y,strtotime(WSOFFBEGIN {
$error.=The effective start date must be AFTER 
.WSOFFBEGIN.\n; unset($_POST[jobs_effective_start]);
}

My error message is displaying. The if statement is executing as true, as if 
01/03/2012 is not greater or equal to 09/16/2011.
This is not correct since a date in 2012 should be greater than a date in 2011.

If I use 12/31/2011 as the $job_effective_start date the error message is not 
displayed since 12/31/2011 is greater than 09/16/2011 and the if statement 
executes as fasle.

Any ideas on why a 2012 date is treated as not greater than a 2011 date?

Thanks

Marc


[PHP] array problem

2011-09-09 Thread Marc Fromm
I am reading a csv file into an array. The csv file.

users.csv file contents:
w12345678,a
w23456789,b
w34567890,c

$csvfilename = users.csv;
$handle = fopen($csvfilename, r);
if($handle) {
while (($line = 
fgetcsv($handle, 1000, ,)) !== FALSE) {
$arrUsers[] = 
$line;
}
fclose($handle);
}

When I echo out the elements in the elements in the array $arrUsers I get:
Array
Array
Array

foreach ($arrUsers as $user){
echo $user . br /;
}

I can't figure out why the word Array is replacing the actual data.



[PHP] using pg_query in a function not working

2011-08-05 Thread Marc Fromm

I have to sql statements in functions to use in my code. Even though the echo 
statements show the sql is valid the sql does not seem to execute and I get the 
error, PHP Warning:  pg_fetch_object() expects parameter 1 to be resource, 
boolean given in . . . line 154 . . .
Line 154: while($val = pg_fetch_object($student))

##

Function Calls:

$insert = recordSentList($empid, $list, printed); // No record gets inserted 
into the table

$student = getStudent($list);
while($val = pg_fetch_object($student)) //No records get listed
{

##

Functions:

function recordSentList($empid, $list, $method){
$today = date(m/d/Y, strtotime(now));
$sql = INSERT INTO lists_sent (
   
lists_sent_employers_id,
lists_sent_type,
lists_sent_date,

lists_sent_method)
VALUES (
'$empid',
'$list',
'$today',
'$method');
echo $sqlbr /; // slq statement looks accurate
$result = pg_query($conn,$sql);
echo Insert Errors:  . pg_errormessage($conn) . br /; 
//No errors are reported
return $result;
}

function getStudent($list){
$removaldate = date(m/d/Y,mktime(0, 0, 0, date(m)-3, 
date(d)-7,  date(Y)));
$sql = SELECT * FROM students WHERE ;
if($list == child_care_list){
$sql .= child_care_list  ' . $removaldate . 
' ;
$sql .= AND child_care_list IS NOT NULL ;
$sql .= ORDER BY student_lname ASC, 
student_fname ASC;
} elseif ($list == day_labor_list) {
$sql .= day_labor_list  ' . $removaldate . 
' ;
$sql .= AND day_labor_list IS NOT NULL ;
$sql .= ORDER BY student_lname ASC, 
student_fname ASC;
} else {
$sql .= tutor_list  ' . $removaldate . ' ;
$sql .= AND tutor_list IS NOT NULL ;
$sql .= ORDER BY student_lname ASC, 
student_fname ASC;
}
echo $sqlbr /; // slq statement looks accurate
$result = pg_query($conn,$sql);
echo Select Errors:  . pg_errormessage($conn) . br /;//No 
errors are reported
echo Rows:  . pg_num_rows($result) . br /;//No number is 
displayed
if ((!$result) or (empty($result))){
return false;
 }
return $result;
}

Marc Fromm
Information Technology Specialist II
Financial Aid Department
Western Washington University
Phone: 360-650-3351
Fax:   360-788-0251


RE: [PHP] using pg_query in a function not working

2011-08-05 Thread Marc Fromm
Thanks! Sometimes I'm blind.

-Original Message-
From: Jim Lucas [mailto:li...@cmsws.com] 
Sent: Friday, August 05, 2011 1:01 PM
To: Marc Fromm
Cc: php-general@lists.php.net
Subject: Re: [PHP] using pg_query in a function not working

On 8/5/2011 12:08 PM, Marc Fromm wrote:
 
 I have to sql statements in functions to use in my code. Even though the echo 
 statements show the sql is valid the sql does not seem to execute and I get 
 the error, PHP Warning:  pg_fetch_object() expects parameter 1 to be 
 resource, boolean given in . . . line 154 . . .
 Line 154: while($val = pg_fetch_object($student))
 

$conn is not in scope

 
 Marc Fromm
 Information Technology Specialist II
 Financial Aid Department
 Western Washington University
 Phone: 360-650-3351
 Fax:   360-788-0251
 



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



[PHP] sending email

2010-12-15 Thread Marc Fromm
When I use the mail function on a linux server, how is the email sent? Does 
sendmail act alone or does it use SMTP?

Thanks

Marc


[PHP] sending emails

2010-12-09 Thread Marc Fromm
We have web forms that send the user an email confirmation after submission, 
like most forms do.
The emails are being delivered to the users' junk folder. The main campus IT 
staff claim it is because our server is sending the emails.
The campus is using Microsoft exchange servers. I am using Red Hat Linux, 
sendmail, and PHP. Is there a way to give php the exchange server's ip address 
and have the emails from my php forms be sent from the exchange server?

Thanks

Marc




[PHP] output buffer

2009-12-29 Thread Marc Fromm
I am receiving the Cannot send session cookie - headers already sent message 
even though I am using ob_start() at the top of my script.
The php.ini file has output_buffering set to 4096 4096.
My server is running Red Hat Enterprise Linux 5.2
I am using PHP 5.1.6

Is there some other setting I need to adjust to be able to start a session 
within the php script?

Thanks

Marc



RE: [PHP] output buffer

2009-12-29 Thread Marc Fromm
I figured it out but not sure why.

On the dev server the script ran with no errors
On the live server the script created the header already sent error.

In the code I did not execute ob_start() at the top of the script.
Once I executed ob_start at the top of the script on the live server it worked 
with no header already sent error.

I cannot see why on the dev server it works with the ob_start() command in 
inside the script while the live server had an error when it was in the same 
place in the script.

-Original Message-
From: Alexey Bovanenko [mailto:a.bovane...@gmail.com] 
Sent: Tuesday, December 29, 2009 1:38 PM
To: Marc Fromm
Subject: Re: [PHP] output buffer

Hi.

There're some other code that is sent to client. You must send cookie
first, at header, then the other data.

Please send code to view your case.

With regards,
Alexey

On Wed, Dec 30, 2009 at 12:09 AM, Marc Fromm marc.fr...@wwu.edu wrote:
 I am receiving the Cannot send session cookie - headers already sent 
 message even though I am using ob_start() at the top of my script.
 The php.ini file has output_buffering set to 4096 4096.
 My server is running Red Hat Enterprise Linux 5.2
 I am using PHP 5.1.6

 Is there some other setting I need to adjust to be able to start a session 
 within the php script?

 Thanks

 Marc




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



[PHP] php and ODBC

2009-09-04 Thread Marc Fromm
I am trying to figure out how to use ODBC with PHP.
Specifically I need to connect a php script to a SunGard Banner table
I know I need to set up some type of DNS connection, but I am not sure what 
exactly that is.

[r...@dev ~]$ odbcinst -j
unixODBC 2.2.11
DRIVERS: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini

/etc/odbcinst.ini
  1 # Example driver definitinions
  2 #
  3 #
  4
  5 # Included in the unixODBC package
  6 [PostgreSQL]
  7 Description = ODBC for PostgreSQL
  8 Driver  = /usr/lib/libodbcpsql.so
  9 Setup   = /usr/lib/libodbcpsqlS.so
 10 FileUsage   = 1
 11
 12
 13 # Driver from the MyODBC package
 14 # Setup from the unixODBC package
 15 #[MySQL]
 16 #Description= ODBC for MySQL
 17 #Driver = /usr/lib/libmyodbc.so
 18 #Setup  = /usr/lib/libodbcmyS.so
 19 #FileUsage  = 1

Thanks,

Marc



[PHP] DOCUMENT_ROOT errors

2009-02-09 Thread Marc Fromm
I updated fedora core from FC5 to TC6, thus httpd and php were updated in the 
process. My pages worked with no errors before the upgrade.
My php pages are no not displaying and generating this error in the httpd logs

PHP Notice:  Undefined variable: DOCUMENT_ROOT in 
/var/www/html/studentjobs/index.php on line 6, referer: 
http://finaid46.finaid.wwu.edu/
PHP Warning:  require(/studentjobs/includes/javascript.php) [a 
href='function.require'function.require/a]: failed to open stream: No such 
file or directory in /var/www/html/studentjobs/index.php on line 6, referer: 
http://finaid46.finaid.wwu.edu/
PHP Fatal error:  require() [a href='function.require'function.require/a]: 
Failed opening required '/studentjobs/includes/javascript.php' 
(include_path='.:/usr/share/pear') in /var/www/html/studentjobs/index.php on 
line 6, referer: http://finaid46.finaid.wwu.edu/

PHP Notice:  Undefined index:  cmd in 
/var/www/html/lan/ztezt/student_alerts/index.php on line 5

My current versions are:
httpd-2.2.6-1.fc6
php-5.1.6-3.7.fc6
php-pear-1.4.9-4 (one error above mentions pear)

Marc



[PHP] dynamic forms

2008-12-16 Thread Marc Fromm
I would like to create a from that will pull and display information based on a 
user's ID from a postgresql database into a textarea on the form, before the 
submit button is clicked. Are there some tutorials on how to use PHP to 
dynamically display information on a form as the form is being filled out?

Thanks

Marc


[PHP] send emails in php not working

2008-10-27 Thread Marc Fromm
We recently moved to a new server. Our code that would send out emails is no 
longer sending emails.
There are no messages in the httpd logs associated with running the email.php 
files.
The email scripts worked on the old server. Is there a special setting in 
php.ini for sending emails in php or is there a packages that needs to be 
installed on the new server. Below is some sample code that worked on the old 
server

Receive the email request:
  1 html
  2 body
  3
  4 form action=emailFormProcess.php method=post
  5 Your Name: input type=text name=namebr
  6 E-mail: input type=text name = emailbrbr
  7 Commentsbr
  8 textarea name=comments/textareabrbr
  9 input type=submit value=Submit
 10 /form
 11
 12 /body
 13 /html

Process the email request:
  1 html
  2 body
  3
  4 ?
  5 function checkOK($field)
  6 {
  7 if (eregi(\r,$field) || eregi(\n,$field)){
  8 die(Invalid Input!);
  9 }
 10 }
 11
 12 $name=$_POST['name'];
 13 checkOK($name);
 14 $email=$_POST['email'];
 15 checkOK($email);
 16 $comments=$_POST['comments'];
 17 checkOK($comments);
 18 $to=[EMAIL PROTECTED],$email;
 19 $message=$name just filled in your comments form. They 
said:\n$comments\n\nTheir e-mail address iss: $email;
 20 if(mail($to,Comments From Your Site,$message,From: $email\n)) {
 21 echo Thanks for your comments.;
 22 } else {
 23 echo There was a problem sending the mail. Please check that you filled in 
the form correctly.;
 24 }
 25 ?
 26
 27 /html
 28 /body

Thanks

Marc



RE: [PHP] send emails in php not working

2008-10-27 Thread Marc Fromm
 You need a local mail server.
Sendmail  8.13.8-2.el5 is installed on the new server and the old server 
(sendmail-8.13.8-1.fc5).
echo 'test' | mail -s 'test' [EMAIL PROTECTED]
The above line sends on email on the old server but not the new server.

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED]
Sent: Monday, October 27, 2008 2:55 PM
To: Marc Fromm
Cc: php-general@lists.php.net
Subject: Re: [PHP] send emails in php not working

Marc Fromm wrote:
 We recently moved to a new server. Our code that would send out emails is no 
 longer sending emails.
 There are no messages in the httpd logs associated with running the email.php 
 files.
 The email scripts worked on the old server. Is there a special setting in 
 php.ini for sending emails in php or is there a packages that needs to be 
 installed on the new server. Below is some sample code that worked on the old 
 server

You need a local mail server. Choices usually are postfix, exim,
sendmail or qmail (I suggest postfix) - they are usually the top 4 open
source ones.

Does email work from command line?

echo 'test' | mail -s 'test' [EMAIL PROTECTED]

--
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP] moved code to a new server

2008-10-24 Thread Marc Fromm
I think I fixed it. The error said that the file script.js, line 4 of the code, 
could not be found:
4 ? require (http://path/to/the/file/script.js;)?

I changed the line to this and it now works:
? require (script.js) ?

I wonder why on the old server it could find the file based on the full url 
while the new server cannot find the file with the full url.

-Original Message-
From: Mohamed Ainab [mailto:[EMAIL PROTECTED]
Sent: Friday, October 24, 2008 3:34 PM
To: Daniel P. Brown
Cc: php php; Marc Fromm
Subject: RE: [PHP] moved code to a new server


would be very helpfull if you would post the code.

---
http://ainab.com | http://somaliyrics.net

 Original Message 
Subject: [PHP] moved code to a new server
From: Daniel P. Brown [EMAIL PROTECTED]
Date: Fri, October 24, 2008 3:25 pm
To: php php php-general@lists.php.net, Marc Fromm
[EMAIL PROTECTED]

Forwarded to General, since this doesn't belong on DB.

On Fri, Oct 24, 2008 at 6:18 PM, Marc Fromm [EMAIL PROTECTED] wrote:
 We moved our website to a new linux server. The code was running on a 
 different linux server. Thus the OS environment is the same.
 We are receiving this error:
 [Fri Oct 24 14:53:37 2008] PHP Fatal error: require() [a 
 href='function.require'function.require/a]: Failed opening required 'this 
 was a url to a .js file' (include_path='.:/usr/share/pear:/usr/share/php') in 
 /var/www/html/path to .php file on line 4

 I'm not a php programmer thus I am in the dark.

You don't have to be, you just have to read the error message. If
you copied that verbatim, then 'this was a url to a .js file' exists
on line 4 of .php in /var/www/html/path, and PHP failed to open it.

Make sure the file exists exactly where PHP is looking for it, and
that it's accessible and readable to and by the user as which the
server is running when executing `.php` in /var/www/html/path, and
that the target file can be found from that directory.

--
/Daniel P. Brown
http://www.parasane.net/ [New Look]
[EMAIL PROTECTED] || [EMAIL PROTECTED]

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





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