Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Auto-Deppe, C. Haensel

nevermind, I made it :o) RTFM sometimes works even for me :O))

Have a great day :o)

Chris

- Original Message - 
From: "Christian Haensel" <[EMAIL PROTECTED]>

To: 
Sent: Monday, April 30, 2007 7:47 AM
Subject: [PHP] PHP & MySQL -> Field Title



Good Morning guys and girls

As I am rather lazy, I don't wanna do a data readout on my MySQL table in 
the following way with mysql_fetch_assoc()


$data_item1=$data['xitem1'];
$data_item2=$data['yitem2];


I am trying to do the following:

I have the correct number of fields in the table, which is 116. Now I want 
to use a for-loop and read teh data into a string, then shove it into 
another table, which has the exact same layout. I was thinking about 
something like


for($i=0; $i<= 115; $i++) {
   $data_item[$i]=$data[$i];
}

but now I have the problem with the field names and all... can someone 
point me into the right direction? All I have to so is move the contents 
of one field to the second database wich has the same layout as the first 
DB.


Would be thankful for any help :o)

Cheers!

Chris
--
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



Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Oliver Block
Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:
> but now I have the problem with the field names and all... can someone
> point me into the right direction?



php-db at lists.php.net

If you need to use an assoc array, use the following SQL Syntax:

INSERT INTO new_table SET key0=value0, key2=value2, ..., 

Regards,

Oliver

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



Re: [PHP] PHP & MySQL -> Field Title

2007-04-30 Thread Christian Haensel

Hi Oliver,

below is what I used.

 ".$value."";
 $titel = $fieldname;
 $insert_q .= ",'$value'";
}
$insert_q = $insert_q.')';
$insert_q = eregi_replace("\(,","(", $insert_q);
echo "";
echo $insert_q;
mysql_query($insert_q) or die(mysql_error());
echo "Yup";
$del_q = "DELETE FROM vorlauf WHERE satz_nr = '$fzg_id' LIMIT 1";
$do_del = mysql_uery($del_q);
?>


I'm sure there are better ways to do the whole thing :o) But as long as I 
need to cpy one record at a time, I don't really care much for speed. I just 
put all the stuff into a string and then use that string as query for the 
insertion into the second database.


Scripts like that make me feel good when I say "You can be dumb as heck, ás 
long as you find a way to resolve your problems" :o) It works, and it took 
me just about 10 minutes of research and another 10 of writing :o)


Hope your weather is just as good as ours here...

All the best!

Chris

- Original Message - 
From: "Oliver Block" <[EMAIL PROTECTED]>

To: 
Cc: "Christian Haensel" <[EMAIL PROTECTED]>
Sent: Monday, April 30, 2007 1:11 PM
Subject: Re: [PHP] PHP & MySQL -> Field Title



Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:

but now I have the problem with the field names and all... can someone
point me into the right direction?




php-db at lists.php.net

If you need to use an assoc array, use the following SQL Syntax:

INSERT INTO new_table SET key0=value0, key2=value2, ...,

Regards,

Oliver

--
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



Re: [PHP] phpbb / sessionid nightmare

2007-04-30 Thread Stut

Brad Sumrall wrote:

Does anyone know what this _utma _utmb _utmc _utmz stuff is?
Obviously it is not a php standard.
Obviously it is what is actually controlling my sessions?


These come from Google services (analytics, adsense, etc), they have 
nothing to do with your sessions.


-Stut

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



Re: [PHP] Re: Object-oriented $_REQUEST?

2007-04-30 Thread Philip Thompson

On Apr 28, 2007, at 5:13 PM, Robert Cummings wrote:


On Sat, 2007-04-28 at 23:41 +0200, keviN wrote:



I'm sorry but your code indicates an extreme lack of experience using
PHP in the real world. Your class should be named such that it will
never collide with someone else's class name in the event you might  
need

to use third party libraries. A better name for your class follows:




LOL!!

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



RE: [PHP] Run a script apart from request

2007-04-30 Thread Buesching, Logan J

> -Original Message-
> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 30, 2007 10:55 AM
> To: php-general@lists.php.net
> Subject: [PHP] Run a script apart from request
> 
> Hi all,
> 
> I am developing a program that does some intensive data processing,
and is
> triggered from a page hit and/or a SOAP request.
> 
> The processing takes on average 30 seconds to 1 minute, which is OK
for a
> web page (I can use set_time_limit(0) and just display a
pseudo-progress bar
> animated gif and a "Please wait..." message) but I can't leave the
SOAP
> request hanging for that long.  I need to send a response immediately.
> 
> What I really need to do is acknowledge the client that their request
has
> been received and will be processed, and terminate that request... and
THEN
> begin the processing.
> 
> One way I thought of doing it would be to put the requests into the
database
> and run a cron job every X minutes, but I would like to avoid this if
at all
> possible.
> 
> Someone had suggested pcntl_fork() but I'm not sure if that will
accomplish
> what I need it to... if I fork(), then send a response, kill the
parent and
> let the child run the process, will the HTTP request wait for the
child or
> will it die with the parent (like I want it to) ?
> 
> Any advice is much appreciated.
> 
> Thx,
> 
> Brad
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

