RE: [PHP] What do I do wrong?

2003-03-13 Thread John W. Holmes
 Hey everybody,
 
 I get the message:
 
 Notice: Undefined variable: msg in
 F:\www-root\domain.com\website\script.php on line 202
 
 whats wrong?

I'm not very good at PHP, but I'd have to say the problem is that you've
got an undefined variable called $msg on line 202 in script.php... but I
could be wrong.

---John W. Holmes...

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



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



RE: [PHP] Will this do what I think it will?

2003-03-13 Thread John W. Holmes
 I call this file 'clean_gpc.php'.
 
 Will it:
   // trim all control codes and spaces from ends of string
   // standardize Window's CRLF in middle of string to \n
   // standardize Apple's  LF   in middle of string to \n
   // remove all control characters BELOW \n
   // remove all control characters ABOVE \n
   // compresse run on spaces to a single space
   // compresse run on carriage returns to a max of 2

Sure... why not. Honestly, why did you write this email? You wasted a
couple hundred people's time when you could have just run the function
yourself. 

---John W. Holmes...

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



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



RE: [PHP] ^M in PHP

2003-03-13 Thread John W. Holmes
 I'm downloading a file from Windows to Linux through PHP.
Understandably,
 there are ^Ms at the end of my lines. Is there a PHP function I can
use to
 delete them?

Use a decent text editor that'll save the files in Unix format... even
if you're on a PC.

Let's NOT get into a
text-editor-suggestion-what-I-use-is-best-and-it-does-this-and-that-whic
h-the-other-ones-don't-oh-and-by-the-way-mine-is-free/cheap/easy/opensou
rce-too war, okay. Search the archives, there are plenty of
recommendations. :)

---John W. Holmes...

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



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



RE: [PHP] ^M in PHP

2003-03-13 Thread John W. Holmes
  Use a decent text editor that'll save the files in Unix format...
even
  if you're on a PC.
 
 Yeah, I could use a decent text editor, but not everyone who uses my
site
 will use it. I need something that can edit them out after download.

Wouldn't it be smarter to eliminate them before it was saved on Windows?
You could read in the file and get rid of all of the \r characters with
str_replace(). 

---John W. Holmes...

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



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



RE: [PHP] preg_replace question,

2003-03-13 Thread John W. Holmes
 yes another one sorry, i'm trying to find the most efficient way to do
a
 replactment over this
 eregi_replace(\[f$key\f\],$value,format_content($content));, would
 preg_replace be quicker and how could i go about it ?
 
 i'd need to replace [f1247f] with its replacement value better still
maybe
 even [1313431] is needed ? i dont know why they has f's in there ?

What exactly are you trying to match and replace? Anything between [ and
]? Is 'f' the only letter that might appear? Is there a limit on the
amount of numbers that'll be between [ and ]? Are you replacing all
matches with the same $value?

---John W. Holmes...

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



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



RE: [PHP] Checkboxes

2003-03-13 Thread John W. Holmes
 I am trying to get results form checkboxes on a form.  Each checkbox
is
 given a value of the id of an item in a table.  What I want to do is
find
 out what is selected and from there get the id so I can create a sql
 insert
 statement for each selected item.
 
 I can get the item selected but not a value.
 I am using:
 
 PHP:
 
 if (count($_POST['skill'])0) {
  for  ($i=0;$icount($_POST['skill']);$i++){
   echo li$fskill[$i]\n;
  }
 }
 
 inside a form
 input type=checkbox name=skill[] value=1
 input type=checkbox name=skill[] value=2
 input type=checkbox name=skill[] value=3
 
 I get a number of bullets representing the items I check but no value!

What is $fskill? Did you forget to update your code?

echo li{$_POST['skill'][$i]}/li\n;

---John W. Holmes...

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



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



Re: [PHP] Will this do what I think it will?

2003-03-14 Thread CPT John W. Holmes
How didn't it work? How did you test it? I'd be more than willing to help
you test it, but everything is sort of vague right now.

---John Holmes...