I am not completely familiar with how forking works in PHP applications,
but I am fairly familiar with how it works in UNIX.  If you kill the
parent process, I believe it will close the HTTP request, but since it
doesn't handle the SIGCHLD signal after the child is done, the child
process will be left as a zombie process.  I believe the only way to
catch the SIGCHLD is to have the script pcntl_waitpid(), which would
then hang the HTTP request.

I haven't tested this, but you can easily test it by:

$pid = pcntl_fork();
 if($pid == -1) {
  // Something went wrong (handle errors here)
 } elseif($pid == 0) {
  // This part is only executed in the child
  usleep(500); //wait 5 seconds... see if the request hangs here
 } else {
  die(); 
 }

Then wait and see what happens.


Maybe there is someone more experience in this area that can put a few
words in, but that is what I believe to be the case.

-Logan

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



[PHP] set_time_limit failing...

2007-04-30 Thread Ashley M. Kirchner


   The manual says that set_time_limit has no effect when PHP is 
running in safe_mode.  Then I have a problem.  I have  the global 
safe_mode turned ON, however I have  'php_admin_value safe_mode 0' set 
in a vhost's config.  When I load up phpinfo(), it correctly tells me 
that the Master Value safe_mode is on, but the Local Value is off.  So 
then why is set_time_limit still complaining that it can't be set when 
running in safe mode, when in theory, safe_mode should not be on for 
that vhosts?



--
H | It's not a bug - it's an undocumented feature.
 +
 Ashley M. Kirchner    .   303.442.6410 x130
 IT Director / SysAdmin / Websmith . 800.441.3873 x130
 Photo Craft Imaging   . 3550 Arapahoe Ave. #6
 http://www.pcraft.com . .  ..   Boulder, CO 80303, U.S.A. 


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



Re: [PHP] Run a script apart from request

2007-04-30 Thread Eric Butera

On 4/30/07, Brad Fuller <[EMAIL PROTECTED]> wrote:

Hi all,

I am developing a program that does some intensive data processing, and is
triggered from a page hit and/or a SOAP request.

The processing takes on average 30 seconds to 1 minute, which is OK for a
web page (I can use set_time_limit(0) and just display a pseudo-progress bar
animated gif and a "Please wait..." message) but I can't leave the SOAP
request hanging for that long.  I need to send a response immediately.

What I really need to do is acknowledge the client that their request has
been received and will be processed, and terminate that request... and THEN
begin the processing.

One way I thought of doing it would be to put the requests into the database
and run a cron job every X minutes, but I would like to avoid this if at all
possible.

Someone had suggested pcntl_fork() but I'm not sure if that will accomplish
what I need it to... if I fork(), then send a response, kill the parent and
let the child run the process, will the HTTP request wait for the child or
will it die with the parent (like I want it to) ?

Any advice is much appreciated.

Thx,

Brad

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



This topic comes up every now and again.  You can search the mailing
list archives for all sorts of answers.  You can also handle this by
using fsockopen and hitting your execute script with a low timeout.
That way it will execute and you don't have to wait for it.

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



[PHP] About resource of popen

2007-04-30 Thread Fernando chucre

Hello all,

I make a script for read and interprete the stdout of cmd `ip monitor`. And
I use signal_handler, the script is like this:


this script run in infine loop, or when to cmd 'ip monitor' exist. The
script ever whait the next line of 'ip monitor', ever. Then when I send the
signal SIGHUP to pid of script. In this point the instruction '$line =
fgets($fh);' is aborted and return false to $line. The $fh is modified and
the function feof($fh) return true and I have not access to $fh agaim. But
the kid process 'ip monitor' is not kill.

This is wanted?

--
Fernando Chure
PSL/CE


RE: [PHP] small picture into thumbnail

2007-04-30 Thread WeberSites LTD
http://www.php-code-search.com/

Type "thumb"  without the "

berber

-Original Message-
From: Alain Roger [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 29, 2007 6:16 PM
To: PHP General List
Subject: [PHP] small picture into thumbnail

Hi,

I would like to know how i can display small sized picture in my web
application ?
I mean in my database, picture can have max. 500 Kb, however as on 1 PHP
page i will display 20 pictures at once, i do not want to force end users to
download all 20 pictures (10Mb around) to have an overview.

I would like directly on server to resize picture to display them to end
user in format 100px*120px (for example) and like that size should be around
20 or 50Kb per picture.
I was thinking to use imagecopyresized function for that, but will it no
kill the server CPU and RAM ?

If you have some other suggestion, they are welcome, but do not forget that
i must have pictures in Database and 500 Kb (due to picture printing later
on - so good enough quality).

thanks a lot,

--
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5

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



[PHP] postgreSQL and bytea / image

2007-04-30 Thread Alain Roger

Hi,

In my PHP page i upload pictures into database. For that i wrote a simple
function which control which user is logged and will upload his picture.

here is the function :

CREATE OR REPLACE FUNCTION sp_a_006("login" character varying, photo bytea)

  RETURNS boolean AS
$BODY$

DECLARE
my_idINTEGER :=0;
BEGIN
select into my_id
account_id from accounts where account_login = $1;
IF (my_id != 0) THEN
UPDATE users
SET user_photo = $2
WHERE user_account_id = my_id;
RETURN (TRUE);
ELSE
RETURN (FALSE);
end if;
END;



when i call this function in PHP, i do the following :

$my_query = "select * from immense.sp_a_006

('".$_SESSION["username"]."','{$escaped}')";
$res_pic = pg_query(my_query);



where $escaped = pg_escape_bytea($data);

this inserts the picture only if i add E in front of '{$escaped}' and
becomes E'{$escaped}').
why ?

on another website i do not use function but a simple SQL query as following
and it works :

pg_query("INSERT INTO photo (photo_id,document_orientation_id, photo_date,

photo_image)
  VALUES
(nextval('photo_photo_id_seq'),".$orientation_id[0].",NOW(),
'{$escaped}')");



thanks a lot,
--
Alain

Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5


RE: [PHP] small picture into thumbnail

2007-04-30 Thread Robert Cummings
On Mon, 2007-04-30 at 20:17 +0200, WeberSites LTD wrote:
> http://www.php-code-search.com/
> 
> Type "thumb"  without the "

If you're going to advertise your site, at least post a URL with the
search query embedded you insensitive clod!

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] PHP + COM (IE Button COM Server)

2007-04-30 Thread Iqbal Naved

Hi,

Anybody has implemented a IE button COM server in PHP ? I have found a
python implementation for this in pywin32 package. My objective is to add a
button in ie which will on click save the url in the address bar. I am
attatching the iebutton.py with this mail. Also, this is a link in msdn
instructing add toolbar buttons:

http://msdn2.microsoft.com/en-us/library/aa753588.aspx

Any code snippet will be extremely useful.

Thanks in advance.

-Iqbal Naved
# encoding: latin-1

# PyWin32 Internet Explorer Button
#
# written by Leonard Ritter ([EMAIL PROTECTED])
# and Robert Förtsch ([EMAIL PROTECTED])


"""
This sample implements a simple IE Button COM server
with access to the IWebBrowser2 interface.

To demonstrate:
* Execute this script to register the server.
* Open Pythonwin's Tools -> Trace Collector Debugging Tool, so you can
  see the output of 'print' statements in this demo.
* Open a new IE instance.  The toolbar should have a new "scissors" icon,
  with tooltip text "IE Button" - this is our new button - click it.
* Switch back to the Pythonwin window - you should see:
   IOleCommandTarget::Exec called.
  This is the button being clicked.  Extending this to do something more
  useful is left as an exercise.

Contribtions to this sample to make it a little "friendlier" welcome!
"""

# imports section
import sys, os
from win32com import universal
from win32com.client import gencache, DispatchWithEvents, Dispatch
from win32com.client import constants, getevents
import win32com.server.register
import win32com
import pythoncom
import win32api

# This demo uses 'print' - use win32traceutil to see it if we have no
# console.
try:
win32api.GetConsoleTitle()
except win32api.error:
import win32traceutil

from win32com.axcontrol import axcontrol

import array, struct

# ensure we know the ms internet controls typelib so we have access to 
IWebBrowser2 later on
win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-C05BAE0B}',0,1,1)


# 
IObjectWithSite_methods = ['SetSite','GetSite']
IOleCommandTarget_methods = ['Exec','QueryStatus']

_iebutton_methods_ = IOleCommandTarget_methods + IObjectWithSite_methods
_iebutton_com_interfaces_ = [
axcontrol.IID_IOleCommandTarget,
axcontrol.IID_IObjectWithSite, # IObjectWithSite
]

class Stub:
"""
this class serves as a method stub,
outputting debug info whenever the object
is being called.
"""