- Original Message -
From: Dennis Gearon [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 12:20 AM
Subject: Re: [PHP] Will this do what I think it will?


 Well,
 it didn't work, and I wrote it because I'm unfamiliar with regex's.

 John W. Holmes wrote:
 
   I call this file 'clean_gpc.php'.
  
   Will it:
 // trim all control codes and spaces from ends of string
 // standardize Window's CRLF in middle of string to \n
 // standardize Apple's  LF   in middle of string to \n
 // remove all control characters BELOW \n
 // remove all control characters ABOVE \n
 // compresse run on spaces to a single space
 // compresse run on carriage returns to a max of 2
 
  Sure... why not. Honestly, why did you write this email? You wasted a
  couple hundred people's time when you could have just run the function
  yourself.
 
  ---John W. Holmes...
 
  PHP Architect - A monthly magazine for PHP Professionals. Get your copy
  today. http://www.phparch.com/


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



RE: [PHP] date

2003-03-14 Thread John W. Holmes
 If I have a date in this format :19-MAR-03 how do I get the next date
(the
 date plus 1)?

echo strtoupper(date('d-M-y',strtotime($date +1 day)));

But why do you have it in that format to begin with?

---John W. Holmes...

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



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



RE: [PHP] preg_replace question,

2003-03-14 Thread John W. Holmes
 the current function been put in place replaces [f1253f] with a file,
for
 inside cms content , where 1253 is the key or the id of the filename
in
 the
 database , therefore to denote its an ftool they added f's around the
keys
 ,
 so maybe i could get away with [1253], what else i'm asking if
 preg_replace is
 more efficient over eregi_replace ?

Yeah, it is.

preg_match_all(/\[f([0-9]+)f\]/i,$string,$matches);

$matches will then contain the numbers you're looking for (in an array).
Read the file or whatever you need, then do another replace to put the
file contents in place of the code. 

If you read it like this:

$file['1234'] = data from file 1234;
$file['3456'] = data from file 3456;

You can use the following to replace the tags

preg_replace(/\[f([0-9]+)\]/ie,'$file[$1]',$string);

the last one is untested, but something like that works. The key is the
'e' modifier. If you know you're always going to have lower case 'f'
characters, then remove the 'i' modifier from each pattern.

---John Holmes...



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



Re: [PHP] php/mySQL time comparison

2003-03-14 Thread CPT John W. Holmes
$timeFrom and $timeTo need to be surrounded by quotes within your SQL query
for the format you're using.

$query = select * from Job_TB where teamNo = $teamNo AND startTime =
'$timeFrom' AND endTime = '$timeTo';

---John Holmes...

- Original Message -
From: Brad Wright [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 9:33 AM
Subject: [PHP] php/mySQL time comparison


Hi all,

I have been tearing my hair out for weeks with this problem, hope someone
can help.

I want to pull all data out of a mysql table that falls between two dates (a
start-time and end-time).

I use PHP to allow the user to specify the time interval, creating 2
variables
'startTime' and 'endTime'. These are formatted thus: 2002-02-25 00:00:00
(-MM-DD HH:mm:ss).

I then use the syntax:
$query = select * from Job_TB where teamNo = $teamNo AND startTime =
$timeFrom AND endTime = $timeTo;
$result = mysql_query($query,$db) or die (somethings wrong);

to query the mysql DB. But it doesnt work. Is there a glaring error in my
syntax?

Can anyone help with this as its driving me nuts

Hope someone can help, thanks in advance,
brad
Cheers,

Brad


Nel vino la verità, nella birra la forza, nell'acqua i bacilli
--
In wine there is truth, in beer there is strength, in water there are
bacteria


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

2003-03-14 Thread CPT John W. Holmes
 Try quoting your dates - you could also edit your code by using the
 BETWEEN SQL keywors.

Using the less than / greater than method is slightly faster and probably
more portable. I don't know how many databases implement BETWEEN.

---John Holmes...


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



Re: [PHP] Newbie MySQL INSERT Q

2003-03-14 Thread CPT John W. Holmes
 Can I have a single SQL string do INSERTS into multiple tables?

No.

---John Holmes...

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



Re: [PHP] Problem with sessions expiring?

2003-03-14 Thread CPT John W. Holmes
Session files will be cleaned up after 24 minutes by default. So if they
take longer than that, and the garbage collection deletes their session
file, then they are no longer logged in. Increase the session.gc_maxlifetime
parameter in php.ini

---John Holmes...

- Original Message -
From: Mallen Baker [EMAIL PROTECTED]
To:  [EMAIL PROTECTED]
Sent: Friday, March 14, 2003 10:59 AM
Subject: [PHP] Problem with sessions expiring?


Hi

I have a process for people to apply for awards online. The login is
controlled using sessions, with a basic session variable set with the
username of the person logged in. In PHP ini the session cookie lifetime is
set to 0 - ie. until the browser session finishes.

Manyof the applicants are using the system, and it is fine.

But a significant minority are having the same problem. They log in, spend
some time entering data into the fields on the form, and when the hit the
button to either save or submit the entry they get a 'you are not logged in'
message and - worse - lose the data they have so far inputted. One user
experienced this after an hour and a half's work - but others have had
problems after considerably shorter periods of time.

As far as I can tell, the problem is not restricted to one platform, and I
haven't yet been able to locate anything that applies to them that wouldn't
apply to others who have successfully used the system.

Is there any known problem - perhaps in relation to certain kinds of
firewall - that would explain this behaviour? Any thoughts on the workaround
I might do short term (above and beyond encouraging people to write their
applications in Word before submitting them) that might alleviate the
problem?

Deadline for the award is two weeks and traffic is getting quite high. Any
help you can give me before it gets worse would be gratefully received!

Thanks - Mallen



This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk


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

2003-03-15 Thread John W. Holmes
 Is or has anyone here been part of or started a PHP user group? I am
 thinking it would be a great thing to get started in my area (maybe
one
 already exists?) and I was looking for suggestions on how to go about
 it and things to know before getting started, etc.
 BTW. I live in Southern New Jersey (USA)

Check http://php.meetup.com/ for your area.

---John W. Holmes...

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



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



RE: [PHP] Encoding /'s

2003-03-15 Thread John W. Holmes
 When my PHP page sends text that is being passed in, it places an /
in
 front of the apostrophe.  How do I encode or decode this when I am
 outputing
 the variable?

www.php.net/stripslashes

They are added to GET, POST, COOKIE data according to the
magic_quotes_gpc setting in php.ini.

---John W. Holmes...

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



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



RE: [PHP] Arrays

2003-03-16 Thread John W. Holmes
 $var = array (
 'AN' = array (
   'Description' = 'Accession Number: (AN)',
   'ReferenceURL' = 'AN__Accession_Number.jsp',
   ),
  'AU' = array (
   'Description' = 'Author(s): (AU)',
   'ReferenceURL' = 'AU__Author(s).jsp',
   )
 )
 
 What I want to get is the keys 'AN' and 'AU' as values.
 
 while (??){
 echo This key is $var[??]br;
 }
 
 This key is AN
 This key is AU

foreach($var as $key = $value)
{ echo The key is $key; }

---John W. Holmes...

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



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



RE: [PHP] Scrolling through values sent from a form[scanned]

2003-03-16 Thread John W. Holmes
Don't rely on checkboxes. If they are not checked, as you've found out I
think, then the value is not set at all. Use a hidden value to carry
over a key for each field, then check the checkbox to see whether it was
checked or not. 

---John W. Holmes...

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

 -Original Message-
 From: shaun [mailto:[EMAIL PROTECTED]
 Sent: Sunday, March 16, 2003 1:16 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Scrolling through values sent from a form
 
 Hi,
 
 i have a form on a page which is built dynamically and consists of
fields
 in
 a certain table and checkboxes. The puropse of the form is to update
the
 the
 status of a table called CMS_FIELDS which stores data of all the
fields
 for
 all the tables in the database.
 
 Using the following code i am attempting to update the table depending
on
 whether the boxes have been ticked or not, but the script only outputs
 values of the boxes that have been ticked. (the data isn't being
updated
 yet
 i am just printing it to the screen for testing purposes).
 
   if(isset($update_fields)==true){
$fields='';
$values='';
foreach ($_POST as $key = $val) {
  $fields[] = $key;
  $values[] = $val;
}
$i=0;
foreach ($fields as $val){
 if ($values[$i] == on){
  $query = UPDATE CMS_FIELDS SET cms_fields_is_editable = '1'
WHERE cms_table_name = '$_GET[table_name]' AND
 cms_field_name
 = '.$fields[$i].';
 }else {
  $query = UPDATE CMS_FIELDS SET cms_fields_is_editable = '0'
WHERE cms_table_name = '$_GET[table_name]' AND
 cms_field_name
 = '.$fields[$i].';
 }
 echo $querybr;
 $i++;
}
   }
 
 How can i get the script to look at all of the values sent from the
form
 (ticked or unticked)?
 
 thanks for your help
 
 
 
 --
 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] passing values from one script to another script

2003-03-16 Thread John W. Holmes
 I want to pass a value, which came from a HTML form, to another PHP
 script. How can i do this?
 
 e.g.: $login - the value of this varriable is came from LOGIN.HTML to
 LOGIN.PHP. How can i pass the value of $login from LOGIN.PHP to
 PROCESS.PHP?

The easiest way is with a session. Remember, each request is unique, so
if you want to carry something over, you have to include it in the next
request. This means adding it to the URL ($_GET) or adding it to a form
($_POST), adding it to a cookie ($_COOKIE), or putting it in the session
($_SESSION).

---John W. Holmes...

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



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



RE: [PHP] RE: ignore html

2003-03-16 Thread John W. Holmes
 hi guys trikky question , i would like to ignore html in content that
i am
 replacing news lines with page breaks , how is it possible ? at the
moment
 and
 new line like so \r\n in content will be replaced with a br but
happens
 to
 work on say tables tags within the content aswell and need to ignore
this.

You'll have to make your own function that only matches data between
td and /td (or whatever you're looking for) and then applies nl2br()
only to that section...

For example:

preg_replace(!td(.*)/td!Ues,nl2br('td$1/td'),$var);

will match only what's between td and /td tags and apply nl2br() to
the data. It will leave everything else along. Adapt to your needs,
there may be better methods...

---John W. Holmes...

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



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



RE: [PHP] fopen

2003-03-16 Thread John W. Holmes
 i have this snippet of code, from what i can tell it works .. just
 wondering
 if i am doing it in a correct way, or if there is a better, or faster
way.
 thanks for any input.
 
 $fp = @fopen($_SERVER[DOCUMENT_ROOT]/images/$mapname.jpg,r);
 
 if ( $fp )
  {
  $mappic = img border=\0\ src='/images/mappics/$mapname.jpg'/a;
 }
 else
  {
  $mappic = img border=\0\ src='/images/noimage.gif';
 
  }
 @fclose ( $fp );
 
 echo $mappic;

How about using file_exists() to check, rather than trying to open it?

---John W. Holmes...

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



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



RE: [PHP] Really simple string search question

2003-03-16 Thread John W. Holmes
 Here's 3 examples:
 $var=www.google.com;
 $var=blah blah google blah;
 $var=google rules;
 
 Now I just want to see if $var contains the word 'google' in it -
which

www.php.net/strstr

---John W. Holmes...

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



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



RE: [PHP] regex problem

2003-03-16 Thread John W. Holmes
 suppose there's a string
 $string=I like my(hot) coffee with sugar and (milk)(PHP);
 
 I would like to get an output of all possible combinations of the
sentence
 with the words between brackets:
 eg.
 I like my hot coffee with sugar and
 I like my hot coffee with sugar and milk
 I like my hot coffee with sugar and milk php
 I like my coffee with sugar and
 I like my coffee with sugar and milk php
 etc.etc.
 
 The number of the words between brackets can differ and they can occur
 everywhere. The most important is that all combinations are returned
but
 the
 sentence (not between brackets) should be there.

Here's a solution. :) Hope it helps. You could adapt it to not use the
placeholders if each word in parenthesis is unique. 

?

$text = I like my (hot) coffee with sugar and (milk)(PHP);

//match words between parenthesis
preg_match_all(/\((.*)\)/U,$text,$matches);

//replace words with placeholder
//#x# where 'x' is incremented
//for each placeholder
$a=0;
$text2 = preg_replace(/\((.*)\)/Ue,'sprintf(#%d#,$a++)',$text);

//determine how many words were matched
//and what decimal number equals a binary 
//number of all ones and a length equal to
//the number of matches
$num_matches = count($matches[0]);
$dec = bindec(str_repeat(1,$num_matches));

//Original text
echo $text . hr;

for($x=0;$x=$dec;$x++)
{
$text3 = $text2;
$cpy = $x;
//loop equal to the number of matched words
for($y=0;$y$num_matches;$y++)
{
//if least significant bit is one then
//replace placeholder with word from $matches
//otherwise an empty string
$replace = ($cpy  1) ? $matches[1][$y] : '';
$text3 = str_replace(#$y#,$replace,$text3);
//shift bits in $cpy one to the right
$cpy = $cpy  1;
}
echo $text3 . br;
}

?

---John W. Holmes...

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



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



RE: [PHP] Access DB PHP

2003-03-16 Thread John W. Holmes
 I have a client who insists on using PHP and an Access database.  He
 describes a problem with the access databases becoming locked when a
user
 clicks 'stop' in their browser whilst downloading the page (and I have
to
 stop the IIS server to release it).  I have absolutely no experience
with
 PHP/Access connections, so I thought I'd ding it along and see if the
 elite
 PHP programmers of the world can pick up an error in his code.
 
 
  I connect like this:
  $conn = new COM ('ADODB.Connection');
  $conn-Open (Provider=Microsoft.Jet.OLEDB.4.0; Data
  Source='c:\\home\\westir\\data\\libcat.mdb');
  $sql = SELECT * FROM tbl_name ;
  $result = $conn-Execute($sql);
 
  // deal with the database generated information
 
  $result-Close()
  $conn-Close
 
 Is there a better way to do this?

Have a look at register_shutdown_function() to ensure that your database
connection is closed, whether the script ends or is stopped or whatever.

www.php.net/register_shutdown_function

---John W. Holmes...

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



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



RE: [PHP] RE: muliple form array values

2003-03-16 Thread John W. Holmes
 hi guys i have multiple media to update in an entry for instance
 
 input type=text name=fileedit[TITLE][123]
 
 where 123 is the fileid of the media in the database , how could i
 possibly
 loop through the post vars of fileedit and get each entry to update ?
 
 input type=text name=fileedit[TITLE][123]
 input type=text name=fileedit[TITLE][124]
 
 so therefore i could have something like this , loop through and
update id
 123
 and update 124 ?

foreach($_POST['fileedit']['title'] as $key=$value)
{
//$key will be 123, 124, etc...
//$value will be whatever was entered in text box
}

---John W. Holmes...

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



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



RE: [PHP] Using PHP to get a word count of a MSword doc

2003-03-16 Thread John W. Holmes
 I have a mySQL DB that stores word documents (as a BLOB). I am trying
to
 find a way of doing a word count on the documents using PHP. Can
anyone
 help??

Look at this:

http://www.winfield.demon.nl/index.html

to convert it to text and then count words. I just did a quick search to
find the above link; I have no idea about the program. There may be
better ones out there...

---John W. Holmes...

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



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



RE: [PHP] sorting results in PHP

2003-03-17 Thread John W. Holmes
 Sorting like that doesn't get it sorted by date.  Each row has a lot
of
 fields.  It
 actually needs to be sorted three times by three fields, Year, Month,
and
 Day.
 
 Because the query uses a GROUP BY statement, I can't sort it in the
query.

Why? I still don't see why you can't use an ORDER BY clause. 

ORDER BY date_column DESC

Which will order by year, month, then day. The order by is applied after
the GROUP BY, which will accomplish the same thing that you're trying to
do in PHP, only much faster.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
 
 André cupini wrote:
 
  Bill
  Try this:
 
  while ($crow=mysql_fetch_array($cresult)) {
$therow[]=$crow;
  }
  sort($therow);
 
  André Cupini
  Programador
  [EMAIL PROTECTED]
  NeoBiz - fábrica de internet
  http://www.neobiz.com.br
 
- Original Message -
From: bill
To: [EMAIL PROTECTED]
Sent: Monday, March 17, 2003 11:54 AM
Subject: [PHP] sorting results in PHP
 
I have a query that returns results including the fields Year,
Month,
 and Day
that I want to sort by date.
 
Because of the nature of the query (it includes a GROUP BY
statement),
 I cannot
sort it in the query.
 
How can I sort the results?
 
I tried to use asort() while designating the field but that didn't
 work.
 
while ($crow=mysql_fetch_array($cresult)) {
  $therow[]=$crow;
}
asort($therow[Year]);
reset($therow);
asort($therow[Month]);
reset($therow);
asort($therow[Day]);
reset($therow);
 
ideas?
 
kind regards,
 
bill
 
--
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




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



RE: [PHP] stripping slashes before insert behaving badly

2003-03-17 Thread John W. Holmes
 I am inserting data from a form into a mySQL database. I am using
 addslashes to escape things like ' in the data input (this is actually
 being done in PEAR (HTML_QuickForm).
 
 The weird thing is that the data gets written into the table like:
 what\'s your problem?
 
 WITH the slash. I am not sure what to modify to fix this so the
literal
 slash is not written.

You're running addslashes() twice, somehow. Magic_quotes_gpc is probably
on and you're escaping the data again. I would think PEAR would account
for that, but I guess not. 

---John W. Holmes...

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



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



RE: [PHP] Working with dates

2003-03-17 Thread John W. Holmes
 I have two variables, $StartDate and EndDate that contain values read
 from MySQL Date fields.  How can I determine if a value entered by the
 user is between the two dates?  I'm using PHP 4.0.6.

I think you can take MySQL timestamps directly into strtotime().

If($user  strtotime($StartDate)  $user  strtotime($EndDate))
{ do something; }

Many ways to do it...

---John Holmes...



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



Re: [PHP] What is the difference: include()

2003-03-17 Thread CPT John W. Holmes
 What is the difference as in... why one or the other?

 include('somefile.php');

 include(somefile.php);

 Just wondering...

No difference as far as include() goes.

Read the manual on strings to see how PHP treats strings in single and
double quotes differently.

---John Holmes...


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



Re: [PHP] What is the difference: include()

2003-03-17 Thread CPT John W. Holmes
  If you had a constant named somefile or php and you use the second
  syntax, the constant would be interpolated/evaluated to the value of the
  constant.
 
  Generally I always use single quoted strings unless there's some need
  for double-quoted strings (like if I want to embed a variable) so
  something like this can't happen.

 BTW, I'm talking out my butt here, but it might be true.  The advice is
 still sound, regardless.

Well, the first part is out your butt... :)

but the second part is sound advice.

---John Holmes...


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



Re: [PHP] copy ...

2003-03-17 Thread CPT John W. Holmes
What about

eregi(TI(.*)¶,$line,$m)

might want to use

eregi(TI([^¶]*)¶,$line,$m)

so it's not greedy.

---John Holmes...

- Original Message -
From: John Taylor-Johnston [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:31 PM
Subject: Re: [PHP] copy ...


 Perl, I will never touch again :) Find occurence of TI: and ¶ in the
string $textarea and extract it only. The problem is the user may have
entered \r\n. Therefore making \n out of the question to use as my end
marker.

 John

 Marek Kilimajer wrote:

  I have a strong feeling that POSIX regexs cannot do multiline, try using
  perl-compatible, or make a loop to read the textarea content line by
line
 
  John Taylor-Johnston wrote:
 
  I need to process the contents of textarea name=textarea
  
  textarea name=textareaSU: something ... blah blah¶
  TI: Title ... asasa asasas asas¶
  AU: author field ... asasasas¶
  /textarea
  
  I want to filter $textarea. I need to change my code below to grab
everything between TI: and ¶, but not including ¶ :
  
  I have this code.
  
  snip
  
  filter_strings(TI: , $textarea)
  
  function filter_strings($tofilter,$line){
  if(eregi('^'.$tofilter.' (.*)$',$line,$m)) {
  $filtered=$m[1];
  return $filtered;
   }
  }
  
  
  --
  John Taylor-Johnston
 
---
--
  Université de Sherbrooke:
  http://compcanlit.ca/
  
  
  
  

 --
 John Taylor-Johnston
 --
---
 If it's not open-source, it's Murphy's Law.

   ' ' '   Collège de Sherbrooke:
  ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
- Université de Sherbrooke:
   http://compcanlit.ca/
   819-569-2064



 --
 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] copy ...

2003-03-17 Thread CPT John W. Holmes
If you have TI: text ¶ TI: text2 ¶ as a string, my first example (if ereg
is greedy by nature) will match  text ¶ TI: text2  as a single match. It
will be greedy and try to match as much text as it can between any TI: and ¶
character. The second example will match text, but only if it's not (hence
the ^ within [ and ]) the ¶ character. So, with the second, you'll end up
with two matches  text  and  text2 .. which is what you want, right?

As for docs, just search anywhere for regular expressions and you can
learn the basics. The implementation of ereg_* vs. preg_* functions are a
little different, but once you learn the regular expression basics, you'll
be fine. The PHP docs for each set give some examples. phpbuilder.com also
has a good article on them.

---John Holmes...

- Original Message -
From: John Taylor-Johnston [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:54 PM
Subject: Re: [PHP] copy ...


 Captn John,
 What the difference? I recognise the code from my attempts at Perl. What's
the diff between ^ and *? Is there a doc I can read up more on?
 ;) Swabbie John

 Cpt John W. Holmes wrote:

  What about
 
  eregi(TI(.*)¶,$line,$m)
 
  might want to use
 
  eregi(TI([^¶]*)¶,$line,$m)
 
  so it's not greedy.
 
  ---John Holmes...
 
  - Original Message -
  From: John Taylor-Johnston [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Monday, March 17, 2003 2:31 PM
  Subject: Re: [PHP] copy ...
 
   Perl, I will never touch again :) Find occurence of TI: and ¶ in
the
  string $textarea and extract it only. The problem is the user may have
  entered \r\n. Therefore making \n out of the question to use as my end
  marker.
  
   John
  
   Marek Kilimajer wrote:
  
I have a strong feeling that POSIX regexs cannot do multiline, try
using
perl-compatible, or make a loop to read the textarea content line by
  line
   
John Taylor-Johnston wrote:
   
I need to process the contents of textarea name=textarea

textarea name=textareaSU: something ... blah blah¶
TI: Title ... asasa asasas asas¶
AU: author field ... asasasas¶
/textarea

I want to filter $textarea. I need to change my code below to grab
  everything between TI: and ¶, but not including ¶ :

I have this code.

snip

filter_strings(TI: , $textarea)

function filter_strings($tofilter,$line){
if(eregi('^'.$tofilter.' (.*)$',$line,$m)) {
$filtered=$m[1];
return $filtered;
 }
}
John Taylor-Johnston
Université de Sherbrooke:
http://compcanlit.ca/


 --
 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] How to manipulate a Access database(MDB file) with PHP.