def __init__(self,name):
self.name = name

def __call__(self,*args):
print 'STUB: ',self.name,args

class IEButton:
"""
The actual COM server class
"""
_com_interfaces_ = _iebutton_com_interfaces_
_public_methods_ = _iebutton_methods_
_reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
_button_text_ = 'IE Button'
_tool_tip_ = 'An example implementation for an IE Button.'
_icon_ = ''
_hot_icon_ = ''

def __init__( self ):
# put stubs for non-implemented methods
for method in self._public_methods_:
if not hasattr(self,method):
print 'providing default stub for %s' % method
setattr(self,method,Stub(method))

def QueryStatus (self, pguidCmdGroup, prgCmds, cmdtextf):
# 'cmdtextf' is the 'cmdtextf' element from the OLECMDTEXT structure,
# or None if a NULL pointer was passed.
result = []
for id, flags in prgCmds:
flags |= axcontrol.OLECMDF_SUPPORTED  | axcontrol.OLECMDF_ENABLED 
result.append((id, flags))
if cmdtextf is None:
cmdtext = None # must return None if nothing requested.
# IE never seems to want any text - this code is here for
# demo purposes only
elif cmdtextf == axcontrol.OLECMDTEXTF_NAME:
cmdtext = "IEButton Name"
else:
cmdtext = "IEButton State"
return result, cmdtext

def Exec(self, pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn):
print pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn
print "IOleCommandTarget::Exec called."
#self.webbrowser.ShowBrowserBar(GUID_IETOOLBAR, not 
is_ietoolbar_visible())

def SetSite(self,unknown):
if unknown:
# first get a command target
cmdtarget = unknown.QueryInterface(axcontrol.IID_IOleCommandTarget)
# then travel over to a service provider
serviceprovider = 
cmdtarget.QueryInterface(pythoncom.IID_IServiceProvider)
# finally ask for the internet explorer application, returned as a 
dispatch object
self.webbrowser = 
win32com.client.Dispatch(serviceprovider.QueryService('{0002DF05---C000-0046}',pythoncom.IID_IDispatch))
else:
# lose all references
self.webbrowser = None

def GetClassID(self):
return self._reg_clsid_

def register(classobj):
import _winreg
subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s

[PHP] What does "<<<" mean?

2007-04-30 Thread Nick Gorbikoff
Hello, folks.
I rember I've since this somewhere in perl and it has somethign to do with
blocks of code. I came across the same thing in some PHP code.
 
<<< END
 some code
END
 
What exactly does it mean.
 
BTW:
PHP .net search breaks if you search for <<<
 
 
Regards,
 
--
Nick 


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__

Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Greg Donald

On 4/30/07, Nick Gorbikoff <[EMAIL PROTECTED]> wrote:

Hello, folks.
I rember I've since this somewhere in perl and it has somethign to do with
blocks of code. I came across the same thing in some PHP code.

<<< END
 some code
END

What exactly does it mean.

BTW:
PHP .net search breaks if you search for <<<



It's heredoc syntax.

http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc



--
Greg Donald
http://destiney.com/

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Daniel Brown

   It means to read until it reaches the matching expression --- in this
case, END.

On 4/30/07, Nick Gorbikoff <[EMAIL PROTECTED]> wrote:


Hello, folks.
I rember I've since this somewhere in perl and it has somethign to do with
blocks of code. I came across the same thing in some PHP code.

<<< END
some code
END

What exactly does it mean.

BTW:
PHP .net search breaks if you search for <<<


Regards,

--
Nick


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
__





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Micky Hulse

Hi Daniel,

Daniel Brown wrote:

BTW:
PHP .net search breaks if you search for <<<


Try this:

www.php.net/<<<

And then scroll down to heredoc section.

Heredoc comes in handy from time-to-time.

Cheers,
M


--
Wishlists: 
   Switch: 
 BCC?: 
   My: 

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Daniel Brown

   Actually, that should be directed at the OP who said that.  I was able
to bring up the heredoc, too.  ;-P



On 4/30/07, Micky Hulse <[EMAIL PROTECTED]> wrote:


Hi Daniel,

Daniel Brown wrote:
>> BTW:
>> PHP .net search breaks if you search for <<<

Try this:

www.php.net/<<<

And then scroll down to heredoc section.

Heredoc comes in handy from time-to-time.

Cheers,
M


--
Wishlists: 
Switch: 
  BCC?: 
My: 

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





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Micky Hulse

Daniel Brown wrote:

   Actually, that should be directed at the OP who said that.  I was able
to bring up the heredoc, too.  ;-P