2003-03-17 Thread CPT John W. Holmes
 How to manipulate a Access database(MDB file) with PHP.

How do I do it? I was expecting a link or something to help me. Or is that
your question... ?? Notice the question marks at the end of my questions?

;)

---John Holmes...

PS: This question was already asked today... search google or the archives,
please.


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



Re: [PHP] What's this _FILE junk?

2003-03-17 Thread CPT John W. Holmes
Is enable file uploads turned on in php.ini??

---John Holmes...

- Original Message -
From: Pete James [EMAIL PROTECTED]
To: Liam Gibbs [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, March 17, 2003 3:33 PM
Subject: Re: [PHP] What's this _FILE junk?


 Is your form enctype set?

 Like so:

 form name='foo' method='post' action='foo.php'
 enctype='multipart/form-data'


 Liam Gibbs wrote:
  This line:
  INPUT TYPE = FILE NAME = imprintpicture SIZE = 22
 
  when clicking submit, produces nothing. I print_r
$_FILES[imprintpicture], I try to echo $_FILES[imprintpicture][name]
or [tmp_name] and nothing comes up. Any reason?
 



 --
 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] documentation on pg_escape_string()

2003-03-17 Thread John W. Holmes
 Anyone know where to find documentation on this? Who knows what it
 escapes?

I always look in the manual when I'm looking for documentation, but
that's just me. Hell, call me crazy, but I'd probably look in the
chapter on the PG functions... but that's just me... and I have no idea
what I'm doing.

---John W. Holmes...

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



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



Re: [PHP] Ereg sass

2003-03-18 Thread CPT John W. Holmes
If you want to look for a dash (-), you always place it last in the
brackets, other wise the regex machine will be looking for a range. So just
move the - to the last character.

[A-Za-z0-9_.-]*

---John Holmes...