Ooops! Sorry Daniel, I meant to reply to Nick... My mistake. :(


--
Wishlists: 
   Switch: 
 BCC?: 
   My: 

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Daniel Brown

   No need to apologize at all, Micky!

On 4/30/07, Micky Hulse <[EMAIL PROTECTED]> wrote:


Daniel Brown wrote:
>Actually, that should be directed at the OP who said that.  I was
able
> to bring up the heredoc, too.  ;-P

Ooops! Sorry Daniel, I meant to reply to Nick... My mistake. :(


--
Wishlists: 
Switch: 
  BCC?: 
My: 

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





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


[PHP] newbie needs help

2007-04-30 Thread Ben Clapp
I am new to PHP programming and need some help. I have an image that i 
have show up each May for the month with $mymonth = date("m", mktime()), 
but i want to set up a date range for it to show up. Ex. 4-13 to 5-13 
each year. How can I do that? Any help would be great.


Thank you
Ben

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



Re: [PHP] newbie needs help

2007-04-30 Thread Daniel Brown

   One way would be to do this:

 413 && date("md") < 513) {
   // Display image
}
?>



On 4/30/07, Ben Clapp <[EMAIL PROTECTED]> wrote:


I am new to PHP programming and need some help. I have an image that i
have show up each May for the month with $mymonth = date("m", mktime()),
but i want to set up a date range for it to show up. Ex. 4-13 to 5-13
each year. How can I do that? Any help would be great.

Thank you
Ben

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





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] newbie needs help

2007-04-30 Thread Richard Davey

Ben Clapp wrote:

I am new to PHP programming and need some help. I have an image that i 
have show up each May for the month with $mymonth = date("m", mktime()), 
but i want to set up a date range for it to show up. Ex. 4-13 to 5-13 
each year. How can I do that? Any help would be great.


There are loads of ways, but hopefully as you're new to PHP this one 
will be easy to follow and make sense:


$start_date = strtotime('4 August 2007');
$end_date = strtotime('9 October 2007');
$current = time();

if ($current >= $start_date && $current <= $end_date)
{
// Do whatever should only happen between the
// 4th of August and the 9th of October here
}

strtotime() is extremely powerful / useful, and well worth reading about:

http://uk.php.net/manual/en/function.strtotime.php

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] newbie needs help

2007-04-30 Thread Daniel Brown

   Ben, make sure whatever method you use, you use the operator
combinations >= and <= as Richard just showed you.  I had forgotten to do
that, which would mean (in my example) that the 13th of April and 13th of
May of each year would not be counted, only 14 April through 12 May of any
given year.  Also, expanding on Richard's example, you can make it dynamic
per year by combining the strtorime() and date() functions, so you wouldn't
have to update your code annually.  However, this would only work if both
dates were within the same (current) year at the time the script was
executed:

= $start_date && $current <= $end_date)
{
  // Do whatever should only happen between the
  // 4th of August and the 9th of October here
}
?>

On 4/30/07, Richard Davey <[EMAIL PROTECTED]> wrote:


Ben Clapp wrote:

> I am new to PHP programming and need some help. I have an image that i
> have show up each May for the month with $mymonth = date("m", mktime()),
> but i want to set up a date range for it to show up. Ex. 4-13 to 5-13
> each year. How can I do that? Any help would be great.

There are loads of ways, but hopefully as you're new to PHP this one
will be easy to follow and make sense:

$start_date = strtotime('4 August 2007');
$end_date = strtotime('9 October 2007');
$current = time();

if ($current >= $start_date && $current <= $end_date)
{
// Do whatever should only happen between the
// 4th of August and the 9th of October here
}

strtotime() is extremely powerful / useful, and well worth reading about:

http://uk.php.net/manual/en/function.strtotime.php

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] newbie needs help

2007-04-30 Thread Ben Clapp

Thank you both, I will try the code and go from there. Thank you again

Daniel Brown wrote:


Ben, make sure whatever method you use, you use the operator 
combinations >= and <= as Richard just showed you.  I had forgotten to 
do that, which would mean (in my example) that the 13th of April and 
13th of May of each year would not be counted, only 14 April through 
12 May of any given year.  Also, expanding on Richard's example, you 
can make it dynamic per year by combining the strtorime() and date() 
functions, so you wouldn't have to update your code annually.  
However, this would only work if both dates were within the same 
(current) year at the time the script was executed:


= $start_date && $current <= $end_date)
{
   // Do whatever should only happen between the
   // 4th of August and the 9th of October here
}
?>

On 4/30/07, *Richard Davey * <[EMAIL PROTECTED] 
> wrote:


Ben Clapp wrote:

> I am new to PHP programming and need some help. I have an image
that i
> have show up each May for the month with $mymonth = date("m",
mktime()),
> but i want to set up a date range for it to show up. Ex. 4-13 to
5-13
> each year. How can I do that? Any help would be great.

There are loads of ways, but hopefully as you're new to PHP this one
will be easy to follow and make sense:

$start_date = strtotime('4 August 2007');
$end_date = strtotime('9 October 2007');
$current = time();

if ($current >= $start_date && $current <= $end_date)
{
// Do whatever should only happen between the
// 4th of August and the 9th of October here
}

strtotime() is extremely powerful / useful, and well worth reading
about:

http://uk.php.net/manual/en/function.strtotime.php

Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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




--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107 


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



Re: [PHP] newbie needs help

2007-04-30 Thread Richard Davey

Ben Clapp wrote:

Thank you again for the help, it does work now but with an issue, here 
is the code that i have for it right now:


You should always reply to the php mailing list, so other people can 
benefit from the answers we give.


With this it works, but i am sure that when mymonth == 5 (may 1st, 
tomorrow) I will have two of the same pictures.


You are right, you will. Because you're running the mothers day check 
twice, once with the 'new' code I gave you, and once with your old code.



If I take out this bit of code from the above code:
then NOTHING shows up. Am I not getting something right or is there 
something elese that is getting in the way or is something not being 
completed?


You've got missing { } around your if blocks. You also could make the 
code a lot more tidy / easy to read. Try the following (it replaces 
entirely the code you emailed me, swap all of it for this)



href="http://pancan.com/Patient/pancreatic.html"; target="_blank">src="../images/ads/pancanNov_banner.jpg" width="777" height="182" 
border="0">


= $start_date && $current <= $end_date)
{
?>
href="../images/passportad/mothersdayBanner.jpg" target="_blank">src="../images/passportad/mothersdayBanner.jpg" width="771" height="112" 
border="0" />




Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] newbie needs help

2007-04-30 Thread Daniel Brown

   Good catch on the non-list reply, Richard.  I didn't even notice that.


On 4/30/07, Richard Davey <[EMAIL PROTECTED]> wrote:


Ben Clapp wrote:

> Thank you again for the help, it does work now but with an issue, here
> is the code that i have for it right now:

You should always reply to the php mailing list, so other people can
benefit from the answers we give.

> With this it works, but i am sure that when mymonth == 5 (may 1st,
> tomorrow) I will have two of the same pictures.

You are right, you will. Because you're running the mothers day check
twice, once with the 'new' code I gave you, and once with your old code.

> If I take out this bit of code from the above code:
> then NOTHING shows up. Am I not getting something right or is there
> something elese that is getting in the way or is something not being
> completed?

You've got missing { } around your if blocks. You also could make the
code a lot more tidy / easy to read. Try the following (it replaces
entirely the code you emailed me, swap all of it for this)


http://pancan.com/Patient/pancreatic.html"; target="_blank">