- Original Message -
From: Liam Gibbs [EMAIL PROTECTED]
To: php list [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:33 AM
Subject: [PHP] Ereg sass


I'm not sure why, but I can't include a period in my eregi statement:

[A-Za-z0-9_-.]*

For this, I get Warning: ereg() [function.ereg]: REG_ERANGE in
/home/website/public_html/Functions.inc on line 27

The same goes for [A-Za-z0-9_-\.]*

Anyone know why?


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



Re: [PHP] what's the best way to handle this?

2003-03-18 Thread CPT John W. Holmes
 When a user 'registers' with our site, I want to generate their personal
 webpage for them.  Currently, I have a webpage where the contents are
 generated from their personal info in the db and I have a drop down to
view
 client pages but it is just the same page but I pass in the clientid so it
 will display their data.  This is fine but I want the users to be able to
 tell others..Visit my home page at www.eddiessite.com/Johnny  or
something
 like that...I don't want them to have to say visit my page
 www.eddissite/client_pages?clientid=43  does that make sense?  Should I
just
 generate a folder for them with an index page that redirects then to the
 clientpage with their id?

If you really wanted to write the file and not use some fancy rewrite rule
or Apache trick, you could do this:

$fp = fopen(http://www.eddissite.com/client_pages.php?clientid=43;,'r');
while(!feof($fp))
{ $data = fread($fp,1); }
fclose($fp);

mkdir(/home/path/to/your/www/$client_name,0777);

$fp2 = fopen(/home/path/to/your/www/$client_name/index.html,'w');
fwrite($fp2,$data);
fclose($fp2);

Just make sure all of your paths for images and links are still correctly
created by client_pages.php

You could use output buffering for the first part, too...

---John Holmes...


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



Re: [PHP] Register_globals question

2003-03-18 Thread CPT John W. Holmes
 I found a class that allows you to have a multiple page listing, where
 it displays a certain number of items, and then you click on the next
 page to show the next results. I found that it needs to have
 register_globals turned on. I am learning, and would like to have
 someone look at the class to tell me where in this class
 register_globals is required. I have emailed the person that created
 the class, I am just trying to understand this.

 Mike

 Here is the class code:

 ?

 class pn_buttons{

/* Public Variables */
var $query_total_pages = 0;
var $limited_query;
var $next_button;
var $previous_button;

/* Functions */
function pn_buttons($sql, $step, $page=0){
$result = mysql_query( $sql );
$query_total_rows = mysql_num_rows( $result );

// if query return some rows
   if ( $query_total_rows0 ){

   if ( $query_total_rows%$step!=0 ){
  $total_pages = intval( $query_total_rows/$step)+1;
   }else{
  $total_pages = $query_total_rows/$step ;
   }

   $this-query_total_pages = $total_pages;

   // if page is set
   if ( empty($page) ) {
  $from = 0;
  $this-current_page= 1;
   }else{
  if ( $page = $this-query_total_pages ) {
   $from = $step * ( $page - 1 );
   $this-current_page= $page;
  }else{
   $from = 0;
   $this-current_page= 1;
  }
   }

   $this-limited_query = $sql .  LIMIT . $from ., .
 $step;
}

} // end  function

// create previous and next buttons
function make_buttons( $link, $link_params, $txt_next=next,
 $txt_previous=previous, $image= ){

if ( $this-query_total_pages1 ){

if ( ($this-current_page  $this-query_total_pages) 
 ($this-current_page1) ){
$next_page = $this-current_page+1;
$prev_page = $this-current_page-1;
$next_lnk = a href='.$link . $link_params .
 page=. $next_page .'$txt_next/a;
$prev_lnk = a href='.$link . $link_params .
 page=. $prev_page .'$txt_previous/a;
}else if( ($this-current_page 
 $this-query_total_pages)  ($this-current_page==1) ){
$next_page = $this-current_page+1;
$prev_page = ;
$next_lnk = a href='.$link . $link_params .
 page=. $next_page .'$txt_next/a;
$prev_lnk = ;
}else if( $this-current_page = $this-query_total_pages
 ){
$next_page = ;
$prev_page = $this-current_page-1;
$next_lnk = ;
$prev_lnk = a href='.$link . $link_params .
 page=. $prev_page .'$txt_previous/a;
}
$this-next_button = $next_lnk;
$this-previous_button = $prev_lnk;
}

} // end function

// display all pages
function count_all_pages( $link, $link_params ){
for ($i=1; $i=$this-query_total_pages; $i++){
if ($i==$this-current_page){
echo b[$i]/b;
}else{
echo a href='$link$link_paramspage=$i'[$i]/a;
}
}
}

 } // end Class

Since it's a class, register_global variables would not have any scope
within it. Since there are no 'global' calls in any of the methods, it
doesn't look like it's relying on any outside variables. Everything this
script acts upon is passed to it, so it does not rely on register globals.
How this class was implemented may rely on them, though.

---John Holmes...


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



Re: [PHP] Mysql Query Question

2003-03-18 Thread CPT John W. Holmes
$string = ' . implode(',',$group) . ';
$query = SELECT * FROM table WHERE groupname IN ($string);

---John Holmes...

- Original Message -
From: Van Andel, Robbert [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 3:51 PM
Subject: [PHP] Mysql Query Question


I am trying to query a database looking for results that match an array of
values I have set.

The variable array is call group and has about 10 elements.  Is there a way
that I can query the database using just $group instead of having to use the
following:
SELECT * FROM `table` WHERE groupname = '$group[1]' OR groupname='$group[2]'
OR groupname='$group[3].

I think I saw the answer once before but can't find it anywhere.

Robbert van Andel




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



RE: [PHP] I.P. range authentication

2003-03-18 Thread John W. Holmes
 $abytes = explode('.', $ip); // explode the IP string
 $ip = 0;
 foreach ($abytes as $byte) $ip = ($ip  8) + $byte;
 
 This will give you the valid numeric equivalent of the IP address.

Isn't that what ip2long() does?

Also, the man page on ip2long() has some good notes and code that may
help the OP. 

http://www.php.net/manual/en/function.ip2long.php

---John W. Holmes...

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



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



RE: [PHP] Posting Query Results to an HTML form

2003-03-18 Thread John W. Holmes
 I have a MySQL query that I am sending the results to text boxes in a
 form.
 In the event of a space in the string data, the string is being
truncated
 at
 the first space. Is there a PHP function that can prevent this string
data
 from being truncated in the form.

No, there's no PHP function, but there is an HTML trick that you can
use: putting quotes around your values!

input type=text name=name value=value

etc...

---John W. Holmes...

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




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



RE: [PHP] remove ' from string

2003-03-19 Thread John W. Holmes
 Any functions to remove'from a longstring?

Care to say why you need to do this? You may be doing a workaround
instead of a solution...

---John W. Holmes...

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



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



RE: [PHP] Need help with coding problem

2003-03-19 Thread John W. Holmes
 I have a subscription service and am trying to not allow the buyer to
 proceed purchasing another subscription if one of their subscriptions
is
 over 29 days past due in their payment.  I am trying to query each
invoice
 and checking to see if it is past due more than 29 days, if it is I
want a
 message to come up saying that it can not proceed because they account
is
 not current.  Can you look at the code below and let me know if you
see
 something wrong.  It is not working for me. Thanks.

There's a problem in your code below, but you could just use this query:

$query = SELECT * FROM $table_name WHERE buyerid='$buyerid' AND
paidinfull IS NULL AND duedate  CURDATE() - INTERVAL 29 DAY;

If that query returns any rows, the buyer is more than 29 days past due.

If you need to get the days, you can do something like this:

$query = SELECT *, TO_DAYS(CURDATE()) - TO_DAYS(duedate) AS difference
FROM $table_name WHERE buyerid = '$buyerid' AND paidinfull IS NULL;

Now, $row['difference'] will contain the number of days between now and
their last duedate. Check in PHP if it's over 29 and act accordingly.

Adapt to your needs...

 
 
 --START
CODE--
 
 $sql_1 =SELECT * FROM $table_name
   WHERE buyerid = \$buyerid\ AND paidinfull is NULL;
 $result_1 = @mysql_query($sql_, $connection) or die(Error # .
 mysql_errno() . :  . mysql_error());
 
 if(mysql_num_rows($result_1)  0){
  while($row = mysql_fetch_array($result_1)) {
 
  $duedate1 = $row['duedate'];
  $paiddate1 = $row['paiddate'];
  $paidinfull = $row['paidinfull'];
 
 $duedatestamp = strtotime($duedate1);  // due date unix
 timestamp
 $difference = time() - $duedatestamp; // diff in seconds
 $differencedays  = $difference / 86400;  // 60 x 60 x 24 hours
 floor
 rounds the days down
 $differencedays1 = floor($differencedays);
 
 $paiddatestamp = strtotime($paiddate1);// paid date unix
timestamp
 $diffdays = floor(((paiddatestamp - duedatestamp) / 86400));

You're missing some dollar signs on your variables here...

 
 
 if (!$paiddate1)
 {
   $daysout = $differencedays1;
 }
 else
 {
   $daysout = $diffdays;
 }
 
 if ($daysout  29)
 {
 echo You cannot add this product as your account is 30 days past
due;
 exit;
 }

---John W. Holmes...

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



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



RE: [PHP] LIsting all the Members who have not loged in for 60 days ...

2003-03-19 Thread John W. Holmes
 $lastDate is a unix time stamp in mySql ... how can i list ONLY the
users
 who have not logged in for 60days?

SELECT name FROM table WHERE FROM_UNIXTIME(lastDate)  CURDATE() -
INTERVAL 60 DAY

---John W. Holmes...

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



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



Re: [PHP] Posting Query Results to an HTML form

2003-03-19 Thread CPT John W. Holmes
 No, there's no PHP function, but there is an HTML trick that you can
 use: putting quotes around your values!
 
 input type=text name=name value=value
 
 That's not a trick, that's actually required with HTML 4 and up. And
 XML...

Umm.. yeah, got that. I was being sarcastic. ;)

---John Holmes...

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



Re: [PHP] PHP and IIS 5.0

2003-03-19 Thread CPT John W. Holmes
 I am putting together a website for a customer who insists on using IIS
 running on Windows XP and I'm running into some problems. It appears that
no
 matter what PHP script I run, I'm getting tons of errors saying this
 variable or that variable is undefined. I have global variables turned on
in
 the php.ini file - so I'm not sure what would be causing the problem
(other
 than it is a Microsoft product). The same scripts work perfectly on my
Linux
 box running Apache.

Read all about it here...

http://www.php.net/manual/en/ref.errorfunc.php

Either fix your code or adjust the error_reporting level.

Actually, it could be a register_globals problem also. They are off by
default, so you may need to re-write your code or turn them on in php.ini.

---John Holmes...


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



RE: [PHP] PHP and IIS - More info

2003-03-19 Thread John W. Holmes
 These are some of the errors I am getting
 
 Notice: Undefined index: login in
 C:\Inetpub\wwwroot\..\login\checklogin.php on line 74
 
 and 75, and other similar errors.
 
 Line 74 is: $login = $HTTP_SESSION_VARS['login'];
 Line 75 is: $password = $HTTP_SESSION_VARS['password'];
 
 Another one is: echo $HTTP_ENV_VARS[QUERY_STRING];

There is no 'login' or 'password' index in the $HTTP_SESSION_VARS array.
How are you registering these variables? Try using the new method with
$_SERVER. 

---John W. Holmes...

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



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



RE: [PHP] MySQL Date

2003-03-19 Thread John W. Holmes
 I have a date stored in a table in my MySQL Database using a DATE type
for
 the column.
 
 How can i compare the date in the table to today

... WHERE your_date = CURDATE() ...

 e.g.
 
 $today = mysql_result($result, $i, Booking_Date);
 
 if($today = *HELP*){

or...

if($today == date('Y-m-d'))

(notice the second equals sign!)

---John W. Holmes...

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



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



RE: [PHP] Anybody have any thoughts on Smarty?

2003-03-19 Thread John W. Holmes
 Was reading this and it sounds really cool. I do work as a consultant
 to designers and thought this may be a good way to improve work flow?
I
 have read mixed thoughts on this, but was wondering what this list
 thought? Anyone using it? Real world?

Once you get used to the syntax, it is great. I think it makes
maintaining your site a lot easier (any templating engine could do that,
though). The speed is very quick. It's beat out every other templating
system I've seen plus it has a huge set of features. 

The only online program I have running it is a Survey System demo at
http://sepodati.realxl.net (admin password is 'password').

I've never used it in a mixed developer/designer environment. I don't
know how effective it is at that. 

---John W. Holmes...

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



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



Re: [PHP] PHP and IIS - More info

2003-03-19 Thread CPT John W. Holmes
 Further note that it is not just this script, but many PHP scripts that I
 run on IIS - they all work perfectly on Apache (on Windows and Linux)..

HOW DOES IT NOT WORK!?

---John Holmes...

 - Original Message -
 From: John W. Holmes [EMAIL PROTECTED]
 To: 'Beauford.2002' [EMAIL PROTECTED]; 'PHP General'
 [EMAIL PROTECTED]
 Sent: Wednesday, March 19, 2003 12:21 PM
 Subject: RE: [PHP] PHP and IIS - More info


   These are some of the errors I am getting
  
   Notice: Undefined index: login in
   C:\Inetpub\wwwroot\..\login\checklogin.php on line 74
  
   and 75, and other similar errors.
  
   Line 74 is: $login = $HTTP_SESSION_VARS['login'];
   Line 75 is: $password = $HTTP_SESSION_VARS['password'];
  
   Another one is: echo $HTTP_ENV_VARS[QUERY_STRING];
 
  There is no 'login' or 'password' index in the $HTTP_SESSION_VARS array.
  How are you registering these variables? Try using the new method with
  $_SERVER.
 
  ---John W. Holmes...
 
  PHP Architect - A monthly magazine for PHP Professionals. Get your copy
  today. http://www.phparch.com/
 
 
 
  --
  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] $array_nam[$variable][0]

2003-03-19 Thread CPT John W. Holmes
 $var = $array_name[$var2][0];

 where $var2 is an integer. I've got this array from a database and I
 want to use a variable in the array... what's the exact syntax of this?

That is the correct syntax. Use print_r() on $array_name to see what it
contains.

---John Holmes...


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



RE: [PHP] convert VARCHAR 10 to DATETIME

2003-03-19 Thread John W. Holmes
 i am exporting a database out of filemakerpro 5 as a comma delimited
file,
 and
 importing the data into a mysql database
 
 most of the information transfer over ok,  the one big problem i have
is
 filemaker's date/time format.
 
 in the filemaker pro database, it looks like the timestamp is stored
in
 the
 format: M/DD/
 
 mysql will not let me create a DATETIME field with X/XX/ as the
 default
 value.  it automatically changes the default value to '-00-00'.
 
 i will migrate the filemaker pro data, using VARCHAR 10 to store the
 timestamp
 information, but there needs to be a way to go through every entry in
this
 column, convert a string such as
 'M/DD/' to something compatible with mysql's DATETIME format.
 
 the reason i'd like to convert the filemaker-generated 'M/DD/'
 timestamp string, which would be stored as
 VARCHAR in the db - to something like '-00-00' - is that i'd like
to
 convert the the data type of this field
 from varchar 10 to DATETIME with a default value of -00-00, so
that
 any sql queries searching through the
 database by date will be compatible, as will any future entries that
get
 tacked onto this field in the database
 after the migration from filemaker, which will be in DATETIME format

If you want to do it strictly in SQL, then use MySQL's String functions
to pull apart the M/DD/ date and format it into a valid MySQL Date. 

If you can run the whole thing through PHP, you may be able to use
strtotime().

For the SQL solution, create a new column in your table that is a Date
type. We'll call it f_date for this example. The following query will
break apart the M/DD/ and format it as /MM/DD, which is a format
MySQL will accept.

UPDATE table SET f_date =  CONCAT(RIGHT(old_date,4), '/',
SUBSTRING_INDEX(old_date,'/',2));

Hope that helps.

---John W. Holmes...

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



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



RE: [PHP] strip single quotes

2003-03-19 Thread John W. Holmes
 I'm trying to query the database using a string pulled out of the
database
 and compare and get the id.  I can do it to a certain point and what
kills
 my query is single quotes.  I CANNOT figure out how to escape it.
 
 I DID THIS:
 $address2 = str_replace(', , $address);
 
 that worked on some, but not all.
 $address = stripslashes($store['address']);
 $address = str_replace(', , $address);
 $address = htmlspecialchars($address);
 $address = addslashes($address);
 
 anyone
 
 Some errors I have gotten back
 You have an error in your SQL syntax near 's Linen  Home'' at line
1
 and
 You have an error in your SQL syntax near 's 800 number.'' at line 1

You need to use addslashes() on any string you insert into your query.

---John W. Holmes...

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



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



RE: [PHP] Cleaning user data

2003-03-19 Thread John W. Holmes
 I'd like to canvas opinions about what's needed to clean user input.
I'm
 using an HTML form where users enter simple things like name and phone
 number, but also a couple of small text areas for address and a
message
 (up
 to 50 words or so).
 
 How would people recommend cleaning this data when it's received (via
 $_POST) in the next page? Some fields (like email) I can check against
a
 template using ereg(), but the text areas pose more of a problem. I
assume
 running strip_tags() might be a wise precaution, and maybe also
 htmlentities(). Anything else?

For a textarea, apply htmlentities() before you save it in the database.
This will let you safely display it on a web page and re-display it in
another textarea for further editing.

If you need to use the data in an email or file, then only apply
htmlentities() when you display the data on a web page, not when you
save it in the database.

Bottom line, as you hopefully know, VALIDATE EVERYTHING!

---John W. Holmes...

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



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



RE: [PHP] Dynamic variables (with method=post)

2003-03-19 Thread John W. Holmes
 How do i receive dynamic variables with POST ?
 Please, see the code fragment.
 
 $ped_item = mysql_result($result, $j, 0);
 
 form name=form_$ped_item method=post action=pedido.php
 input type=hidden name=upd_item value='$ped_item'
 input type=text size=7 maxlength=7 value=$ped_qtde
 name=quantidade$ped_item
 /form
 
 
 upd_item was usually received.
 How do i receive quantidade$ped_item  ?
 
 I have tried:
 
 $p1 = $_POST['upd_item'];// this is OK !
 $p2 = $_POST['quantidade$upd_item'];// this doesn't work !

I guess it would be 

$p2 = $_POST['quantidade'.$p1];

if I'm reading correctly...

---John W. Holmes...

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



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



RE: [PHP] Date Conversion

2003-03-19 Thread John W. Holmes
 when retrieving a date from MySQL in n/MM/DD, how can I present
this
 to
 the user of a site in readable format i.e. 19th March 2003?

SELECT DATE_FORMAT(column,' ... ') AS f_date FROM table WHERE ...

Look up DATE_FORMAT in the MySQL manual, Chapter 6. It works almost the
same as the PHP date() function. The ' ... ' would be the pattern to
create '19th March 2003'

---John W. Holmes...

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



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



RE: [PHP] Cleaning user data

2003-03-19 Thread John W. Holmes
 And yes, definitely striptags(), and follow the advice on the rest of
the
 thread.

I disagree. I think stripping HTML from my text is a horrible thing. If
I want to put a b in my text, then use htmlentities() and show me a
b when I look at it. Obviously you don't want to evaluate HTML, but
the end result should be that I should see exactly what I typed into the
text box. 

If you need to allow formatted text, then use something like BBcode
where you can specify exactly what is allowed. 

---John W. Holmes...

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



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



Re: [PHP] Cleaning user data

2003-03-20 Thread CPT John W. Holmes
 --- John W. Holmes [EMAIL PROTECTED] wrote:
  I disagree. I think stripping HTML from my text is a horrible thing. If
  I want to put a b in my text, then use htmlentities() and show me a
  b when I look at it. Obviously you don't want to evaluate HTML, but
  the end result should be that I should see exactly what I typed into the
  text box.

The real problem I have with strip_tags is that if I want to type smile or
grin, it's going to be stripped out and now I have to go back and edit my
code and change it to something else... If you just use htmlentities(), the
user is none the wiser.

  If you need to allow formatted text, then use something like BBcode
  where you can specify exactly what is allowed.

 Maybe there is something I'm missing, but I have always hated these
alternative
 markup languages like BBcode that seem to offer no benefit over HTML. If
you
 want to allow the b tag to be evaluated, you can do something like this
after
 you use htmlentities():

 $blah = str_replace('lt;bgt;', 'b', $blah);
 $blah = str_replace('lt;/bgt;', '/b', $blah);

 Of course, if people want the b to appear exactly as they type it, they
would
 either have to use lt;bgt;, or you would have to let them choose an
option as
 to whether they want to use HTML (much like slash code does).

That would work, too, I guess. If the user actually typed in lt; it would
be encoded as amplt; and not match something similar to a replacement like
you've shown.

You don't want to do matching like you've shown, though. If I put a b on
my page with no /b, then it's going to make everything on the entire page
following my post bold. When cleaning the data, you want to make sure you
match a pattern that includes both the start and end tag. You can use
regular expressions or go through character by character.

---John Holmes...


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



RE: [PHP] Cleaning user data

2003-03-20 Thread John W. Holmes
 I still fail to see how BB code helps in any way, since you have to
make
 these
 same considerations. But, like I said, maybe I'm missing something.
:-)

I agree pretty much. The only way it helps is that it's easier for
people to pick up, however slightly. Instead of explaining to people to
use a href, you tell them to just use [url]. It's slightly easier, but
doesn't offer any additional features...

---John W. Holmes...

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



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



RE: [PHP] php, mysql, and method question

2003-03-20 Thread John W. Holmes
 i have a table that contains articles. i have another table which
 contains  the order 1 - 9 that i would like to display them in.
 
 this part is done, and is not a problem. here is where I am not sure
 how to proceed.
 
 1. tbl_display_order - can only have 9 records in it (or do i just
 ignore anything beyond 9?)
 2. when a new article is added to tbl_display_order - it needs to get
 the field that contains it's order set to 1 so it shows up first when
I
 display the articles, and all the other articles need to have their
 order number incremented.
 
 Maybe there is a better way to do this? Just not sure. Maybe not with
a
 database at all?

Can't you just add a TIMESTAMP column, ORDER BY that DESCending, and
LIMIT to 9 results??

---John W. Holmes...

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



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



Re: [PHP] Built in source encode function..

2003-03-21 Thread CPT John W. Holmes
There are programs out there that do this for you. Buy/use them if you feel
you need to. I don't.

---John Holmes...

- Original Message -
From: Awlad Hussain [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 21, 2003 8:58 AM
Subject: [PHP] Built in source encode function..


I think PHP should have a built in ability tp encode source code, so if
someone wish to protect their source code they should be able to.
I hear lot of people worried about other people nicking their codes.

But i also think this could kill the idea of open source.

What do you guys think?
-awlad


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



Re: [PHP] detecting end of line - php 4.1.2

2003-03-21 Thread CPT John W. Holmes
 I am trying to get php 4.1.2 to read a Mac file (exported from
 FileMaker Pro) and split it into different lines  using the following
 but php does not recognize the end of line.  For some tech reason I
 cannot upgrade php now but I need to be able to read my Mac files
 now.  What is the easiest : edit the Mac file and replace the end of
 line or modify the script below?  In any case I need help to know
 exactly what to do.

   // first read the entire file
$file = file($Export_ImageBank);

I know Macs use \r as the end of line. file() may only look for \n.

You can read the entire file into a variable and then use explode() on \r to
achieve the same results as file().

---John Holmes...


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



RE: [PHP] who is on the page?

2003-03-23 Thread John W. Holmes
 I've been looking for a script to determine who is on my page (people
 have to log in). So far, I've been using a script that updates the
time
 in the database continuously as long as the person is on the page.
That
 way, the script could determine whether the user is still online or
not.
 However, this script has way too many queries and uses too much server
 resources. Is there anything else? I'm wondering if the
 connection_status() function would help in any way...

Connection_status() is for something else.

Remember how HTTP works. The server receives a request, it sends a file,
you receive it, and that's it. There is no more communication. There is
_no_ way to tell how many people are on your page, plain and simple.

What you can do, however, is something like you're doing now. With each
_request_ to a page (not every second, or however you're doing it now),
update a time in a database. To see how many people are on your site
you can select a count of how many users have times that are less than X
minutes old. You have to assume that if they requested a page X minutes
ago, they are more than likely still on your page. 

Since this isn't rocket science, this assumption will be adequate for
your needs. 

---John W. Holmes...

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



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



RE: [PHP] numbers problem

2003-03-23 Thread John W. Holmes
 Hi, I'm using a mysql connection to dinamically fill a table with
 descriptions, prices, and so on...
 
 But when the script takes the price of a Plasma Monitor, that costs
 8025.00
 $, it outputs only 8,00.
 I recall it by typing :
 
 echo $row_Recordset1['Prezzo']
 
 And please note that I've seen that it happens only when
 $row_Recordset1['Prezzo']  1000

Check what the type is on your column. Since you show it has a comma in
it, I'll assume it's a varchar. Since you can't store a number over
1000, I'll also guess that it's a varchar(3) column. 

If you're typing in 8025.00 and it's getting stored as 8,00 then how are
you processing it before storing it? Something has to add in the comma,
right?

Prices should be stored as a DECIMAL column type. You should validate
what the user puts in and _make_ it into a decimal. Can you always
assume that a period is the decimal separator? Some countries use a
comma for a decimal separator and the period as the thousands separator.
You must validate everything from the user and format it to match what
you need and reject everything else. Plain and simple. :)

---John W. Holmes...

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



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



RE: [PHP] htaccess writable by httpd

2003-03-23 Thread John W. Holmes
 is this a dangerous feature ?

Depends what kind of server you're on to start with. If you have a
dedicated server, then it's not as big of a deal. If you're on a shared
server, then anyone else on that server can write your .htaccess files
for you (generally).

---John W. Holmes...

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



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



RE: [PHP] Re[2]: [PHP-DB] mysql timestamps

2003-03-24 Thread John W. Holmes
Yeah, sorry, it's the UNIX_TIMESTAMP() function you want.
FROM_UNIXTIME() will convert a Unix timestamp to a MySQL timestamp,
also. 

---John W. Holmes...

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

 -Original Message-
 From: Don Read [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 24, 2003 4:30 AM
 To: L0vCh1Y
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP] Re[2]: [PHP-DB] mysql timestamps
 
 
 On 24-Mar-2003 L0vCh1Y wrote:
 
 
  JWH SELECT TO_UNIXTIME(your_column) FROM table ...
 
 
  It doesn't work... MySQL returns error - what could be trouble in? I
  also tried
 
  SELECT TO_UNIXTIME(foo) AS bar FROM baz
 
  But it's look like it doesn't know such function :\.
 
  I tried table in next types: TIMESTAMP,DATETIME.
 
 
 
 There's no such function in MySQL but there is UNIX_TIMESTAMP():
 
 localhost.dread$ grep TO_UNIXTIME $MANUAL
 localhost.dread$ grep UNIX_TIMESTAMP $MANUAL
  `RAND()'. You can, for example, use `UNIX_TIMESTAMP()' for the
  `UNIX_TIMESTAMP()'.  Other functions operate on the formatted
 `UNIX_TIMESTAMP()'
 `UNIX_TIMESTAMP(date)'
  `UNIX_TIMESTAMP()' is called with a `date' argument, it returns
 
 snip
 
 --
 Don Read   [EMAIL PROTECTED]
 -- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
 
 --
 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] Hidden new line markers?

2003-03-24 Thread CPT John W. Holmes
nl2br() doesn't remove the newlines, it simply adds in the br / in before
them.

The str_replace should work, how are you trying to use it?

---John Holmes...

- Original Message -
From: Jeff Lewis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 24, 2003 2:56 PM
Subject: [PHP] Hidden new line markers?


I am using a SELECT statement to grab all items from a database table and
while looping through the results I am connecting the fields with tabs and
adding a new line at the end of the row to create a tab delimited file.

On one field I do a nl2br in order to preserve the spacing in the field.
However, when I import it into Excel, it keeps treating the br / as a nl.
Am I missing something? I tried removing \r and \n with str_replace and I
have used trim but it still doesn't work how I'm expecting it to.

Does anyone have any ideas on this?

Jeff


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



Re: [PHP] looking for advice on PHP server

2003-03-24 Thread CPT John W. Holmes
 My server has cURL built into its php module, but it doesn't support
 SSL, and thus doesn't support requests to secure servers, i.e. https. It
 was an effort in itself to get them incorporate cURL, and I was just
 wondering if I should move immediately to a new host - if this were just
 ridiculous.  I needed cURL badly in order to process credit card
 transactions, now I don't even have the option.  I supposed I could use
 the PHP wrapper with the API, but it looks difficult and the processing
 company (Linkpoint) really doesn't seem to have their stuff together as
 far as support goes, or anything for that matter.  What should I do?  If
 I should move, could anyone suggest a decent host that could handle the
 aforementioned?

You could make an exec() call to Lynx (and maybe wget) and process the
results. Both should be installed on your system.

---John Holmes...


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



Re: [PHP] Hidden new line markers?

2003-03-24 Thread CPT John W. Holmes
 The data is being entered into a textarea and is being stored as it is
 entered but with an addslashes right before insertion.

 On the extract I am doing the following:

 $row[description] = stripslashes($row[description]);

You don't have to use stripslashes() on data coming out of a database unless
you have magic_quotes_runtime enabled. If you find that you do need to call
it, then you're running addslashes() twice before the data is inserted.

 $row[description] = nl2br($row[description]);
 $row[description] = trim($row[description]);

 I was trying str_replace as follows but that wasn't working:

 $row[description] = str_replace(\n, , $row[description]);

This will get rid of the \n, but leave the \r there. On windows, you'll
still see a newline even with just the \r remaining. If you know everything
is coming from Windows, replace \r\n with an empty string. Unix uses just a
plain \n and Macs use just \r, while Windows uses \r\n. Adjust your
str_replace accordingly if you need to account for data from all three
possible OS.

---John Holmes...


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



Re: [PHP] mail() Bcc:

2003-03-24 Thread CPT John W. Holmes
 From: Oden Odenius [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, March 24, 2003 3:44 PM
 Subject: [PHP] mail() Bcc:

 How can send bcc: with mail()?

 - Original Message -
 From: Bryan Brannigan [EMAIL PROTECTED]
 To: Oden Odenius [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Monday, March 24, 2003 3:56 PM
 Subject: Re: [PHP] mail() Bcc:
 $mail-BCC( [EMAIL PROTECTED] );

Honestly, how do you expect that to help anyone? Do you assume the entire
world is using whatever class you are using? They are not.

At least tell them what class you're using as a recommendation, otherwise
provide an answer that'll work with a regular PHP function.

Thank you.

---John Holmes...


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



Re: [PHP] mail() Bcc:

2003-03-24 Thread CPT John W. Holmes
  How can send bcc: with mail()?
 
 From, CC and BCC are headers to be set in the fourth parameter of the
mail()
 function.  Headers must be spearated by end-of-line characters.

 $headers = From: [EMAIL PROTECTED]
 CC: [EMAIL PROTECTED]
 BCC: [EMAIL PROTECTED];

 mail($to, $subject, $body, $headers);

 There are many other headers that you may find useful that are just as
easy
 to add through the mail() function.

I don't think that'll work. The concept is right, but the way you are typing
it, you're actually adding in two line breaks between each header. That's
going to cause your CC: and BCC: header to show up in the body of the
message because anything after two consecutive line breaks is considered the
body.

You can do it like this:

$headers = From: [EMAIL PROTECTED]: [EMAIL PROTECTED]:
[EMAIL PROTECTED];

or

$headers = From: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
BCC: [EMAIL PROTECTED];

Also, you may want to check the regs on the capitalization of the headers.
If I'm wrong, someone please let me know, but some servers may only accept
Bcc: instead of bcc: or BCC:, etc... ?? Does anyone know if that matters? If
it does, is it only dependant upon the sending SMTP server and not any
servers the message is sent through or the receiving server?

Thanks.

---John Holmes...


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



Re: [PHP] session id

2003-03-25 Thread CPT John W. Holmes
  can somebody tell me why I am getting this:
  Warning: session_start() [function.session-start]: Cannot send session
  cookie - headers already sent by (output started at
  c:\inetpub\wwwroot\search.php:8) in c:\inetpub\wwwroot\search.php on
line 21
 
  Warning: session_start() [function.session-start]: Cannot send session
cache
  limiter - headers already sent (output started at
  c:\inetpub\wwwroot\search.php:8) in c:\inetpub\wwwroot\search.php on
line 21
 
 
  when I use this code:
 
  session_start();
  if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
  }
 
 
  PHP is version 4.3.1
 
  thanx
 
 

 You cannot send any output until the session is set

 This includes html before the ?php tag or any print's or echo's

More specifically, whatever you have in search.php on line 8 is considered
output and is ending the headers. Move session_start() before any output.

---John Holmes...


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



Re: [PHP] Persistent connections with mysql_pconnect()

2003-03-25 Thread CPT John W. Holmes
 no, not at all... but there is a time and a place, and i don't think you
 should use pconnect just because you don't want to an include at the top
of
 every page.

You still have to call pconnect() on every page if you use it. It doesn't
leave it open for other requests, it leaves it open within the web server
program. pconnect() is only useful on certain OS using certain web servers.
Read the manual page on mysql_pconnect() for more information.

---John Holmes...

 - Original Message -
 From: John Hicks [EMAIL PROTECTED]
 To: php [EMAIL PROTECTED]
 Sent: Tuesday, March 25, 2003 5:11 PM
 Subject: [PHP] Persistent connections with mysql_pconnect()


  On Tuesday 25 March 2003 09:02 am, skate [EMAIL PROTECTED] wrote:
   leaving the connection open creates security questions,
   and also leaves resources open, what if a user closes his
   browser window, how do you know to close the connection?
 
  So are you saying that persistent connections  [ i.e. mysql_pconnect() ]
  should never be used?
 
   if you really want to make it simple, you can edit your
   php.ini to have the username and password as default in
   there, but again, this can be a security risk.
  
   i'm afraid the best way is to include connection code on
   every page...
 
  --
  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



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



Re: [PHP] Checking for existence of file

2003-03-25 Thread CPT John W. Holmes
 What I'd like to do is check the directory 'images' first to see if
 'mast_$img_pick.jpg' exists and if it doesn't, call a different image such
 as 'mast_default.jpg'. I'm sure this isn't hard, I'm just not sure how to
 start.

Maybe you can start with file_exists() or is_file() and somehow work from
there???

---John Holmes...


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



Re: [PHP] formatting textarea input on output

2003-03-25 Thread CPT John W. Holmes
 i have a textarea in a form which gets inserted into a table in my
 database (mySQL). When displaying this text back to the screen, how do
 i retain the line breaks etc. that were in the original input?

I bet if you searched for textarea and line breaks you'd of found the
nl2br() function... but I'm not a betting man... unless there's money
involved... and beer.

---John Holmes...


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



Re: [PHP] formatting textarea input on output

2003-03-25 Thread CPT John W. Holmes
 /**
 * converts line break and spaces to page break
 *
 * @access public
 */
 
 function nlbr($string) {
 return preg_replace(/(\r\n|\n|\r)/, br\n, $string);
 }

ummm www.php.net/nl2br() ??

Start a new thread for your question, don't hijack someone else's thread.

---John Holmes...

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



RE: [PHP] Disabling output control when using ob_start

2003-03-25 Thread John W. Holmes
 Is there a way to disable the call back function set by ob_start?
 I tried:
 ob_end_flush();
 ob_end_clean();
 ob_implicit_flush(true);
 
 Nothing seams to work. I can't detect the call back function and I
can't
 prevent it either. The call back function is called no matter what!
 
 Michael
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

What if you use something like:

Ob_start(dummy);

Function dummy($string) { return $string; }

Which basically does nothing...

---John W. Holmes...

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



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



RE: [PHP] variables??

2003-03-25 Thread John W. Holmes
 It is considered more secure to declare the variable explicitly.
 
 $var = $_GET[var];

Ummm... that's the same result as having register_globals on
(basically). You're not helping anything and it's certainly not any more
secure.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
 
   I'm having a problem with form data being recognized by a php
script.
   If I send information with a GET the variable data appears in
 $GET[var]
   but not $var.  
 
 
 
 --
 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] Default setting garbage

2003-03-25 Thread John W. Holmes
 Why is it that when I send call this function:
 function GetNextDate($whichfriday, $month = , $frequency = 1,
$basedate
 = )
 
 with this line:
 GetNextDate(4, 2003-03, 5);
 
 that $frequency ends up ? Whether I set it myself when I call the
 function, or I leave it blank and let the function set it itself, it
ends
 up with nothing in it. empty() returns 1, while isset() returns
nothing on
 this.

I'll guess that you're trying to access $frequency outside of the
function, after you've called it, right? If so, read up on variable
scope in the manual.

---John W. Holmes...

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



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



RE: [PHP] Changing variables in a text file

2003-03-25 Thread John W. Holmes
 I have a text file with a series of project variables.
 
 For example
 $var1=;
 $var2=;
 $template=blue;
 $anothervar=foo;
 
 Let say I need to change $template=blue; to $template=red;. How
can I
 do
 that keeping the rest of the file intact?

You have to write the whole file over. So read the entire file into a
string. If you know you're looking to match $template, then you can use
a preg_replace() call.

$new_value = red;
preg_replace('/\$template=[^];/','$template='.$new_value.';',$text)
;

or something similar. Adapt to your needs. 

---John W. Holmes...

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



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



RE: [PHP] Benchmarking

2003-03-25 Thread John W. Holmes
 I've been making a web ap PHP based, but I fear the number of arrays
it
 has
 is too big. Is there any way to benchmark a script, or are there any
 recomendations or standards about how much time execution takes and
how
 many
 resources it takes?

The benchmarking is just a matter of subtracting the time at the end of
your script from the time at the beginning.

Check your web server logs for the resources question. I don't know of
any PHP way to do it. 

---John W. Holmes...

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



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



RE: [PHP] Difference between months

2003-03-25 Thread John W. Holmes
 How do I subtract the difference of months between two dates?
 
 For instance, if one date is 2003-12 and the other is 2002-08, I need
to
 know that there are 16 months between them. If one date is 2003-04 and
the
 other is 2003-01, I need to know that there are 3 months between them.
How
 can I do this?

One way...

$date1 = 2003-12;
$date2 = 2002-08;

$d1 = explode('-',$date1);
$d2 = explode('-',$date2);

$diff = ($d1[0]*12+$d1[1]) - ($d2[0]*12+$d2[1]);

---John W. Holmes...

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



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



RE: [PHP] variables??

2003-03-25 Thread John W. Holmes
Okay, true. But they key here is the act accordingly, meaning you
sanitize and validate the variable before using it anywhere. 

Sometimes the way it's represented is that just using $_GET['var'] is
going to make things more secure than using $var, which is not the case
unless you know what exactly $_GET['var'] contains and how you're using
it. 

---John W. Holmes...

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

-Original Message-
From: Leif K-Brooks [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 25, 2003 8:15 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] variables??

No, it is more secure.  The problem with register_globals is that ALL
variables become global - not just the ones you want to be.  Example:

if(something) $authorized = true;
if($authorized){
...do something requiring security...
}

A hacker could easily go to script.php?authorized=1, and gain access.
 If you only allow one variable in that ($_GET['var']), you will know
that the variable is from an outside source, and can act accordingly.

John W. Holmes wrote:

It is considered more secure to declare the variable explicitly.

$var = $_GET[var];


Ummm... that's the same result as having register_globals on
(basically). You're not helping anything and it's certainly not any more
secure.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
 
  
I'm having a problem with form data being recognized by a php

script.
  
If I send information with a GET the variable data appears in

$GET[var]

but not $var.  



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





  


-- 
The above message is encrypted with double rot13 encoding.  Any
unauthorized attempt to decrypt it will be prosecuted to the full extent
of the law.




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



Re: [PHP] help with preg_replace please

2003-03-26 Thread CPT John W. Holmes
 I get the following error:

 Parse error: parse error, expecting `T_VARIABLE' or `'$'' in
 /usr/local/apache/htdocs/lib/lib_string.inc on line 218

 Using this code:
 $str =
 preg_replace(!([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/=])!ei, a
 href=\{$1}://{$2}{$3}\{$2}{$3}/a, $str);

Since you're using the 'e' modifier, the replacement string needs to be
valid PHP code. So, it should start with a variable or a function. A
replacement such as:

'print(a href={$1} .. )'

should work.

I didn't get a chance to answer you original question. I couldn't even get
that regular expression to match links in any tests that I did, but if it's
working for you, that's good. Couldn't you modify the expression to look for
0-60 characters that are not a space, followed by any amount of characters
that are not a space, and only actually match the first 0-60 to use in your
replacement string? Something like:

([^[:space:]]{0,60})[^[:space:]]*

Which will match up to 60 characters in $2 for example, and also allow form
more characters than that, but just not match them. This is assuming what
everyone else said is right and you fix the entire regex to match the preg
syntax...

---John Holmes...


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



Re: [PHP] Default setting garbage

2003-03-26 Thread CPT John W. Holmes
  I'll guess that you're trying to access $frequency outside of the
  function, after you've called it, right? If so, read up on variable
  scope in the manual.

 No, I'm trying to access it inside the function. This is what I have (or
an
 example, since I don't have it right in front of me right now):

 function func($a = 1, $b = 2) {
 print([$a]);
 }

 From the above example, I get [] as output.

Well, my guess was wrong. I guess it has to happen eventually. :)

So how are you calling the function? If you have:

function func($a=1,$b=2)
{ print([$a]); }
func();

all by itself, does it work? No reason it shouldn't. Maybe you think you're
passing a value to func(), but you're really not. In order to get what you
say, you _have_ to be passing an empty string as the first parameter.

Wait... you realize that if you call

func('');

That $a in the function will be an empty string, right? $b would get the
default value of 2. They would only get that default value if you do not
include that parameter in the function call at all.

---John Holmes...


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



Re: [PHP] Checkbox

2003-03-26 Thread CPT John W. Holmes
 is it possible to have a checkbox that if it is specified to be checked
 when the page is being formulated then it cannot be unchecked?

No. No... No.

If you already know you don't want it to be unchecked, then don't show a
checkbox. That's why we have PHP, so you can create your page DYNAMICALLY
and not show bits and pieces when you don't need to.

There are plenty of JavaScript or other workarounds you can do, but you
still need to verify _everything_ on the server side and don't accept any
changed value.

---John Holmes...


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



Re: [PHP] Checkbox

2003-03-26 Thread CPT John W. Holmes
On Wednesday 26 March 2003 01:43 pm, CPT John W. Holmes wrote:
   is it possible to have a checkbox that if it is specified to be
checked
   when the page is being formulated then it cannot be unchecked?
 
  No. No... No.
 
  If you already know you don't want it to be unchecked, then don't show a
  checkbox. That's why we have PHP, so you can create your page
DYNAMICALLY
  and not show bits and pieces when you don't need to.

 Although that is theoretically correct, there can be some reason why one
would
 want to display a checkbox anyway. Sometimes it can be clearer for the
user
 to see the GUI, asthetic reason, etc, etc.

True. In that case, though, I would just show an image of a checked check
box. The end result will be the same to the user, they will just think it's
a checkbox they cannot uncheck.

---John Holmes...


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



Re: [PHP] Checkbox

2003-03-26 Thread CPT John W. Holmes
 But isn't it so much easier to type in that one line HTML + javascript
than
 trying to get an image of a checked check box.. unless you have that
 handy, you'd have to eg. take a snapshot, or draw something, then save the
 file as an image file...hmm...

 and as you said, the effect will be the same to the user anyway

Yeah, really doesn't matter how you do it, I guess. Just so long as you
check the data after it's submitted again and determine whether the value
should have been allowed to change or not. If it wasn't allowed to change,
then don't accept the value that was passed (because it may of changed
regardless of what measures you take).

Like you said, hopefully that part is obvious, though. :)

---John Holmes...


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



RE: [PHP] auto_prepend_file

2003-03-26 Thread John W. Holmes
 Trying to use
 php_value auto_prepend_file /path/to/file/checkauth.php
 in an .htaccess file.
 
 I've used this before without problems, however with this instance, I
 keep getting a message in my browser which says:
 Redirection limit for this URL exceeded.  Unable to load the requested
 page.
 
 my checkauth.php page looks like this
 
 ?
   session_start();
   if (!session_is_registered(SESSION)){
   header(Location: /error.php?e=2);
   exit;
   }
 ?
 
 Any suggestions would be appreciated.

error.php is probably being prepended with this file, which will fail
your check and try to redirect to error.php, which will fail your check
and try to redirect to error.php, which will fail your check and try to
redirect to error.php, which will fail your check and try to redirect to
error.php, which will fail your check and try to redirect to error.php,
which will fail your check and try to redirect to error.php, which will
fail your check and try to redirect to error.php, which will fail your
check and try to redirect to error.php, which will fail your check and
try to redirect to error.php, which will fail your check and try to
redirect to error.php, which will fail your check and try to redirect to
error.php, which will fail your check and try to redirect to error.php,
which will fail your check and try to redirect to error.php, which will
fail your check and try to redirect to error.php, which will fail your
check and try to redirect to error.php and you'll eventually hit a
limit where your web server or browser will stop. :)