= $start_date && $current <= $end_date)
 {
?>




Cheers,

Rich
--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"





--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107


Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Philip Thompson

On Apr 30, 2007, at 2:17 PM, Greg Donald wrote:


On 4/30/07, Nick Gorbikoff <[EMAIL PROTECTED]> wrote:

Hello, folks.
I rember I've since this somewhere in perl and it has somethign to  
do with

blocks of code. I came across the same thing in some PHP code.

<<< END
 some code
END

What exactly does it mean.

BTW:
PHP .net search breaks if you search for <<<



It's heredoc syntax.

http://us2.php.net/manual/en/ 
language.types.string.php#language.types.string.syntax.heredoc



Ok, let's gather some stats to see how many people actually use the  
heredoc syntax. I created this quick little form to gather the data.  
It's takes 2 seconds (literally) - vote here:


http://thril.uark.edu/heredoc/

I'm interested in knowing if this is used a lot. If it is, then I may  
consider tying it into my code (if it calls for it).


~Philip

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Greg Donald

On 4/30/07, Philip Thompson <[EMAIL PROTECTED]> wrote:

Ok, let's gather some stats to see how many people actually use the
heredoc syntax. I created this quick little form to gather the data.
It's takes 2 seconds (literally) - vote here:

http://thril.uark.edu/heredoc/



If you're not using it you're working yourself way too hard.


echo "=== UPLOAD FILE ===\n";
echo "CLIENT:  " . $_SERVER['REMOTE_ADDR'] . "\n";
echo "BROWSER: " . $_SERVER['HTTP_USER_AGENT'] . "\n";
echo "TIME:" . date("Y-m-d H:i:s") . "\n";
echo "ENCODED: $encoded\n";
echo "UID: $uid\n";
echo "PATH:$path\n";
echo "EMAIL:   $email\n";
echo "PROJECT: $prj\n";
echo "LENGTH:  " . $_SERVER['CONTENT_LENGTH'] . "\n";
echo "\n";


Versus:


$date = date( 'Y-m-d H:i:s' );

echo <

RE: [PHP] What does "<<<" mean?

2007-04-30 Thread Daevid Vincent
> echo "BROWSER: " . $_SERVER['HTTP_USER_AGENT'] . "\n";

I've always had problems with heredoc when I try using arrays like that. I
will either pull them into a straight $foo, or use the ${} thing.

> echo << BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;

Isn't that form (sans quote marks) deprecated and frowned upon?

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Greg Donald

On 4/30/07, Daevid Vincent <[EMAIL PROTECTED]> wrote:

> echo << BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;

Isn't that form (sans quote marks) deprecated and frowned upon?


http://destiney.com/

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



RE: [PHP] What does "<<<" mean?

2007-04-30 Thread Brian Seymour
Heredoc is truly a great thing. You'll learn to love heredoc whenever you
have tons of stuff you need to print instead of escaping php. A great
example is output that comes from classes, where you can't break the class
into multiple code blocks. Just don't forget that heredoc end part has to be
on the very next line with no whitespace to start. Confusing at times.

Cheers!
-BRIAN

>Ok, let's gather some stats to see how many people actually use the  
>heredoc syntax. I created this quick little form to gather the data.  
>It's takes 2 seconds (literally) - vote here:

>http://thril.uark.edu/heredoc/

>I'm interested in knowing if this is used a lot. If it is, then I may  
>consider tying it into my code (if it calls for it).

>~Philip

>-- 
>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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Paul Novitski

At 4/30/2007 03:38 PM, Philip Thompson wrote:

Ok, let's gather some stats to see how many people actually use the
heredoc syntax. I created this quick little form to gather the data.
It's takes 2 seconds (literally) - vote here:

http://thril.uark.edu/heredoc/

I'm interested in knowing if this is used a lot. If it is, then I may
consider tying it into my code (if it calls for it).



I recommend that you to make your decision about using heredoc based 
on whether the syntax itself makes good sense to you, not based on 
which number or percentage of other programmers use it.


I love using heredoc and I don't give a rat's ass if there are only 
three other people in the world who use it.  It absolutely makes 
sense to me, helps me write better code with fewer errors and that's 
much easier to read.  I know from previous discussions of this topic 
that it gives some people the freakin' heebee-jeebies.  That's fine; 
different strokes; doesn't matter.  It's just one tool.


I use heredoc mostly for SQL queries, for html blocks, for inline 
html assembly, and for other circumstances in which I'm merging 
literals & variables.  If a statement gets messy with too many 
concatenations, I'll use heredoc.  I use heredoc for much the same 
reasons I like to separate data from logic in separate files.  The 
next best thing to importing text is to heredoc it in the script 
itself.  Also heredoc can be a quick & dirty way of roughing out a 
script to get the logic right before exporting the text to a separate file.


Another commenter in this thread is correct: you can't get away with 
referring to an array variable in heredoc without using {curly 
braces} e.g. {$aArray['key']}.  That and the fact that the 
termination symbol has to be at the left margin are minor 
disadvantages in my view, far outweighed by the difficulty in 
accurately writing and reading complex concatenations.


When I first started using PHP I thought that each heredoc label had 
to be unique.  Turns out that's not true, and now I use the simple shorthand:


$sResult = <<<_
Some text.
_;

Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 


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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Richard Davey

Greg Donald wrote:


On 4/30/07, Daevid Vincent <[EMAIL PROTECTED]> wrote:

> echo << BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;

Isn't that form (sans quote marks) deprecated and frowned upon?




I'm not dissing heredoc syntax, it has its uses (now and again) but it's 
far from "clean", especially when embedded deep in classes - the major 
cause being the delimeters insistance on being at the very start of the 
line. It's just *not* pretty IMHO. Certainly not girl code [1]


The frowning surely would be at the mixing of logic and presentation, 
regardless how that mix happens (heredoc, echo, jumping in and out of 
PHP tags, sprintf, etc).


Cheers,

Rich

[1] 
http://headrush.typepad.com/creating_passionate_users/2006/03/code_like_a_gir.html

--
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Greg Donald

On 4/30/07, Richard Davey <[EMAIL PROTECTED]> wrote:

I'm not dissing heredoc syntax, it has its uses (now and again) but it's
far from "clean", especially when embedded deep in classes


Classes?  PHP is the absolute worst language to do OO programming in.
If you like OO, move on to ruby or python, you'll be much happier.  Or
you can wait around until PHP fully (d)evolves into Java.


the major
cause being the delimeters insistance on being at the very start of the
line.


All parts of a heredoc statement do not have to be right justified,
only the closing line.


It's just *not* pretty IMHO. Certainly not girl code [1]


Mmmm..  girls..  coding..  :)