---John W. Holmes...

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



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



RE: [PHP] Mail Header - id this PHP

2003-03-26 Thread John W. Holmes
 I am trying to format the mail header that will be send by mail().
 
 One thing that I noticed was it only accept for the first no. of lines
or
 charracters (???) See sample 1  2.
 
 Is this a php problem (4.2.2) or has something to do the mailer ???
 
 This script is working on (4.2.1) but is in different type of server.
 
 FYI, on header sent it has some other default header included
 
 
 
 
 Example. (1)
 
  $mail_headers .= MIME-Version: 1.0\r\n;
  $mail_headers .= From: WEB\n;
  $mail_headers .= Reply-to: $Email\n;
  $mail_headers .= Bcc: [EMAIL PROTECTED];
  $mail_headers .= Content-Type: text/html;
charset=ISO-8859-1\r\n;
  $mail_headers .= Content-Transfer-Encoding:
quoted-printable\r\n;
 
 To: [EMAIL PROTECTED]
 Subject: Test
 From: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Reply-to: [EMAIL PROTECTED]
 MIME-Version: 1.0
 
 Rejected
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 
 Example (2)
 
 
  $mail_headers .= Content-Type: text/html;
charset=ISO-8859-1\r\n;
  $mail_headers .= Content-Transfer-Encoding:
quoted-printable\r\n;
  $mail_headers .= MIME-Version: 1.0\r\n;
  $mail_headers .= From: WEB\n;
  $mail_headers .= Reply-to: $Email\n;
  $mail_headers .= Bcc: [EMAIL PROTECTED];
 
 To: [EMAIL PROTECTED]
 Subject: Test
 Content-Type: text/html; charset=ISO-8859-1
 
 Rejected:
 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0
 From: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Reply-to: [EMAIL PROTECTED]

Use \r\n between all of your headers (at the end of your strings,
above). Just using \n will not work. 

---John W. Holmes...

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



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



RE: [PHP] html_quickform - array question

2003-03-26 Thread John W. Holmes
 echo The month: $thedate['m'];

echo The month: {$thedate['m']};

or

echo The month: $thedate[m];

---John W. Holmes...

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



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



Re: [PHP] php and Perl

2003-03-27 Thread CPT John W. Holmes
www.php.net/virtual

---John Holmes...

- Original Message -
From: Brad Wright [EMAIL PROTECTED]
To: PHP General List [EMAIL PROTECTED]
Sent: Thursday, March 27, 2003 8:00 AM
Subject: [PHP] php and Perl


Hi all,

can php call perl scripts?

I know nothing of perl, but have found a perl script that will process a
MSword document in a way that it seems php cannot.