The frowning surely would be at the mixing of logic and presentation,


Sounds like you got MVC-itis.  PHP can't really help with that since
it's a templating language.

Try Rubyonrails, it's the best cure for the MVC itch.


regardless how that mix happens (heredoc, echo, jumping in and out of
PHP tags, sprintf, etc).


I love me some heredoc syntax:

#!/usr/bin/env perl -w

$x = 

Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Greg Donald

On 4/30/07, Greg Donald <[EMAIL PROTECTED]> wrote:

All parts of a heredoc statement do not have to be right justified,
only the closing line.


I meant my other right, the one on my left.  Sorry.


--
Greg Donald
http://destiney.com/

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Robert Cummings
On Mon, 2007-04-30 at 19:42 -0500, Greg Donald wrote:
> On 4/30/07, Richard Davey <[EMAIL PROTECTED]> wrote:
> > I'm not dissing heredoc syntax, it has its uses (now and again) but it's
> > far from "clean", especially when embedded deep in classes
> 
> Classes?  PHP is the absolute worst language to do OO programming in.
> If you like OO, move on to ruby or python.

You sissy, Ruby and Python suck. One baseless statement deserves
another. Feel free to back up your statement with verifiable proof.

> , you'll be much happier.  Or
> you can wait around until PHP fully (d)evolves into Java.

Unlikely.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] What does "<<<" mean?

2007-04-30 Thread Micky Hulse

Greg Donald wrote:

Try Rubyonrails, it's the best cure for the MVC itch.


Django framework is pretty nice too. :)


--
Wishlists: 
   Switch: 
 BCC?: 
   My: 

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



RE: [PHP] sloppy use of constants as strings. WAS: What does "<<<" mean?

2007-04-30 Thread Daevid Vincent
> > > echo << > > BROWSER: $_SERVER[HTTP_USER_AGENT]
> > > EOF;
> >
> > Isn't that form (sans quote marks) deprecated and frowned upon?
> 
>  
> error_reporting( E_ALL );
> 
> echo << BROWSER: $_SERVER[HTTP_USER_AGENT]
> EOF;
> 
> Why would cleaner, perfectly error free code be frowned upon?

http://us2.php.net/manual/en/language.types.array.php
"A key may be either an integer or a string. If a key is the standard
representation of an integer, it will be interpreted as such (i.e. "8" will
be interpreted as 8, while "08" will be interpreted as "08")."

I was always under the impression that using:

$_SERVER[HTTP_USER_AGENT] or $foo[myindex]

Was "bad" compared to the proper way of:

$_SERVER['HTTP_USER_AGENT'] or $foo['myindex']

Just like it's:

define('MYTHING', true);

not

define(MYTHING, true);


(again, note the ' marks)

http://us2.php.net/manual/en/function.define.php
http://us2.php.net/manual/en/language.constants.php

"If you use an undefined constant, PHP assumes that you mean the name of the
constant itself, just as if you called it as a string (CONSTANT vs
"CONSTANT"). An error of level E_NOTICE will be issued when this happens.
See also the manual entry on why $foo[bar] is wrong (unless you first
define() bar as a constant). If you simply want to check if a constant is
set, use the defined() function."

So, I think you're relying upon a little work that PHP does for you in that
an undefined CONSTANT is turned into a STRING i.e. "bad". Personally, I
*hate* that it does this work, and would love to see a little stricter
parsing done and throw a fatal error if you try to use an undefined
constant.

D.Vin

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



Re: [PHP] sloppy use of constants as strings. WAS: What does "<<<" mean?

2007-04-30 Thread Chris

> Personally, I

*hate* that it does this work, and would love to see a little stricter
parsing done and throw a fatal error if you try to use an undefined
constant.


You can do this yourself.

See http://php.net/set_error_handler

--
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] What does "<<<" mean?

2007-04-30 Thread Larry Garfield
On Monday 30 April 2007, Greg Donald wrote:


> Sounds like you got MVC-itis.  PHP can't really help with that since
> it's a templating language.
>
> Try Rubyonrails, it's the best cure for the MVC itch.

Except that it's a PAC framework, not MVC, like the vast majority of web apps 
frameworks out there in any language.  The web just doesn't lend itself to 
MVC.  Sun just likes to get their terminology wrong and confuse everyone for 
the next decade.

http://www.garfieldtech.com/blog/mvc-vs-pac

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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