At this stage, my knowledge of perl is limited to it's used in web stuff
sometimes isnt it :) but i am sure i will soon find a bit more about perl
itself elsewhere from this list.

Can i indeed use php to 'call' a perl script/function/app whatever its
called?



Cheers,

Brad


Nel vino la verità, nella birra la forza, nell'acqua i bacilli
--
In wine there is truth, in beer there is strength, in water there are
bacteria


--
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] preg split question

2003-03-27 Thread CPT John W. Holmes
 i'd like to split Benutzer_CRA.php
 to get CRA  but sometimes the files are called 
 Benutzer_OVE_CRA.php and therefore the result schould OVE_CRA
 how cann i tell preg_split to split the string at the 
 first occurence of _ and before .php

preg_match(/_(.*)\.php/,$str,$matches);

$matches[1] will contain what you're looking for.

---John Holmes...

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



Re: [PHP] Removing columns from a text file

2003-03-27 Thread CPT John W. Holmes
 I have a text file file ready to go into a Filemaker database. It has over
 5000 rows, each containing over 500 columns.

 If I do a straight import I can only pull in the first 442 colums, but all
 records. I can't take it in via Excel for the same reason - column limit
 stops at 'IV' - never got that far before.

 Is there a way to remove columns from the file using php on a fgets()
basis?
 I can identify which columns I can do without quite easily - certainly
 enough to pare the file down to a reasonable extent.

You can't just remove columns. You'd have to read in each line, chop off
the end (however much you want), and re-write it to a separate file. The
load the second file you just created into Filemaker.

 An alternative would be to create a MySQL Table and drop columns there.

You could probably use the LOAD DATA INFILE query to do this quickly.

---John Holmes...


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



RE: [PHP] split

2003-03-27 Thread John W. Holmes
 I want to make a loop.Like $a = 123; //$a is One two threw not
 hundred...
 and i want to make for each $a then $b = $a + 2
 
 The output will be.
 3 (1+2)
 4 (2+2)
 5 (3+2)
 
 Any example?

$a = 123;
$c = '';

$b = strlen($a);
for($x=0;$x$b;$x++)
{ $c .= $a{$x} +2; }

echo $c;

---John W. Holmes...

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



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



RE: [PHP] date math question

2003-03-28 Thread John W. Holmes
 This leads me to another question. If I have stored the date as an
 epoch then is there a way using PHP and MySQL to say find all the
 records that have been added this YEAR (not last 365 days)?

SELECT * FROM table WHERE YEAR(FROM_UNIXTIME(column)) =
YEAR(CUR_DATE());

Benchmark each method and see which is faster...

---John W. Holmes...

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



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



Re: [PHP] Anything that is changed when the browser is closed

2003-03-28 Thread CPT John W. Holmes
While your script is running, you can use connection_aborted() to see if the
user has clicked the stop button or closed the window. After your script
finishes, though, then you have no way of knowing unless you use a session
cookie, which will be destroyed when the browser is closed.

---John Holmes...

- Original Message -
From: Haseeb Iqbal [EMAIL PROTECTED]
To: PHP General list [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 8:46 PM
Subject: [PHP] Anything that is changed when the browser is closed


hi,
just wanna know if there is anything in php that can be used (besides
sessions) to get anything from the $_SERVER that is unique and gets changed
each time we close the browser. anything at all to check if the user has
closed the browser.
regards
Haseeb


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



Re: [PHP] Session Theft

2003-03-28 Thread CPT John W. Holmes
 i just want to figure out a way by which i can stop session theft.i
thought
 if i can get something from user end that is unique for that user.for e.g.
 his/her IP .but it will not work when they are behind firewall.they will
be
 assigned same IP.is there a way for me to get the IP (e.g.202.202.202.202
 thats just an e.g. ) plus computer ip(192.168.0.1 e.g.) i saw once a java
 chat server do this.if we can do this then it will help us (SOMEWHAT).

Conduct your business over SSL. That's the only way, otherwise everything is
sent plain text and can be intercepted.

---John Holmes...


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



Re: [PHP] Get the HTTP Server Username

2003-03-28 Thread CPT John W. Holmes
 Is there anyway to get the HTTP Server Username (something like
 $_SERVER['username']) I tried printing all the variables defined in a
 page (and looking at a phpinfo.php) and wasn't able to figure it out...

Do you mean the user your web server is running as? You should already know
that...

---John Holmes...


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



Re: [PHP] Is there a PHP for Dummies?

2003-03-28 Thread CPT John W. Holmes
 I'm really tired of trying to figure out the PHP manual and need something
 that explains things in plain straight forward English. Like
 get_magic_quotes_gpc() for example - the manual says how to use it and
what
 it returns - but nowhere can I find out what it's for. Does it count
sheep,
 do a quote of the day, or what - maybe I'm just stupid - but in any event
I
 have spent more time in the last two weeks searching for things and
getting
 no answers - Any help in pointing me a good straight forward
tutorial/manual
 would be appreciated.

Ummm... it returns the setting of magic_quotes_gpc from the php.ini file. Do
you need to know what magic_quotes are? That's in the manual, too...

Usually something telling you how to use it and what it returns is good
enoughbut

---John Holmes...


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



<    10   11   12   13   14   15   16   17   18   19   >