Re: [PHP] Post Array elements to URL / was: Database Search .............

2004-11-15 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 you need to build a string which looks like:
 
   Stat[1]=value1State[2]=value2...Stat[n]=valuen
 
 which you append to your URL like so:
 

searchresults.php?Stat[1]=value1Stat[2]=value2...Stat[n]=valuen
 
 This can be done using a foreach() on $_POST['Ind'],
 and implode(). Remember 
 to validate each item as you go along.


Not sure if this means I need to use both a foreach
and implode or one of them.

Right now I have this :

?php
$stats = $HTTP_POST_VARS['stats'];
if (is_array($stats))
foreach ($stats as $key=$val ) {
print $key = $valbr /;
}
?
 
I'm wondering how I change from printing it our to
getting into the URL.

Stuart

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



RE: [PHP] Converting a string into ASCII and a bit more - newbie

2004-11-15 Thread Alp Bekisoglu
Hi Klaus,

Thanks you very much both for your quick reply and guidance. Yes, it now
works as it should.

I have a few further questions all related to the subject if you wouldn't
mind.

One is: how can I do the following (sort of maths) with a secondary string
of ascii values i.e. 25203030
with this result string from the first operation (65666768697071727374)
should be processed as
(65+25)(66+20)(67+30)(68+30)(69+25)(70+20)(71+30)(72+30)(73+25)(74+20)
So it actually is a nested loop but I am clueless how to accomplish this in
PHP.

Then finally I will convert the resulting ascii values string back into
chr's. I think I know how to do this. (Finally).

Thanks again for your time and help.

Alp

-Original Message From: Klaus Reimer-

Alp wrote:
 $x=1
 while ($x=strlen($string)) {
 $holder = ord(substr($string, $x, 1));
 $result = $result . $holder;
 }
 and failed since it takes ages to process and does not really return a 
 proper value/result but repetitive number such as 1..

I think you forgot to increment $x. Add an $x++ at the end of your 
loop and it works.

And by the way: It's better to write $result .= $holder if you want to 
append a string to another. That's shorter and (more important) faster.

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



Re: [PHP] Pulling data from a table into a array

2004-11-15 Thread Jason Wong
On Monday 15 November 2004 15:54, Richard wrote:
 I am using mysql_fetch_row to pull data from a table to fill an array
 But I am not getting the data into the array the way I whant it to be.

 $query = SELECT amenityID FROM property_amenity where listingId =
 '$listingId';
 $results = mysql_query($query);
  if ($results) {
while ($list=mysql_fetch_row($results)) {

You are really *much* better off using mysql_fetch_assoc().

 $checked[]=$list;

Instead of of slapping the whole of $list into $checked, just stick in the bit 
you want, namely amenityID.

So assuming you've changed to using mysql_fetch_assoc():

  $checked[]=$list['amenityID'];

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
  Where in the US is Linus?

He was in the Promise Land.
 -- David S. Miller [EMAIL PROTECTED]
*/

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



Re: [PHP] Converting a string into ASCII and a bit more - newbie

2004-11-15 Thread Matthew Fonda
This ought to work:
?php
$string = 'ABCDEFGHIJ';
$chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
for ($i = 0; $i  count($chars); $i++) {
$chars[$i] = ord($chars[$i]);
//$chars[$i] = ord($chars[$i]) + 10;
}
$string = implode('', $chars);
? 

On Sun, 2004-11-14 at 22:32, Alp wrote:
 Hi,
 
 My question could have quite stright forward answer or the question itself
 might be silly but being a newbie, I'll ask it anyway.
  First I am trying to convert each character in a string into their
 respective ASCII codes and then keep these again in a string. Such as:
 string : ABCDEFGHIJ, expect to see in the result : 65666768697071727374
 Then I would like to further manipulate this result with some math, say add
 10 to each pair (the ascii code) so the new result becomes:
 75767778798081828384
 For my first attempt I tried:
 $x=1
 while ($x=strlen($string)) {
 $holder = ord(substr($string, $x, 1));
 $result = $result . $holder;
 }
 and failed since it takes ages to process and does not really return a
 proper value/result but repetitive number such as 1..
 I have also tried a 'for' example I found which failed as well.
 I truely hope an expert here could show me some light and point me in the
 right direction.
 I have 2 sets installed on my PC as PHPDEV423 and XAMPP 1.4.9 (set to use
 php4) and it fails in both.
 
 Thanks in advance,
 
 Alp
 P.S.: I hope I have posted this in the correct NG
-- 
Regards,
Matthew Fonda

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



[PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
For those who recognize this topic from me and perhaps
are sick of it , my apologies :)

This is actually a different question more about logic
then syntax or functionality.

One of the uses of my search form is that users may
save their search parameters. Typical benefits, they
don't have to re-enter all the criteria.  Hitting one
link or receiving an email can get them the results
they need.  

The way I was approaching this was to grab the url,
the part after the ? , so not the referer.  Whatever
the second part is called. 
Only now that I've created a search and results page
via Post method, of course there is nothing going to
the URL. I'm wondering at this point if I should
create a way to let users save their search
parameters, by grabbing the variables and storing them
as an array in the database or go back to the URL
method.

Curious if anyone sees benefits or negatives with
either.

Stuart

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



[PHP] Dynamic Combo Box

2004-11-15 Thread ankur_os
Dear All,

I want to create 3 dynamic combo box.

When i select the first combo(select) box then automatically the related details
[from database] will come in the second select box.and simultenously for second
to third.

Please help me.(give me some help through code)

I have to complete the project at last by today...

Thnx

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



[PHP] Can't get results from MySQL via PHP

2004-11-15 Thread Alp
Hi there,

I've been fighting with PHP/MySQL to get proper results but without success.
For example:
  $sql = SELECT * FROM prod WHERE shortname='Myprog;
  $result = mysql_query($sql);  returns Resource #7
  $list = mysql_fetch_row($result);   returns Array

and actually the data in the table is a four digit number! The query returns
what is expected in MySQL but refuses to do so under php. What is it (or
could be) that I am doing wrong/missing?

Thanks in advance.

Alp

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



Re: [PHP] Can't get results from MySQL via PHP

2004-11-15 Thread raditha dissanayake
Alp wrote:
Hi there,
I've been fighting with PHP/MySQL to get proper results but without success.
For example:
 $sql = SELECT * FROM prod WHERE shortname='Myprog;
 $result = mysql_query($sql);  returns Resource #7
 $list = mysql_fetch_row($result);   returns Array
and actually the data in the table is a four digit number! The query returns
what is expected in MySQL but refuses to do so under php. What is it (or
could be) that I am doing wrong/missing?
 

PHP is behaving exactly as it should. The fact that your table has one 
column only is of no relevence you still have to retrieve the first 
element of the array that is returned  mysql_fetch_row($result);

--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Database search logic question

2004-11-15 Thread Graham Cossey
A couple of possibilities are:

Store search criteria (form entries) in MySQL
Store query string in MySQL

If the user has to log-in then the MySQL table would
be keyed on the user_id or similar.

If the user does not have to log-in then you will most
likely need to store something in a client-side cookie 
that references the saved query details.

On one of my sites I allow users to either build a query
via a step-by-step procedure or manually enter a query
statement. It is the statement that I store in the 
database together with a name they supply and their user 
id. This allows the user to save multiple queries and 
recall them at a later date by a name that they supplied.

HTH
Graham


 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 15 November 2004 09:10
 To: [EMAIL PROTECTED]
 Subject: [PHP] Database search logic question
 
 
 For those who recognize this topic from me and perhaps
 are sick of it , my apologies :)
 
 This is actually a different question more about logic
 then syntax or functionality.
 
 One of the uses of my search form is that users may
 save their search parameters. Typical benefits, they
 don't have to re-enter all the criteria.  Hitting one
 link or receiving an email can get them the results
 they need.  
 
 The way I was approaching this was to grab the url,
 the part after the ? , so not the referer.  Whatever
 the second part is called. 
 Only now that I've created a search and results page
 via Post method, of course there is nothing going to
 the URL. I'm wondering at this point if I should
 create a way to let users save their search
 parameters, by grabbing the variables and storing them
 as an array in the database or go back to the URL
 method.
 
 Curious if anyone sees benefits or negatives with
 either.
 
 Stuart
 
 -- 
 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] Database search logic question

2004-11-15 Thread Stuart Felenstein
Please see inline:
--- Graham Cossey [EMAIL PROTECTED] wrote:

 A couple of possibilities are:
 
 Store search criteria (form entries) in MySQL
 Store query string in MySQL

So with my current form, the where statement is built
from conditions that are set (or not set) in the form.
Perhaps I grab that one array ?

 On one of my sites I allow users to either build a
 query via a step-by-step procedure or manually enter

 a query
 statement. It is the statement that I store in the 
 database together with a name they supply and their
 user 
 id. This allows the user to save multiple queries
 and 
 recall them at a later date by a name that they
 supplied.
 
I have something like that set up now.  The user must
be registered and logged in, the difference is I'm
saving the query string from URL. 

Stuart

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



Re: [PHP] Can't get results from MySQL via PHP

2004-11-15 Thread Alp
Thanks for your response, I did finally sove it by changing
mysql_fetch_row($result);  to
mysql_fetch_array($result);
and assigning my variable as $somevar = $list['fieldname'];

Now I get my real value. Thanks again.

Alp


Raditha Dissanayake [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Alp wrote:

 Hi there,
 
 I've been fighting with PHP/MySQL to get proper results but without
success.
 For example:
   $sql = SELECT * FROM prod WHERE shortname='Myprog;
   $result = mysql_query($sql);  returns Resource #7
   $list = mysql_fetch_row($result);   returns Array
 
 and actually the data in the table is a four digit number! The query
returns
 what is expected in MySQL but refuses to do so under php. What is it (or
 could be) that I am doing wrong/missing?
 
 
 PHP is behaving exactly as it should. The fact that your table has one
 column only is of no relevence you still have to retrieve the first
 element of the array that is returned  mysql_fetch_row($result);

 -- 
 Raditha Dissanayake.
 --
 http://www.radinks.com/print/card-designer/ | Card Designer Applet
 http://www.radinks.com/upload/  | Drag and Drop Upload

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



RE: [PHP] Database search logic question

2004-11-15 Thread Graham Cossey
 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 15 November 2004 10:12
 To: Graham Cossey; [EMAIL PROTECTED]
 Subject: RE: [PHP] Database search logic question


 Please see inline:
 --- Graham Cossey [EMAIL PROTECTED] wrote:

  A couple of possibilities are:
 
  Store search criteria (form entries) in MySQL
  Store query string in MySQL

 So with my current form, the where statement is built
 from conditions that are set (or not set) in the form.
 Perhaps I grab that one array ?

[snip]

I was thinking more along the lines of storing the SQL string.

SELECT ... FROM vendorjobs WHERE...

Then when recalled there is no further array processing etc to be done.
However, you may want some kind of validation to prevent malicious use of
the feature.

I've never attempted to store an array in a MySQL table. But storing the
'where' is an alternative.

Other guys (and girls) on the list probably have much more experience of
this than myself.

Graham

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



RE: [PHP] Sessions: I don't get it!!

2004-11-15 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 15 November 2004 06:13, [EMAIL PROTECTED] wrote:

 Looks like you're making it way more complicated than it
 needs to be. PHP
 will automatically tack on the Session ID tag to your local
 url's, but only
 if it needs to. There is no need to append the SID to url's manually.

Not to most URLs, no, but if the SID is being passed in the URL you *must*
append it to any header(Location: ...) URL.

Fortunately, this, too, is easy, and the OP was making it way more
complicated than it needs to be! ;)  The constant SID only contains the
session name and id *when it needs to* -- otherwise it's defined as the
empty string.  So you can unconditionally append it to URLs and get the
right result:

   header('Location: simple2.php?'.SID);

The only tidying-up you might want to do, if you're really obsessional about
neatness, is suppress the '?' if SID is empty, so:

   header('Location: simple2.php'.SID?('?'.SID):'');

I can't see any benefit in applying strip_tags() to SID, unless you're
terminally paranoid -- as it's generated internally by PHP, there shouldn't
be any way it can contain anything that strip_tags() would defend against.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Converting a string into ASCII and a bit more - newbie

2004-11-15 Thread Alp
Thanks Matthew,

Got it going finally.

Would you be able to help in my further question?

Alp

Matthew Fonda [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 This ought to work:
 ?php
 $string = 'ABCDEFGHIJ';
 $chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
 for ($i = 0; $i  count($chars); $i++) {
 $chars[$i] = ord($chars[$i]);
 //$chars[$i] = ord($chars[$i]) + 10;
 }
 $string = implode('', $chars);
 ?

 On Sun, 2004-11-14 at 22:32, Alp wrote:
  Hi,
 
  My question could have quite stright forward answer or the question
itself
  might be silly but being a newbie, I'll ask it anyway.
   First I am trying to convert each character in a string into their
  respective ASCII codes and then keep these again in a string. Such as:
  string : ABCDEFGHIJ, expect to see in the result : 65666768697071727374
  Then I would like to further manipulate this result with some math, say
add
  10 to each pair (the ascii code) so the new result becomes:
  75767778798081828384
  For my first attempt I tried:
  $x=1
  while ($x=strlen($string)) {
  $holder = ord(substr($string, $x, 1));
  $result = $result . $holder;
  }
  and failed since it takes ages to process and does not really return a
  proper value/result but repetitive number such as 1..
  I have also tried a 'for' example I found which failed as well.
  I truely hope an expert here could show me some light and point me in
the
  right direction.
  I have 2 sets installed on my PC as PHPDEV423 and XAMPP 1.4.9 (set to
use
  php4) and it fails in both.
 
  Thanks in advance,
 
  Alp
  P.S.: I hope I have posted this in the correct NG
 -- 
 Regards,
 Matthew Fonda

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



[PHP] force a download

2004-11-15 Thread Alessandro Rosa
How can be forced a download by PHP with the
visualization of Directory dialog window in order to choose
the download path?

Alessandro Rosa


[PHP] Re: Dynamic Combo Box

2004-11-15 Thread Sebastian Mendel
Ankur Os wrote:
I want to create 3 dynamic combo box.
When i select the first combo(select) box then automatically the related details
[from database] will come in the second select box.and simultenously for second
to third.
Please help me.(give me some help through code)
I have to complete the project at last by today...
This is a javascript related problem!
Why not just take a look add any driver-section of a web-page from a 
hardware-manufacturer?

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] $_REQUEST

2004-11-15 Thread Diana Castillo
there seems to be a limit to how many form variables I can get wtih a 
$_REQUEST.  does anyone know how to get an large amount of variables?

-- 
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039 Ext 216
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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



RE: [PHP] $_REQUEST

2004-11-15 Thread Jay Blanchard
[snip]
there seems to be a limit to how many form variables I can get wtih a 
$_REQUEST.  does anyone know how to get an large amount of variables?
[/snip]

Look at $_POST

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



[PHP] session_set_cookie_params() for one level domains

2004-11-15 Thread Jordi Canals
Hi all,

Something that has taken me some time to debug and wanted to share:
session_set_cookie_params() does not work when the domain param is
just a one level domain, like it was a TLD.

I have a site in an intranet and our internal domain is .local, so
trying to set the cookie session to the .local domain does not work:

session_set_cookie_params(0, '/', '.local'); // Does not work

In all test I've done, setting the domain only works for SLDs and above: 

session_set_cookie_params(0 , '/', '.sld.local'); Does work

I think this is nothing to do with PHP but the http protocol, witch
does not permit setting cookies for TLDs for obvious security reasons.

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



Re: [PHP] Atom 2 RSS Script? Anyone got one?

2004-11-15 Thread Skippy
On Sun, 14 Nov 2004 16:48:57 +0100 Nick Wilson [EMAIL PROTECTED] wrote:
 hi all, 
 
 im all tired out of searching, just cant seem to find a script that will
 convert atom 0.3 to any rss format. Does anyone have one or know where i
 can get hold of one?

That's probably because most people have the data in a personal format
which they convert to either RSS or Atom.

Related to your problem, try looking for an XSLT transformation script.
Both RSS and Atom are XML so it should work (actually, only the source
needs to be XML). Sorry, can't point out any ready-made ones.

-- 
Skippy - Romanian Web Developers - http://ROWD.ORG

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



[PHP] sending mail attachment problem

2004-11-15 Thread Angelo Zanetti
Hi all

I have a script that is supposed to use the mail function to send an
email with an attachment, however, when run the script I dont get any
errors but in the body of the email there is a lot of mixed up text,
which i presume is meant to be the attachment.

Below is the code that performs the sending:

if (file_exists
(/home/httpd/vhosts/myserv.com/httpdocs/pps/ . $row['pps_doc']  .))
{
$pps_name= $row['pps_doc'];
$pps =
/home/httpd/vhosts/myserv.com/httpdocs/pps/ . $row['pps_doc'];
$pps_size = $row['pps_size'];
}

 $headers .= From: myserv.com [EMAIL PROTECTED]\r\n;
 $headers .= Content-Type: text/plain;
charset=\iso-8859-1\\n;
 $headers .= Content-Transfer-Encoding: 7bit\n\n;

$fp = fopen($pps,'rb'); 
$file = fread($fp, $pps_size);
/*
Encode The Data For Transition using base64_encode();
And get a 32-character hexadecimal number
*/
$fileContent .= chunk_split(base64_encode($file));
$num = md5( time() );

$headers .= Content-Type:
application/vnd.ms-powerpoint; \r\n;
$headers.= name=\$pps_name\\r\n;
$headers.= Content-Transfer-Encoding: base64\r\n;
$headers.= Content-Disposition: attachment; \r\n;
$headers .= filename=\$pps_name\\r\n\n;

$headers .= $fileContent . \r\n;

$headers .= --$num--;

 if(!mail($to, $subject, $message, $headers)) {

echo Error: mail() function failed!BR;

}

Im not sure what is causing the problem, the attachment is a powerpoint
slide, Ive tried the various Mime Types for pps, all with the same
result so I presume thats not it thats causing the email to be sent in
the body.

Thanks in advance for any help
Angelo

Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



RE: [PHP] sending mail attachment problem

2004-11-15 Thread Jay Blanchard
[snip]
I have a script that is supposed to use the mail function to send an
email with an attachment...
[/snip]

http://www.zend.com/zend/spotlight/sendmimeemailpart1.php

Have a look at this article, it'll shed some light on it

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



Re: [PHP] force a download

2004-11-15 Thread John Nichel
Alessandro Rosa wrote:
How can be forced a download by PHP with the
visualization of Directory dialog window in order to choose
the download path?
Alessandro Rosa
Start here...
http://us4.php.net/header
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] explode and PATH_SEPARATOR

2004-11-15 Thread Francisco M. Marzoa Alonso
Taking this code:
pre
?php
define (PATH_SEPARATOR, /);
$String=Root/One/Two/Three/Last;
$arr = explode ( PATH_SEPARATOR, $String );
var_dump ( $arr );
$arr = explode ( /, $String );
var_dump ( $arr );
?
/pre
It works fine in second case returing a five elements array, but in the 
first one it returns an array with just one elemen that's the source 
string itself. I've test it also changing PATH_SEPARATOR by SEPARATOR in 
both cases, and it works nice... Is PATH_SEPARATOR any kind of reserved 
word or so?

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


Re: [PHP] Silly OOP question

2004-11-15 Thread Simas Toleikis

Semantics. Until any langiage compiles to pure 1s and 0s, it's all about
bytecode. Even C compiles to assembler which is really just a low level
bytecode.
 

Just a note:
C compiles to opcodes. opcodes are 1s and 0s directly interpreted by CPU.
Same applies to assembler. (asm-opcodes). The true is that C has 
nothing to do with assembly language.

Note on inline C assembly:
When you use inline C assembler several thing happen:
1) C compiles itself to assembler
2) Your inline assembly code is then inserted properly
3) Asm compiles to opcodes (And assembler compiler is required: MASM - 
used by ms compilers, TASM-borland etc..)

When no inline assembly used C code compiles directlly to opcodes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP postfix mail problem no recipient problem on SUSE 9.1

2004-11-15 Thread Manuel Lemos
Hello,
On 11/15/2004 05:52 AM, Chris W wrote:
I have a PHP script to send an email that I know is correct.  Ever since 
I installed SUSE 9.1I get a no recipient error from postfix.  I know 
others have had this problem but after an extensive search I can find no 
solution.  As of yet no one seems to know, or is not willing to tell how 
to fix this config problem that SUSE screwed up when they released 9.1.  
I have also heard it is still a problem in 9.2 as well.   So here is 
some incentive, I will send $25 via paypal to the first person who can 
tell me how to fix this.  BTW using some other mail function that isn't 
part of the core PHP isn't a solution.
If you want to see the error on your own SUSE 9.1 install just run the 
PHP test mail program and look at the mail logs.

?php
$message =  This is a Test Message ;
mail('[EMAIL PROTECTED]', test message, $message);
?
I already suggested that it may be a problem in your PHP configuration. 
However, since you did not show your php.ini file it is hard to help 
without further cooperation from you.

I also suggested that you try this class that comes with a wrapper 
function named sendmail_mail(). It emulates mail() function except that 
it sends the message directly to Postfix sendmail emulation wrapper. I 
know that you do not want to use anything that isn't part of the core 
PHP, but at least trying this class you will be able to tell whether it 
is a PHP problem or a Postfix problem depending on whether the class 
function works or not.

BTW, keep your change, but if you want help, you need to help us helping 
you.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: sending mail attachment problem

2004-11-15 Thread Manuel Lemos
Hello,
On 11/15/2004 12:28 PM, Angelo Zanetti wrote:
 I have a script that is supposed to use the mail function to send an
 email with an attachment, however, when run the script I dont get any
 errors but in the body of the email there is a lot of mixed up text,
 which i presume is meant to be the attachment.
That is because you are setting it to be of text/plain.
Anyway, although you can, you should not be sending messages with 
attachments this way as modern spam filters will discard your messages.

You may want to try this class to compose and send messages with 
attachments properly:

http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] explode and PATH_SEPARATOR

2004-11-15 Thread Araceli Pulido
This constant is part of the directory functions.

See: http://www.php.net/manual/en/ref.dir.php

Araceli.

-Original Message-
From: Francisco M. Marzoa Alonso [mailto:[EMAIL PROTECTED]
Sent: Monday, November 15, 2004 5:18 PM
To: PHP-General
Subject: [PHP] explode and PATH_SEPARATOR


Taking this code:

pre
?php

define (PATH_SEPARATOR, /);

$String=Root/One/Two/Three/Last;

$arr = explode ( PATH_SEPARATOR, $String );
var_dump ( $arr );

$arr = explode ( /, $String );
var_dump ( $arr );
?
/pre

It works fine in second case returing a five elements array, but in the 
first one it returns an array with just one elemen that's the source 
string itself. I've test it also changing PATH_SEPARATOR by SEPARATOR in 
both cases, and it works nice... Is PATH_SEPARATOR any kind of reserved 
word or so?

Thx.

-- 
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] Re: PHP postfix mail problem no recipient problem on SUSE 9.1

2004-11-15 Thread Chris W
Manuel Lemos wrote:
I already suggested that it may be a problem in your PHP 
configuration. However, since you did not show your php.ini file it is 
hard to help without further cooperation from you.

Yes you did but I don't remember you asking to se the php.ini file.  It 
is a rather large file, you don't what to see the whole thing do you?  
Here are the only lines I can find that have to do with mail.

[mail function]
; For Win32 only.
;SMTP = localhost
; For Win32 only.
;sendmail_from = [EMAIL PROTECTED]
; For Unix only.  You may supply arguments as well (default: sendmail 
-t -i).
sendmail_path = /usr/sbin/sendmail

And maybe these lines
; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str*() functions
; 4: Overload ereg*() functions
;mbstring.func_overload = 0
--
Chris W
Bring Back the HP 15C
http://hp15c.org
Not getting the gifts you want?  The Wish Zone can help.
http://thewishzone.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Dinamically adding methods to an object instance?

2004-11-15 Thread Francisco M. Marzoa Alonso
I've seen that's possible to add public members to objects dinamically, 
such as:

?php
class TestClass {
   public $One=1;
}
$Obj = new TestClass ();
$Obj-Two = 2;
echo $Obj-Two;
?
There'll be a public Two member that's not defined in the class.
Is it possible to add methods dinamically to an object instance in same 
way? how? will these methods have access to private and protected 
members of the class of the object?

Thanks a lot in advance...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP postfix mail problem no recipient problem on SUSE 9.1

2004-11-15 Thread Manuel Lemos
Hello,
On 11/15/2004 02:34 PM, Chris W wrote:
I already suggested that it may be a problem in your PHP 
configuration. However, since you did not show your php.ini file it is 
hard to help without further cooperation from you.

Yes you did but I don't remember you asking to se the php.ini file.  It 
I said: It is hard to guess it right without seeing the actual 
configuration.


is a rather large file, you don't what to see the whole thing do you?  
Here are the only lines I can find that have to do with mail.

[mail function]
; For Win32 only.
;SMTP = localhost
; For Win32 only.
;sendmail_from = [EMAIL PROTECTED]
; For Unix only.  You may supply arguments as well (default: sendmail 
-t -i).
sendmail_path = /usr/sbin/sendmail
I think your problem is that the -t switch is missing. That would make 
sendmail read the addresses from the message headers, which seems to be 
the problem.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Dinamically adding methods to an object instance?

2004-11-15 Thread Matthew Weier O'Phinney
* Francisco M. Marzoa Alonso [EMAIL PROTECTED]:
 I've seen that's possible to add public members to objects dinamically, 
 such as:

 ?php

 class TestClass {
 public $One=1;
 }

 $Obj = new TestClass ();
 $Obj-Two = 2;

 echo $Obj-Two;
 ?

 There'll be a public Two member that's not defined in the class.

 Is it possible to add methods dinamically to an object instance in same 
 way? how? will these methods have access to private and protected 
 members of the class of the object?

You can add methods dynamically, but not in the same way that you can
add properties dynamically. You have two options:

1) Overloading the object
2) Using the classkit extension

(2) requires that you can add extensions to PHP on your server -- so,
for hosted solutions, it's out.

(1) can be accomplished in two ways, but in each, you need to setup your
class to allow overloading in the first place. 

PHP4 has the overload() function; read about it at

http://php.net/overload

overload() sets up an environment where the magic methods __get(),
__set(), and __call() (this latter would be used to handle dynamic
methods) are utilized.

PHP5 has overloading built into the object model; see
http://php.net/oop5 for more information.

Either way, you need to add a __call() method to your class and tell it
how to handle dynamic methods.

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



RE: [PHP] Database search logic question

2004-11-15 Thread Chris W. Parker
Stuart Felenstein mailto:[EMAIL PROTECTED]
on Monday, November 15, 2004 1:10 AM said:

 The way I was approaching this was to grab the url,
 the part after the ? , so not the referer.

This sounds like you're not familiar with the $_GET array. $_GET is
everything after the ? in the url but as an array.

 Whatever the second part is called.

I *think* that's the querystring. Not sure on that though.

 Only now that I've created a search and results page
 via Post method, of course there is nothing going to
 the URL.

This sounds like you're not familiar with the $_POST array. $_POST is
everything that *would be* after the ? in the url but as an array.

 I'm wondering at this point if I should
 create a way to let users save their search
 parameters, by grabbing the variables and storing them
 as an array in the database or go back to the URL
 method.

I don't see how these two things are similar. shrugs

If you want to store your array in a db use serialize() and
unserialize(). In any case I would just store the search criteria in a
cookie and leave the db out of it.


HTH,
Chris.

* http://www.php.net/serialize
  http://www.php.net/unserialize

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



Re: [PHP] Database search logic question

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 09:21:01 -0800, Chris W. Parker
[EMAIL PROTECTED] wrote:
 This sounds like you're not familiar with the $_GET array. $_GET is
 everything after the ? in the url but as an array.
 
  Whatever the second part is called.
 
 I *think* that's the querystring. Not sure on that though.

$_SERVER['QUERY_STRING'] to be exact.



-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Weird virtual() behavior for nested require()

2004-11-15 Thread Paul Cantrell
I'm getting a weird behavior when virtual() calls another page that 
uses a require().  The behavior seems contrary to the docs for virtual.

Consider these four files:
-- foo.php --
This is foo.
?php virtual('subdir/bar.php'); ?
-- foo.shtml --
This is foo.
!--#include virtual=subdir/bar.php--
-- subdir/bar.php --
This is bar.
?php require('./baz.php'); ?
-- subdir/baz.php --
This is baz.
According to the docs, virtual() handles the argument as an Apache 
subrequest -- in other words, it should be equivalent to an SSI 
include.  But it's not.  As I would expect, foo.shtml produces this:

This is foo. This is bar. This is baz.
Here's what I get from foo.php:
This is foo. This is bar.
Warning: main(./baz.php): failed to open stream: No such file or 
directory in
/blah/blah/blah/subdir/bar.php on line 2

Fatal error: main(): Failed opening required './baz.php' 
(include_path='.:/usr/local/lib/php')
in /blah/blah/blah/subdir/bar.php on line 2

Oddly, it works if bar.php says require('baz.php') instead of 
require('./baz.php').  That smells really bad.  Is this a bug, or am I 
missing something?

Cheers,
Paul
_
After hearing ten thousand explanations, a fool is no wiser.
 But an intelligent person needs only two thousand five hundred.
   -- Mahabharata
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Silly OOP question

2004-11-15 Thread Robert Cummings
On Mon, 2004-11-15 at 10:17, Simas Toleikis wrote:
 Semantics. Until any langiage compiles to pure 1s and 0s, it's all about
 bytecode. Even C compiles to assembler which is really just a low level
 bytecode.
   
 
 Just a note:
 
 C compiles to opcodes. opcodes are 1s and 0s directly interpreted by CPU.
 Same applies to assembler. (asm-opcodes). The true is that C has 
 nothing to do with assembly language.
 
 Note on inline C assembly:
 When you use inline C assembler several thing happen:
 1) C compiles itself to assembler
 2) Your inline assembly code is then inserted properly
 3) Asm compiles to opcodes (And assembler compiler is required: MASM - 
 used by ms compilers, TASM-borland etc..)
 
 When no inline assembly used C code compiles directlly to opcodes.

True :) I guess the point I was trying to make is that the opcodes that
C compiles to are less efficient (processor wise) than if the actual
machine language was manipulated. Working with assembler gets one closer
to that potential efficiency, but still not perfect. Understandably this
is necessary or we'd still be spending weeks to write simplistic
programs.

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

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



[PHP] Column Totals

2004-11-15 Thread Ben Miller
I am trying to get the total sales revenue for each day of the month, and
having no luck at all.

The following query seems to return an empty string, which should only give
me the total for the entire column anyway.
$query = SELECT SUM(Revenue) FROM Sales WHERE Date='$Date';


I also tried, among many, many things, to use a for loop to get the sum for
each date, month to date, such as:

$Today = date(d);

for ($i = 1; $i  $Today; $i++) {

   $query = SELECT SUM(Revenue) FROM Sales WHERE Date='$i';

}

In case it helps, sample table data might look like this:

OrderNoOrderDateRevenue
   1  79.95
1112   1  39.95
1113   3  89.95

and I am trying to produce something that would show:

TABLE
TR
TDDate/TDTDRevenue/TD
/TR
TR
TD1/TDTD119.90/TD
/TR
TR
TD2/TDTD0.00/TD
/TR
TR
TD3/TDTD89.95/TD
/TR
/TABLE


PLEASE HELP.   PLEASE!!  And many, many thanks in advance

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



RE: [PHP] Help: Database Search

2004-11-15 Thread Gryffyn, Trevor
You can't do WHERE Industry = 1, 2, 3 unless that's something you can
do in MySQL but not the other DB's I've used.

What you CAN do is us IN:


WHERE Industry IN (1, 2, 3)

Or..

WHERE Industry IN ('1','2','3')


IN basically does a Industry = 1 OR Industry = 2 OR Industry = 3 type
thing.

If there's a more efficient way to do your query, I'd recommend it.
IN or even the multiple OR statements can be very intensive on a
database with a high load or tons of rows.  But it's definitely the
right answer for some solutions.

If you have 8 categories for Industry and you're doing IN (1, 2, 3, 4,
5) then you might consider doing a  6,  7,  8 type thing (I'm
guessing you can do NOT IN (6, 7, 8), just never done it).   The fewer
things you're checking in your WHERE clause, the less work your DB
server has to do.

HTH

-TG

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, November 13, 2004 1:16 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Help: Database Search
 
 
 I've changed my logic around but still running into a
 sql query error.
 I've tried a number of things with no success.  Here
 is the error that returns on POST:
 
 SELECT PostStart, JobTitle, Industry, LocationState,
 VendorID FROM VendorJobs WHERE (VendorJobs.Industry =
 ''1','2','3''Query failed: You have an error in your
 SQL syntax. Check the manual that corresponds to your
 MySQL server version for the right syntax to use near
 '1','2','3''' at line 2 . 
 
 Here is the relevant code:
 
 $Ind = $HTTP_POST_VARS['Ind'];
 if (count($Ind)  0 AND is_array($Ind)) {
 $Ind = '.implode(',', $Ind).';
 }
 $sql = SELECT PostStart, JobTitle, Industry,
 LocationState, VendorID
 FROM VendorJobs;
 //if ($Ind)
 $sql .=  WHERE (VendorJobs.Industry = '$Ind';
 
 I'm not trying to be a pain here.  Either I'm not
 catching a syntax error or something else.
 
 Stuart

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



RE: [PHP] Column Totals

2004-11-15 Thread Jay Blanchard
[snip]
The following query seems to return an empty string, which should only
give
me the total for the entire column anyway.
$query = SELECT SUM(Revenue) FROM Sales WHERE Date='$Date';
[/snip]

$query = SELECT SUM(Revenue) AS Revenue FROM Sales WHERE Date='$Date';
note the AS statement-^

$foo = mysql_query($query, $connection);

$bar = mysql_fetch_array($foo);

echo $bar['Revenue']

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



RE: [PHP] Hacking attempt

2004-11-15 Thread Gryffyn, Trevor
Sounds like someone replaced their INDEX.PHP with something else.

Short answer:  You can get the INDEX.PHP back if you restore it from a
backup copy you should have.

If you don't have a backup copy, then you can't get it back most likely
(unless it's on a system that you can manage to undelete from, but
chances are it's been over-written by now).


The bigger question is How do we keep someone from replacing our PHP
scripts again?.   I'd do some research on PHP security.  Cross Site
Scripting vulnerabilities are big these days and many (all? Need to do
more research) can be handled by the PHP developer by scrubbing user
input sufficiently to make it impossible.

Also, keep up with the latest versions of PHP as they tend to patch
security issues that are known to exist (can't patch something that
nobody's reported though).


And the biggest must do Keep backups.   If you gotta, you can
always just copy over the hacked pages with a few copy of your
latest/greatest PHP scripts.

Good luck.

-TG

 -Original Message-
 From: raditha dissanayake [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, November 14, 2004 8:51 AM
 Cc: [EMAIL PROTECTED]
 Subject: Re: [PHP] Hacking attempt
 
 
 and what exactly is a hacking attempt?
 
 The Doctor wrote:
 
 One of our customers how has
 Hacking attempt on their index.php instead of their regualr page.
 
 What caused this and how do we get the regualr page back?

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



RE: [PHP] Column Totals

2004-11-15 Thread Ben Miller
-Original Message-
From: Robby Russell [mailto:[EMAIL PROTECTED]
Sent: Monday, November 15, 2004 11:12 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Column Totals


On Mon, 2004-11-15 at 11:01 -0700, Ben Miller wrote:
 SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'

What happens when you do:

SELECT Revenue FROM Sales WHERE Date='$Date';

Make sure you're getting values back first..and then you can try to sum
them.

-Robby


--
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
*--- Now supporting PHP5 ---
/

I am getting values back in this case, if there are values for the given
date, that is.  If I do:


while ($row = mysql_fetch_array($result)) {

extract($row);

echo TRTD$DateBR/TDTD$RevenueBR/TD/TR;
}

for example, it returns a long list of individual sales.

Ben

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



[PHP] Recall: [PHP] Converting a string into ASCII and a bit more - newbie

2004-11-15 Thread Alp Bekisoglu
The sender would like to recall the message, [PHP] Converting a string into 
ASCII and a bit more - newbie.

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

Re: [PHP] Dinamically adding methods to an object instance?

2004-11-15 Thread Robby Russell
On Mon, 2004-11-15 at 18:56 +0100, Francisco M. Marzoa Alonso wrote:
 I've seen that's possible to add public members to objects dinamically, 
 such as:
 
 ?php
 
 class TestClass {
 public $One=1;
 }
 
 $Obj = new TestClass ();
 $Obj-Two = 2;
 
 echo $Obj-Two;
 ?
 
 There'll be a public Two member that's not defined in the class.
 

Hmm, don't think that you can do this. You could do something like this
though:

class foo
{
var $bar = array();

function foo() 
{
$this-bar['One'] = 1;
}
}

$obj = new foo();
$obj-bar['Two'] = 2;

print_r($obj);



foo Object
(
[bar] = Array
(
[One] = 1
[Two] = 2
)

)




 Is it possible to add methods dinamically to an object instance in same 
 way? how? will these methods have access to private and protected 
 members of the class of the object?
 
 Thanks a lot in advance...
 
-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
*--- Now supporting PHP5 ---
/


signature.asc
Description: This is a digitally signed message part


Re: [PHP] newbie question

2004-11-15 Thread Richard Davey
Hello Max,

Monday, November 15, 2004, 6:26:43 PM, you wrote:

MK } else if ($_POST[FirstName] != ) {

Where you use $_POST you should have the syntax as follows:

$_POST['var']

(note the quote marks)

Without them, PHP is going to think you're passing in a constant
called FirstName (etc) which of course you're not.

MK $add_table = INSERT into table values (NULL, '$_POST[FirstName]',
MK '$_POST[LastName], '$_POST[Address], '$_POST[City], 
'$_POST[State],
MK '$_POST[Zip], '$_POST[phone],'$_POST[email]);
MK mysql_query($add_table) or die(mysql_error());

You really *really* shouldn't insert POST data directly into a table,
for reasons please see Chris's very good read on PHP Security here:

http://shiflett.org/php-security.pdf

But back to the question in hand - try and see what has happened,
extend your code a bit at the end:

mysql_query($add_table);

if (mysql_error($conn))
{
   echo Something bad happened with MySQL:  . mysql_error($conn);
}
else
{
echo There was no SQL error;
}

Try outputting the SQL (echo $add_table) and then pasting it into
PHPMyAdmin or a MySQL command session and see what it gives you. If
that works fine, the error is in the communication with the MySQL
server (authentication perhaps) and not the SQL itself.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



Re: [PHP] Column Totals

2004-11-15 Thread raditha dissanayake
Ben Miller wrote:
I am trying to get the total sales revenue for each day of the month, and
having no luck at all.
 

snipped/
In case it helps, sample table data might look like this:
OrderNoOrderDateRevenue
   1  79.95
1112   1  39.95
1113   3  89.95
 

I would guess that you have a char type for your Revenue Column which 
would lead to this situation. If you are unsure about which data type to 
use you will have to ask in a mysql mailing list. 
you might also want to echo out your query and run it directly in the 
mysql client to see what happens. Liberal user of 
error_log(mysql_error()) in your code would probably help too.


--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] XML Parser doesn't work when moved....

2004-11-15 Thread Gryffyn, Trevor
Using PHP 4.2.1 as a development platform to run on a 4.3.7 production
box?  How strange. Haha  Assuming you have zero control over this
(otherwise, UPGRADE or something :) then I'm not sure what to tell you.

Here are some articles you may have seen already, but passing them on
anyway:


Parsing non-well-formed XML documents in PHP 5.1
http://blog.bitflux.ch/archive/parsing_non_well_formed_xml_documents_in_
php.html

Parsing RSS at all costs  (some general ideas, not necessarily PHP
oriented)
http://www.xml.com/pub/a/2003/01/22/dive-into-xml.html

Random comments at PHP Manual:
http://ar.php.net/manual/en/ref.xml.php

Random info from Zend:
http://www.zend.com/zend/art/parsing.php


need help with Sablotron parser error
http://www.webmasterworld.com/forum88/2491.htm



You also might try to pre-qualify/validate the XML and if it doesn't
pass the well-formed test, to put it aside and notify you of a
problem.  Here's info on 'well-formedness':
http://www.developer.com/lang/print.php/784621
http://www.phpfreaks.com/xmlmanual.php


Hope this helps a little.

-TG


 -Original Message-
 From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, November 10, 2004 4:18 PM
 To: Jay Blanchard; [EMAIL PROTECTED]
 Subject: RE: [PHP] XML Parser doesn't work when moved
 
 
 [snip]
 Having added the following line
 
 echo XML Error  . 
 xml_error_string(xml_get_error_code($covadParser)) .
 br\n;
 
 just after the xml_parse PHP is reporting not well-formed (invalid
 token) so I will have to explore.
 [/snip]
 
 Having beaten my head against the wall for severqal hours now, I am
 thouroughly stumped and have a major headache. I have turned 
 over all of
 the rocks that I can and cannot even come up with a clean 
 explanation of
 the error itself. Does anyone have anything that can help me 
 clean this
 up? Unfortunately I have no control over the XML as it is a received
 document that I am trying to parse.
 
 -- 
 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] Database search logic question

2004-11-15 Thread David Bevan
On November 15, 2004 13:27, Stuart Felenstein wrote:
 See inline:

 --- Chris W. Parker [EMAIL PROTECTED] wrote:
  Stuart Felenstein mailto:[EMAIL PROTECTED]
 
  on Monday, November 15, 2004 1:10 AM said:
   The way I was approaching this was to grab the
 
  url,
 
   the part after the ? , so not the referer.
 
  This sounds like you're not familiar with the $_GET
  array. $_GET is
  everything after the ? in the url but as an array.

 It sounds like you answered before you either read or
 understood.  I was talking about

 $_SERVER[QUERY_STRING];

  This sounds like you're not familiar with the $_POST
  array. $_POST is
  everything that *would be* after the ? in the url
  but as an array.

 In $_POST there is nothing in the URL , there is no ?.

   I'm wondering at this point if I should
   create a way to let users save their search
   parameters, by grabbing the variables and storing
 
  them
 
   as an array in the database or go back to the URL
   method.
 
  I don't see how these two things are similar.
  shrugs

 They are not similar but will accomplish the same
 goal.

  If you want to store your array in a db use
  serialize() and
  unserialize(). In any case I would just store the
  search criteria in a
  cookie and leave the db out of it.

 A ccokie wouldn't help me one bit in this situation.

 Stuart
Stuart,

Did you take the time to think about what you were going to do before starting 
your application? You are asking more than one question within this newest 
version of your thread and are treating people's responses to each individual 
question as part of one all encompassing answer.

If you are looking to have the SQL query string sent as POST vars but don't 
know how to get those out of the array, I would say you have some RTFMing to 
do, the same would go for sending the users to your results page AND ( you 
can do both POST and GET vars for a single page) adding a querystring to the 
url so that the user could bookmark the url and have a way to return to the 
same query they specified provided that the database query happens on/in the 
results page.

If that answers any of your questions, great, if not, try planning ahead a 
little instead of asking the list to write the functionality code for you.

-- 
Regards,
David Bevan

We could learn a lot from crayons: 
some are sharp, some are pretty, some are dull, some have weird names, 
and all are different colorsbut they all exist very nicely in the same 
box. 

http://www.getanyideas.com

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



Re[2]: [PHP] Database search logic question

2004-11-15 Thread Richard Davey
Hello Stuart,

Monday, November 15, 2004, 6:27:18 PM, you wrote:

SF In $_POST there is nothing in the URL , there is no ?.

Technically, there can be. You can post a form to x.php?foo=bar and it
will populate both the POST and GET super-globals.

  I'm wondering at this point if I should
  create a way to let users save their search
  parameters, by grabbing the variables and storing
 them
  as an array in the database or go back to the URL
  method.

SF They are not similar but will accomplish the same
SF goal.

Given than URLs change over time, surely it would make sense to save
the actual search parameters instead, so then you could re-build the
search even if the URL of it changed.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



RE: [PHP] Column Totals

2004-11-15 Thread Ben Miller
That did it perfectly.  Why don't any of the stupid books tell you that you
need the AS statement?

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]
Sent: Monday, November 15, 2004 11:16 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [PHP] Column Totals


[snip]
The following query seems to return an empty string, which should only
give
me the total for the entire column anyway.
$query = SELECT SUM(Revenue) FROM Sales WHERE Date='$Date';
[/snip]

$query = SELECT SUM(Revenue) AS Revenue FROM Sales WHERE Date='$Date';
note the AS statement-^

$foo = mysql_query($query, $connection);

$bar = mysql_fetch_array($foo);

echo $bar['Revenue']

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



Re: [PHP] Column Totals

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 11:21:45 -0700, Ben Miller [EMAIL PROTECTED] wrote:
 That did it perfectly.  Why don't any of the stupid books tell you that you
 need the AS statement?

Because they assumed you would access it just like you asked for it.

$bar['SUM(Revenue)']


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



RE: [PHP] Column Totals

2004-11-15 Thread Gryffyn, Trevor
Because you don't technically 'need' it, unless you're trying to
reference the results by column name and you're using an aggregate like
that. :)

And in most systems, you don't need the AS just a space and a new
name:

SELECT SUM(Revenue) Revenue FROM Sales Where.

But all depends on your style.  I don't think the SQL Server or Oracle
server I deal with care if you put the AS in there or not.  Again,
it's not required unless you're relying on a name coming back with the
result set, then you might want to be explict with an alias like that.

Also, when you use aggregates, remember that they'll they group the
non-aggregate functions based on uniqueness.  This will happen even if
you're not displaying the non-aggregate functions, so you may get
repeats of some things that you can get rid of by using SELECT DISTINCT
Sum(...

But if there's anything non-unique in what you're using in SELECT or
WHERE, it'll use that for grouping.  This includes the hours, minutes
and seconds in a date field sometimes.  If the query below worked for
you, then I guess it's enough for MySQL (is that what you're using?) but
in some systems it may not be and you may get every row in the database
non-SUM'd because the dates all have different seconds in the time.

In that case, you'd need to section out the day/month/year and compare
based on that or something.


Just some pitfalls to watch out for when you're not used to aggregates
and grouping.

-TG

 -Original Message-
 From: Ben Miller [mailto:[EMAIL PROTECTED] 
 Sent: Monday, November 15, 2004 1:22 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP] Column Totals
 
 
 That did it perfectly.  Why don't any of the stupid books 
 tell you that you
 need the AS statement?
 
 -Original Message-
 From: Jay Blanchard [mailto:[EMAIL PROTECTED]
 Sent: Monday, November 15, 2004 11:16 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: [PHP] Column Totals
 
 
 [snip]
 The following query seems to return an empty string, which should only
 give
 me the total for the entire column anyway.
 $query = SELECT SUM(Revenue) FROM Sales WHERE Date='$Date';
 [/snip]
 
 $query = SELECT SUM(Revenue) AS Revenue FROM Sales WHERE 
 Date='$Date';
 note the AS statement-^
 
 $foo = mysql_query($query, $connection);
 
 $bar = mysql_fetch_array($foo);
 
 echo $bar['Revenue']
 
 -- 
 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] newbie question

2004-11-15 Thread Max Krone
Hello all,

I am new to php programming and web programming in general. I have
created a php file that if it works will create a simple form for
inputing contact information and then once the submit button is
pressed, the information is saved into a MySQL database.

When I try to submit, I get no error messages, but no data goes into
the MySQL table. I have verified that my MySQL User and Password are
correct and I believe I am actually connecting to the database.

Please look at what I have created and tell me what I am doing wrong,
what I can do better, why I am an idiot, et .al.

Thanks,
Max

?php
if ($_POST[FirstName] == ) {
$display_block = h1Add an Entry/h1
form method=\post\ action=\$_SERVER[PHP_SELF]\
PstrongFirst/Last Names:/strongbr
input type=\text\ name=\FirstName\ size=30 maxlength=75
input type=\text\ name=\LastName\ size=30 maxlength=75

PstrongAddress:/strongbr
input type=\text\ name=\Address\ size=30

PstrongCity/State/Zip/strongbr
input type=\text\ name=\City\ size=30 maxlength=50
input type=\text\ name=\State\ size=5 maxlength=2
input type=\text\ name=\Zip\ size=10 maxlength=10

PstrongTelephone Number:/strongbr
input type=\text\ name=\phone\ size=30 maxlength=25

PstrongEmail Address:/strongbr
input type=\text\ name=\email\ size=30 maxlength=150

Pinput type=\submit\ name=\submit\ value=\Add Entry\/p
/FORM;

} else if ($_POST[FirstName] != ) {
//time to add to tables, so check for required fields
if (($_POST[FirstName] == ) || ($_POST[LastName] == ) ||
($_POST[city] == ) ||
  ($_POST[State] == ) || ($_POST[Zip] == ) || ($_POST[phone] == ) 
||
  ($_POST[email] == )) {
header(Location: addentry.php);
exit;
}

//connect to database
$conn = mysql_connect(localhost, user, password)
  or die(Failure to attach to database);
mysql_select_db(database, $conn) or die(Failure to attach to 
database);

//add to first and last name
$add_table = INSERT into table values (NULL, '$_POST[FirstName]', 
'$_POST[LastName], '$_POST[Address], '$_POST[City], 
'$_POST[State],
'$_POST[Zip], '$_POST[phone],'$_POST[email]);
mysql_query($add_table) or die(mysql_error());


}
?
HTML
HEAD
TITLEAdd an Entry/TITLE
/HEAD
BODY
?php echo $display_block; ?
/BODY
/HTML

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



RE: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
See inline:
--- Chris W. Parker [EMAIL PROTECTED] wrote:

 Stuart Felenstein mailto:[EMAIL PROTECTED]
 on Monday, November 15, 2004 1:10 AM said:
 
  The way I was approaching this was to grab the
 url,
  the part after the ? , so not the referer.
 
 This sounds like you're not familiar with the $_GET
 array. $_GET is
 everything after the ? in the url but as an array.

It sounds like you answered before you either read or
understood.  I was talking about 

$_SERVER[QUERY_STRING];


 This sounds like you're not familiar with the $_POST
 array. $_POST is
 everything that *would be* after the ? in the url
 but as an array.

In $_POST there is nothing in the URL , there is no ?.


  I'm wondering at this point if I should
  create a way to let users save their search
  parameters, by grabbing the variables and storing
 them
  as an array in the database or go back to the URL
  method.
 
 I don't see how these two things are similar.
 shrugs

They are not similar but will accomplish the same
goal.


 If you want to store your array in a db use
 serialize() and
 unserialize(). In any case I would just store the
 search criteria in a
 cookie and leave the db out of it.

A ccokie wouldn't help me one bit in this situation.  

Stuart
 

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



Re: [PHP] Column Totals

2004-11-15 Thread Jason Wong
On Tuesday 16 November 2004 02:21, Ben Miller wrote:
 That did it perfectly.  Why don't any of the stupid books tell you that you
 need the AS statement?

You don't *need* the AS. You just need to be aware that without the AS the 
query will return a column called 'SUM(columnname)'. The AS is for 
convenience and not mandatory.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Earth -- mother of the most beautiful women in the universe.
  -- Apollo, Who Mourns for Adonais? stardate 3468.1
*/

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



Re: [PHP] Column Totals

2004-11-15 Thread Robby Russell
On Mon, 2004-11-15 at 11:01 -0700, Ben Miller wrote:
 SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'

What happens when you do:

SELECT Revenue FROM Sales WHERE Date='$Date';

Make sure you're getting values back first..and then you can try to sum
them.

-Robby


-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
*--- Now supporting PHP5 ---
/


signature.asc
Description: This is a digitally signed message part


RE: [PHP] newbie question

2004-11-15 Thread Chris W. Parker
Greg Donald mailto:[EMAIL PROTECTED]
on Monday, November 15, 2004 11:08 AM said:

 ?php
 if ($_POST[FirstName] == ) {
 $display_block = h1Add an Entry/h1
 form method=\post\ action=\$_SERVER[PHP_SELF]\
 PstrongFirst/Last Names:/strongbr
 input type=\text\ name=\FirstName\ size=30 maxlength=75
 input type=\text\ name=\LastName\ size=30 maxlength=75
 
 It's trivial for a malicious attacker to bypass your maxlength, just
 an FYI.  You should check with strlen() after the post, or possibly
 look into javascript form validation.

Greg, I'm sure you already understand this but I just wanted to add to
your statement for those that may not.

Javascript should not be relied upon for data validation as a security
measure. It should merely be used as a convenience to the user (so they
don't have to wait for a page to reload just to see some error notices)
and to take load off the server (so the server does not have to process
a page 10 times while the customer refines their input to match your
criteria). Having said that, make sure to always have server side
validation in place even if you *do* in fact also use Javascript on the
client side.



Chris.

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



Re: [PHP] explode and PATH_SEPARATOR

2004-11-15 Thread Ryan King
On Nov 15, 2004, at 10:17 AM, Francisco M. Marzoa Alonso wrote:
Taking this code:
pre
?php
define (PATH_SEPARATOR, /);
$String=Root/One/Two/Three/Last;
$arr = explode ( PATH_SEPARATOR, $String );
var_dump ( $arr );
$arr = explode ( /, $String );
var_dump ( $arr );
?
/pre
PATH_SEPARATOR is is a predefined constant, so you'll need to use 
something else, but you still need to put quotes around it:

define('NOT_PATH_SEPARATOR', '/');
-ryan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein
See inline please:
--- David Bevan [EMAIL PROTECTED] wrote:

 Did you take the time to think about what you were
 going to do before starting 
 your application? 

Honestly , no I did not.  What I did start out with is
a belief that there wouldn't be a need to know php.  I
was using a RAD, that was sold as all encompassing. 
Fool me once.

 If you are looking to have the SQL query string sent
 as POST vars but don't know how to get those out of 
 the array, I would say you have some RTFMing to 
 do, the same would go for sending the users to your
 results page AND ( you can do both POST and GET vars
 for a single page)adding a querystring to the 
 url so that the user could bookmark the url and have
 a way to return to the same query they specified
 provided that the database query happens on/in the 
 results page.

Ok, I was not aware that both POST and GET can be used
at the same time.  
 
 If that answers any of your questions, great, if
 not, try planning ahead a 
 little instead of asking the list to write the
 functionality code for you.
 
Okay, so showing me how something works is now wrong ?
No one has shown you code or explained a better method
at some function ?

This particular post has went way passed its course. 
Thank you for your help.

Stuart

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



[PHP] Re: Date Conversions?

2004-11-15 Thread Matthew Weier O'Phinney
* Robert Sossomon [EMAIL PROTECTED]:
 I have a date in format YY-MM-DD in a MySQL table.  I need to pull it back to 
 display it in either format: MM-DD-YY or Month Day, Year format.

 I can't figure out how to write the query to do it, and am not sure
 how to make PHP just parse the one given and dump it back out in the
 way I need it.  Any suggestions?

http://php.net/strtotime

Specifically, try the following:

// $date is the date as pulled from the MySQL table
$convertedDate = date(m-d-y, strtotime($date));

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



[PHP] Date handling

2004-11-15 Thread Ryan
Hello,

I would like to find out the 'official' way to handle dates in PHP.  I am 
aware of the limits on a Unix timestamp, but I am writing a financial 
application that needs to deal with dates both before 1970 and after 2038 
and of course have run into problems when trying to format those dates using 
the date() and strftime() functions.  This of course then also impacts 
Smarty as Smarty's date_format modifier is just a wrapper around strftime().

I am looking at the PEAR Date module and that seems to resolve these issues, 
but I would like to know if that is the standard/official way to handle 
dates in PHP applications as in my application, I would like to have one 
handler for dates, rather than separate code for dates within the Unix 
timestamp range and for dates outside - so if I switch to PEAR Date, I will 
use it everywhere in my code since I cannot take any chance of using date() 
or strftime() and possibly getting invalid data.

Additionally, are there any plans to make an official PHP date extension 
that handles dates outside a Unix timestamp range as something built into 
the language itself rather than as a '3rd party extension' which the PEAR 
Date module appears to be since it's not in the core PHP language?

Thanks,
Ryan

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



Re: [PHP] newbie question

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 10:26:43 -0800, Max Krone [EMAIL PROTECTED] wrote:
 When I try to submit, I get no error messages, but no data goes into
 the MySQL table. I have verified that my MySQL User and Password are
 correct and I believe I am actually connecting to the database.
 
 Please look at what I have created and tell me what I am doing wrong,
 what I can do better, why I am an idiot, et .al.
 
 ?php
 if ($_POST[FirstName] == ) {
 $display_block = h1Add an Entry/h1
 form method=\post\ action=\$_SERVER[PHP_SELF]\
 PstrongFirst/Last Names:/strongbr
 input type=\text\ name=\FirstName\ size=30 maxlength=75
 input type=\text\ name=\LastName\ size=30 maxlength=75

It's trivial for a malicious attacker to bypass your maxlength, just
an FYI.  You should check with strlen() after the post, or possibly
look into javascript form validation.

 PstrongAddress:/strongbr
 input type=\text\ name=\Address\ size=30
 
 PstrongCity/State/Zip/strongbr
 input type=\text\ name=\City\ size=30 maxlength=50
 input type=\text\ name=\State\ size=5 maxlength=2
 input type=\text\ name=\Zip\ size=10 maxlength=10
 
 PstrongTelephone Number:/strongbr
 input type=\text\ name=\phone\ size=30 maxlength=25
 
 PstrongEmail Address:/strongbr
 input type=\text\ name=\email\ size=30 maxlength=150
 
 Pinput type=\submit\ name=\submit\ value=\Add Entry\/p
 /FORM;
 
 } else if ($_POST[FirstName] != ) {
 //time to add to tables, so check for required fields
 if (($_POST[FirstName] == ) || ($_POST[LastName] == ) ||
 ($_POST[city] == ) ||
   ($_POST[State] == ) || ($_POST[Zip] == ) || ($_POST[phone] == 
 ) ||
   ($_POST[email] == )) {
 header(Location: addentry.php);
 exit;
 }
 
 //connect to database
 $conn = mysql_connect(localhost, user, password)
   or die(Failure to attach to database);
 mysql_select_db(database, $conn) or die(Failure to attach to 
 database);
 
 //add to first and last name
 $add_table = INSERT into table values (NULL, '$_POST[FirstName]',
 '$_POST[LastName], '$_POST[Address], '$_POST[City], 
 '$_POST[State],
 '$_POST[Zip], '$_POST[phone],'$_POST[email]);

You're missing the closing single quote on most all the $_POST variables.

 mysql_query($add_table) or die(mysql_error());

How about:

or die(mysql_error() . ' query was: ' . $add_table)

so you can see your query as it goes to the database.

 
 }
 ?
 HTML
 HEAD
 TITLEAdd an Entry/TITLE
 /HEAD
 BODY
 ?php echo $display_block; ?
 /BODY
 /HTML

Also, your code is subject to SQL injection.  You might want to
investigate PHP's addslashes() function.  And maybe read this too:

http://shiflett.org/php-security.pdf


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] saving blobs to file system

2004-11-15 Thread Merlin
Hi there,
I do have images inside a blob field which I would like to save to the hard 
drive. Now I cant find a fuction in saving the file. Usually I retrieve the data 
out of the blob, and output a header before echoing the data.

Basicly I do have the image now saved inside a string and I would need to write 
that to a file. At least I guess this could work.

Has anybody an idea how to do that, I am kind of lost here.
Thanx for any help,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Date Conversions?

2004-11-15 Thread Mike Johnson
From: Robert Sossomon [mailto:[EMAIL PROTECTED] 

 I have a date in format YY-MM-DD in a MySQL table.  I need to 
 pull it back to display it in either format: MM-DD-YY or 
 Month Day, Year format.
 
 I can't figure out how to write the query to do it, and am 
 not sure how to make PHP just parse the one given and dump it 
 back out in the way I need it.  Any suggestions?

I don't know how well PHP would handle the 2-digit year concept, so you
might be better off doing it in the query. Something like this:

SELECT DATE_FORMAT(date_field, '%m-%d-%y') AS date_format_1,
DATE_FORMAT(date_field, '%M %e, %y') AS date_format_2...

HTH!


-- 
Mike Johnson Smarter Living, Inc.
Web Developerwww.smarterliving.com
[EMAIL PROTECTED]   (617) 886-5539

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



Re: [PHP] Date Conversions?

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 14:29:59 -0500, Robert Sossomon
[EMAIL PROTECTED] wrote:
 I have a date in format YY-MM-DD in a MySQL table.  I need to pull it back to
 display it in either format: MM-DD-YY or Month Day, Year format.
 
 I can't figure out how to write the query to do it, and am not sure how to 
 make
 PHP just parse the one given and dump it back out in the way I need it.  Any
 suggestions?

In PHP you can take it apart and put it back together.

$date = explode('-', $array['date']);

If it's an actual date or time field in MySQL, you can use
date_format() to reformat it in the query and skip the PHP.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Re: PHP postfix mail problem no recipient problem on SUSE 9.1

2004-11-15 Thread Chris W
Manuel Lemos wrote:
Yes you did but I don't remember you asking to se the php.ini file.  It 

I said: It is hard to guess it right without seeing the actual 
configuration.
I guess I missed that part, while looking into the other code you 
mentioned in your post.


; For Unix only.  You may supply arguments as well (default: sendmail 
-t -i).
sendmail_path = /usr/sbin/sendmail

I think your problem is that the -t switch is missing. That would make 
sendmail read the addresses from the message headers, which seems to be 
the problem.
That appears to have fixed that problem.  I am confused as to why you 
needed to see that one line of the php.ini file before you could make 
the suggestion to add the -t.  Now that I Know what the -t option is 
for, that would be the first thing I would suggest if I hear of someone 
getting the same errors.  Any way thanks for the help.

Chris W
Gift Giving Made Easy
Get the gifts you want  give the
gifts they want this holiday season
http://thewishzone.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: PHP file permission

2004-11-15 Thread Scott Fletcher
Rule of thumb.  set the file permission to 644 for all files execpt the
directory, the directory folder would be 755.  Most executable files can
safely be set to 644 but if your machine or web browser can't run the file
then change permission for that file from 644 to 555.  Why 644 in the first
place, it is to protect the end user from something like virus, spyware,
etc...

Scott

Jerry Swanson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 regular php page, some mysql queries and print html on the screen.



 On Sun, 14 Nov 2004 18:19:28 +0100, M. Sokolewicz [EMAIL PROTECTED] wrote:
  depends on what you need it for
 
 
 
  Jerry Swanson wrote:
 
   What is the optimal PHP file permission?
 
  --
  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] unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread Scott Fletcher
I found that on most web browsers, I can not upload the folder via HTTP
using hte web browser upload dialog box.  So, I can't use the php's
function, is_uploaded_file and move_uploaded_file.  Because the web browser
see the folder as something to open with, like going down one directory.
So, any advice or suggestion??

Thanks,
 Scott

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



[PHP] London - One Day Workshop How to Build a Professional Database-Driven Website

2004-11-15 Thread Ryan Carson
Hey everyone,

We're running a one-day practical workshop, in London UK, that will give you 
everything you need to build a powerful
enterprise-level, database-driven website - focusing on PHP, Apache and MySQL. 
Find out how to plan the project, design the
database, structure the code, develop and test the site, deploy it effectively, 
promote it professionally and maintain it
efficiently.

Read more at www.carsonworkshops.com

Hope to see you there,
Ryan

--
Ryan Carson | Carson Systems   | www.carsonsystems.com
| Carson Workshops | www.carsonworkshops.com
| FlightDeck   | www.flightdeck-online.com
| BD4D.com | www.bd4d.com
--
Telephone   | +44 (0) 1225 859 835
Mobile  | +44 (0) 79688 10 253
Email   | [EMAIL PROTECTED]
Address | Vale View Studios, 9 Vale View, Bath BA1 7RH, UK
--
This message and any files attached are confidential and intended solely for 
the use of the individual or entity to whom they are
addressed. If you have received this message in error please notify Carson 
Systems Ltd. If you are not the named recipient you
should not disseminate, distribute or copy this message.

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



[PHP] Session file not written *solved*, but session variables *still* messed up.

2004-11-15 Thread Rodolfo Gonzalez Gonzalez
On Fri, 12 Nov 2004, Klaus Reimer wrote:
 Rodolfo wrote:
  The weirdness comes when in one frame the script will print Agent Smith
  while in the other frame of the same frameset the script which loads on it
  will print Thomas Anderson...

 On the other hand: Have you checked that your disk has enough room for
 more sessions? Maybe you are working on the bleeding edge of your
 harddisk capacity.

Hi,

I found the cause for this message:

---
Nov 15 12:22:02 http2 httpd: PHP Warning:  Unknown(): Failed to write
session data (files). Please verify that the current setting of
session.save_path is correct (/var/tmp/php) in Unknown on line 0
---

this is the cause:

---
Nov 15 12:22:02 http2 httpd: PHP Warning:  Unknown(): The session id
contains invalid characters, valid characters are only a-z, A-Z and 0-9 in
Unknown on line 0
---

and the configuration lines which cause these messages, are, IMO, these:

---
session.entropy_length = 16
session.entropy_file = /dev/urandom
---

Maybe some PHP or Zend guru could confirm this?.

On the other hand, it is still not clear why different session data is
appearing in different frames. Could some cache software (ie. Squid) being
messing up the cookies?, or maybe MMCache? :S

Thanks.

Regards,
Rodolfo.

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



[PHP] Re: unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread Scott Fletcher
Um, can't be done.  So, I'll have to use JAVA instead.  Have anyone ever
done this, does anyone know of a good freeware JAVA applet that I can use?

Thanks,
 Scott

Scott Fletcher [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I found that on most web browsers, I can not upload the folder via HTTP
 using hte web browser upload dialog box.  So, I can't use the php's
 function, is_uploaded_file and move_uploaded_file.  Because the web
browser
 see the folder as something to open with, like going down one directory.
 So, any advice or suggestion??

 Thanks,
  Scott

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



Re: [PHP] Re: Date Conversions?

2004-11-15 Thread Robert Sossomon
Matthew Weier O'Phinney is quoted as saying on 11/15/2004 3:01 PM:
* Robert Sossomon [EMAIL PROTECTED]:
SNIP
http://php.net/strtotime
Specifically, try the following:
// $date is the date as pulled from the MySQL table
$convertedDate = date(m-d-y, strtotime($date));
Here's what I wound up using, in case anyone else comes across the same 
dilemma:
$Date = $Quote['Date'];
$EDate = date(M d, Y,strtotime($Date));

--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Date Conversions?

2004-11-15 Thread Robert Sossomon
I have a date in format YY-MM-DD in a MySQL table.  I need to pull it back to 
display it in either format: MM-DD-YY or Month Day, Year format.

I can't figure out how to write the query to do it, and am not sure how to make 
PHP just parse the one given and dump it back out in the way I need it.  Any 
suggestions?

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] saving blobs to file system

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 21:12:25 +0100, Merlin [EMAIL PROTECTED] wrote:
 Hi there,
 
 I do have images inside a blob field which I would like to save to the hard
 drive. Now I cant find a fuction in saving the file. Usually I retrieve the 
 data
 out of the blob, and output a header before echoing the data.
 
 Basicly I do have the image now saved inside a string and I would need to 
 write
 that to a file. At least I guess this could work.
 
 Has anybody an idea how to do that, I am kind of lost here.

Write the data to a file with a proper filename.  I'd use fopen(),
fwrite(), and fclose, or file_put_contents() if your PHP is new
enough.  You won't need to output any headers, they only matter when
you render the file in an application such as a web client.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



RE: [PHP] Database search logic question

2004-11-15 Thread Gryffyn, Trevor
  Did you take the time to think about what you were
  going to do before starting your application? 
 
 Honestly , no I did not.  What I did start out with is
 a belief that there wouldn't be a need to know php.  I
 was using a RAD, that was sold as all encompassing. 
 Fool me once.

Yeah, that's always fun.  You think you're getting something close to
what you want, maybe with some tweaking, and what you end up with is
really a giant spaghetti tangle of unusable code that you have no choice
but to hack enough to get a functional product. Or re-write the
whole thing by hand.

Don't worry..  Questions are good, but do your best to untangle what you
can, get all your questions together and hit the web sites and mailing
lists.  The more research you do and more helping yourself you do, the
less RTFM and othe responses similar to what you got above.

But hell...  It's not like the rest of us have never ended up neck-deep
in a mess that we needed as much help as we could get to untangle.  

  If you are looking to have the SQL query string sent
  as POST vars but don't know how to get those out of 
  the array, I would say you have some RTFMing to 
  do, the same would go for sending the users to your
  results page AND ( you can do both POST and GET vars
  for a single page)adding a querystring to the 
  url so that the user could bookmark the url and have
  a way to return to the same query they specified
  provided that the database query happens on/in the 
  results page.
 
 Ok, I was not aware that both POST and GET can be used
 at the same time.  

Yeah, you can do that.   GET requests are just where the info is passed
via the URL.  You don't even need a FORM to do GET variables.   Just
do  scriptname.php?getvar1=Testgetvar2=Test2   Then use
$_GET[getvar1] or whatever you named them.

You can also use $_REQUEST[] to get any data put into $_GET, $_POST or
$_COOKIE (superceding in that order I believe.. That is, it gets all the
GET data first, and if there's a POST variable of the same name, it
overwrites the GET version... And COOKIE overwrites POST).


  If that answers any of your questions, great, if
  not, try planning ahead a little instead of asking the
  list to write the functionality code for you.

 Okay, so showing me how something works is now wrong ?
 No one has shown you code or explained a better method
 at some function ?
 
 This particular post has went way passed its course. 
 Thank you for your help.


Probably...Understand that there are a lot of people on here who
post a lot of responses and help a lot of people and they have bad days
just like everyone else.  So while you ask for patience and
consideration for your questions, be sure to show some patience and
consideration for those who bother to respond.  It's a two-way street.

I mean, if people got nasty every time someone asked a question that was
answered with YOU HAVE REGISTER GLOBALS TURNED OFF NOW!! or other
questions that we all probably ran into when we were starting out
ourselves, then we'd have a lot of flaming going on here.


This is a PHP General mailing list, it should be for general, newbie,
etc sort of questions.  But the expectation is that the questions being
asked were researched some ahead of time as well.  Although that's not
always an option and that needs to be understood as well.


Good luck, Stuart.

-TG

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



Re: [PHP] unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread Marek Kilimajer
Scott Fletcher wrote:
I found that on most web browsers, I can not upload the folder via HTTP
using hte web browser upload dialog box.
Most? I thought all.
So, I can't use the php's
function, is_uploaded_file and move_uploaded_file.  Because the web browser
see the folder as something to open with, like going down one directory.
So, any advice or suggestion??
Zip it up. Or signed applets or activex objects
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] saving blobs to file system

2004-11-15 Thread Marek Kilimajer
Merlin wrote:
Hi there,
I do have images inside a blob field which I would like to save to the 
hard drive. Now I cant find a fuction in saving the file. Usually I 
retrieve the data out of the blob, and output a header before echoing 
the data.

Basicly I do have the image now saved inside a string and I would need 
to write that to a file. At least I guess this could work.

Has anybody an idea how to do that, I am kind of lost here.
fwrite()
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread John Holmes
 From: Scott Fletcher [EMAIL PROTECTED]

 I found that on most web browsers, I can not upload the
 folder via HTTP using hte web browser upload dialog box. 
 So, I can't use the php's function, is_uploaded_file and 
 move_uploaded_file. Because the web browser see the folder
 as something to open with, like going down one directory.
 So, any advice or suggestion??

You can't upload folders over HTTP, only files. 

---John Holmes...

UCCASS - PHP Survey System
http://www.bigredspark.com/survey.html


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

[PHP] Re: PHP postfix mail problem no recipient problem on SUSE 9.1

2004-11-15 Thread Manuel Lemos
Hello,
On 11/15/2004 06:25 PM, Chris W wrote:
; For Unix only.  You may supply arguments as well (default: 
sendmail -t -i).
sendmail_path = /usr/sbin/sendmail

I think your problem is that the -t switch is missing. That would make 
sendmail read the addresses from the message headers, which seems to 
be the problem.

That appears to have fixed that problem.  I am confused as to why you 
needed to see that one line of the php.ini file before you could make 
the suggestion to add the -t.  Now that I Know what the -t option is 
for, that would be the first thing I would suggest if I hear of someone 
getting the same errors.  Any way thanks for the help.
Actually, I only realized that -t or -i could be missing after noticing 
that is what the default value mentioned in the comment line above. I 
recall somebody complaining about a similar problem and somebody else 
suggesting that the php.ini needed to be fixed but I do not remember 
anybody mentioning explicitly that -t was important.

Anyway, the mail() function is prone to many problems that may or may 
not be due to configuration problems other than this that you only know 
what may be the reason only you pass by the problems.

Personally I avoid using the mail() function because of these headaches 
and use my own classes that inject messages directly the local MTA queue 
so I do not have to wonder much.

--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: PHP file permission

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 15:26:56 -0500, Scott Fletcher [EMAIL PROTECTED] wrote:
 Why 644 in the first
 place, it is to protect the end user from something like virus, spyware,
 etc...

I fail to see how the specific file permissions of a PHP script that
is executed by the web server software has anything to do with
protecting the end user from a virus or from spyware.  The execution
of a PHP script begins and ends on the web server.  The output is sent
to the requester for rendering, not further execution.

Can you please explain a bit more?


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



RE: [PHP] Database search logic question

2004-11-15 Thread Stuart Felenstein

--- Gryffyn, Trevor [EMAIL PROTECTED]
wrote:


 This is a PHP General mailing list, it should be for
 general, newbie,
 etc sort of questions.  But the expectation is that
 the questions being
 asked were researched some ahead of time as well. 
 Although that's not
 always an option and that needs to be understood as
 well.
 
 
 Good luck, Stuart.
 
 -TG
Thank you Trevor.  Your words will be well heeded. 
Your effort and response is greatly appreciated.  I'm
going to make a better effort going forward before
turning to the list for quick answers.

I've received  many great answers and explanations
here.  All have been appreciated , and I hope used for
the betterment of right now, at least my
understanding.

Stuart

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



Re: [PHP] London - One Day Workshop How to Build a Professional Database-Driven Website

2004-11-15 Thread Ryan A
SPAM


 Hey everyone,



 We're running a one-day practical workshop, in London UK, that will give
you everything you need to build a powerful
 enterprise-level, database-driven website - focusing on PHP, Apache and
MySQL. Find out how to plan the project, design the
 database, structure the code, develop and test the site, deploy it
effectively, promote it professionally and maintain it
 efficiently.

 Read more at www.carsonworkshops.com

 Hope to see you there,
 Ryan

 --
 Ryan Carson | Carson Systems   | www.carsonsystems.com
 | Carson Workshops | www.carsonworkshops.com
 | FlightDeck   | www.flightdeck-online.com
 | BD4D.com | www.bd4d.com
 --
 Telephone   | +44 (0) 1225 859 835
 Mobile  | +44 (0) 79688 10 253
 Email   | [EMAIL PROTECTED]
 Address | Vale View Studios, 9 Vale View, Bath BA1 7RH, UK
 --
 This message and any files attached are confidential and intended solely
for the use of the individual or entity to whom they are
 addressed. If you have re

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



Re: [PHP] unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread Scott Fletcher
Um, look like I'm going to have to write a JAVA programming and have a
couple of friends to come to help me out with it.   Suck though!  So,
applets it is...

Zip it up, that gonna be tought because of lack of good cross-platform
support.  We have Robo-Help for Windows, since windows zip only work for
windows then I http it over to AIX and have php extract it.  So, does the
GNU zip work for that or not?  Probably not too well.  So, applet is the way
to go.  It will also help me to avoid the need for the su or sudo command
cause it doesn't work through Apache account too well.

Thanks,
 Scott



Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Scott Fletcher wrote:
  I found that on most web browsers, I can not upload the folder via HTTP
  using hte web browser upload dialog box.

 Most? I thought all.

  So, I can't use the php's
  function, is_uploaded_file and move_uploaded_file.  Because the web
browser
  see the folder as something to open with, like going down one directory.
  So, any advice or suggestion??

 Zip it up. Or signed applets or activex objects

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



Re: [PHP] Date handling

2004-11-15 Thread Ryan King
On Nov 15, 2004, at 2:05 PM, Ryan wrote:
Hello,
I would like to find out the 'official' way to handle dates in PHP.
There are many paths, choose the one best for you. :-)
I am looking at the PEAR Date module and that seems to resolve these 
issues,
but I would like to know if that is the standard/official way to handle
dates in PHP applications as in my application, I would like to have 
one
handler for dates, rather than separate code for dates within the Unix
timestamp range and for dates outside - so if I switch to PEAR Date, I 
will
use it everywhere in my code since I cannot take any chance of using 
date()
or strftime() and possibly getting invalid data.
I don't believe there is a standard way to do anything in php. I'd say 
if you find that it works for you, use it. I've used the PEAR Date 
package myself and it has worked in every case that I needed it.

Additionally, are there any plans to make an official PHP date 
extension
that handles dates outside a Unix timestamp range as something built 
into
the language itself rather than as a '3rd party extension' which the 
PEAR
Date module appears to be since it's not in the core PHP language?
I believe I've heard rumors of this for php5.1. You might want to dig 
through the php-internals archive to find out for sure.

Thanks,
Ryan
You're welcome,
ryan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Atom 2 RSS Script? Anyone got one?

2004-11-15 Thread Thomas Goyne
On Sun, 14 Nov 2004 16:48:57 +0100 Nick Wilson [EMAIL PROTECTED]
wrote:
hi all,
im all tired out of searching, just cant seem to find a script that will
convert atom 0.3 to any rss format. Does anyone have one or know where i
can get hold of one?
?xml version=1.0 encoding=UTF-8?
xsl:stylesheet version=1.0
xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
xmlns:atom=http://purl.org/atom/ns#;
xmlns:dc=http://purl.org/dc/elements/1.1/;
xsl:output cdata-section-elements=description /
xsl:output method=xml version=1.0 encoding=UTF-8 indent=yes/
xsl:template match=atom:[EMAIL PROTECTED]'0.3']
xsl:element name=rss
xsl:attribute name=version2.0/xsl:attribute
xsl:element name=channel
xsl:apply-templates select=atom:title/
xsl:apply-templates select=atom:[EMAIL PROTECTED]'text/html']/@href/
xsl:element name=description
xsl:value-of select=atom:tagline/
/xsl:element
xsl:apply-templates select=atom:modified/
xsl:element name=docshttp://backend.userland.com/rss/xsl:element
xsl:apply-templates select=atom:entry/
/xsl:element
/xsl:element
/xsl:template
xsl:template match=atom:entry
xsl:element name=item
xsl:apply-templates select=atom:title/
xsl:apply-templates select=atom:[EMAIL PROTECTED]'text/html']/@href/
xsl:element name=guid
xsl:attribute name=isPermaLinkfalse/xsl:attribute
xsl:value-of select=atom:id/
/xsl:element
xsl:apply-templates select=atom:modified/
xsl:element name=description
xsl:choose
xsl:when test=atom:[EMAIL PROTECTED]'escaped']
xsl:value-of select=atom:content disable-output-escaping=yes/
/xsl:when
xsl:otherwise
xsl:copy-of select=atom:content/*/
/xsl:otherwise
/xsl:choose
/xsl:element
/xsl:element
/xsl:template
xsl:template match=atom:title
xsl:element name=title
xsl:value-of select=./
/xsl:element
/xsl:template
xsl:template match=atom:[EMAIL PROTECTED]'text/html']/@href
xsl:element name=link
xsl:value-of select=./
/xsl:element
/xsl:template
xsl:template match=atom:modified
xsl:element name=dc:date
xsl:value-of select=./
/xsl:element
/xsl:template
/xsl:stylesheet
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
http://www.smempire.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Error when I try to display 20 records per page

2004-11-15 Thread Scott McWhite
Hi,

 

I’m using an HTML search form that passes the “searchterm” to a php file.

In my case the “searchterm” can have 1000s of records in my database, so I
implemented a limit which displays 20 records per page.  The pagination
function works fine with one exception.  Example of my problem: searchterm
typed in the html search form equals “ford”, in the database there are 2000
fords, the first page displays 20 fords and then the next page forgets that
we are searching “fords” and displays the equivalent to a wildcard “%”

search and displays accordingly.  

 

Does anyone have sample code for using an HTML search form with pagination?

Generally what I’m trying to do is type a “searchterm” on the html search
page, have the php file run the query and if it is an item that has many
results to display it 20 records per page without it displaying every record
in the database.

 

Error.

 

Notice: Undefined index: searchterm in
C:\Inetpub\cars\search\my_php_file.php on line 2

Notice: Undefined index: searchterm1 in
C:\Inetpub\cars\search\my_php_file.php on line 3

Notice: Undefined index: searchterm2 in
C:\Inetpub\cars\search\my_php_file.php on line 4

 

 

My php file. 

 

?php 

$searchterm=$_POST['searchterm'];

$searchterm1=$_POST['searchterm1'];

$searchterm2=$_POST['searchterm2'];

 

$searchterm = addslashes($searchterm);

$searchterm1 = addslashes($searchterm1);

$searchterm2 = addslashes($searchterm2);

 

 

@mysql_pconnect(localhost, root, ) or die(error -- can't connectto
server);

@mysql_select_db(list) or die (error -- can't connect to DB);

 

 

if(!isset($_GET['page'])){

$page = 1;

} else {

$page = $_GET['page'];

}

 

// Define the number of results per page

$max_results = 20;

 

// Figure out the limit for the query based

// on the current page number.

$from = (($page * $max_results) - $max_results);

 

// Perform MySQL query on only the current page number's results

 

$sql  = select * from parts where .'model'. like '%.$searchterm.%' AND
.'seller'. like '%.$searchterm1.%' AND .'description'. like
'%.$searchterm2.%' ORDER BY 'model', 'price', 'quantity' LIMIT $from,
$max_results;

 

echo 'body bgcolor=#dfefff';

 

$result = mysql_query($sql) or die(mysql_error());

$numofrows = mysql_num_rows($result);

echo TABLE BORDER=\0\\n;

echo TR bgcolor=\3366cc\TD align=leftfont color=\FF\
face=\Verdana\ size=\1\bSeller/TD/font/b/TDTD
align=leftfont color=\FF\ face=\Verdana\ size=\1\bModel
Number/TD/font/bTD align=leftfont color=\FF\ face=\Verdana\
size=\1\bManufacturer/TD/font/bTD align=leftfont
color=\FF\ face=\Verdana\
size=\1\bDescription/TD/font/bTD align=leftfont
color=\FF\ face=\Verdana\ size=\1\bQuantity/TD/font/bTD
align=leftfont color=\FF\ face=\Verdana\
size=\1\bPrice/TD/font/bTD align=leftfont color=\FF\
face=\Verdana\ size=\1\bCondition/TD/font/bTD align=leftfont
color=\FF\ face=\Verdana\ size=\1\bEmail
Address/TD/font/bTD align=leftfont color=\FF\
face=\Verdana\ size=\1\bAIM/TD/font/b/TR\n;

for($i = 0; $i  $numofrows; $i++) {

$row = mysql_fetch_array($result); //get a row from our result set

if($i % 2) { //this means if there is a remainder

echo TR bgcolor=\eaeaea\\n;

} else { //if there isn't a remainder we will do the else

echo TR bgcolor=\d5eaff\\n;

}

echo TD align=leftfont color=\80\ face=\Verdana\
size=\1\b.$row['seller']./a/TD/font/b/aTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['model']./TD/font/bTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['manufacturer']./TD/font/bTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['description']./TD/font/bTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['quantity']./TD/font/bTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['price']./TD/font/bTD align=leftfont
color=\80\ face=\Verdana\
size=\1\b.$row['condition']./TD/font/bTD align=lefta
href=\mailto:.$row['email'].\font color=\80\ face=\Verdana\
size=\1\b.$row['email']./TD/font/bTD align=lefta
href=\aim:goim?message=Hi.+Are+you+there?screenname=.$row['aim'].\fon
t color=\80\ face=\Verdana\ size=\1\bAIM
Link/TD/font/a\n;

echo /TR\n;

}

//now let's close the table and be done with it

echo /TABLE\n;

 

while($row = mysql_fetch_array($result)){

// Build your formatted results here.

$variable1=$row[manufacturer];

$variable2=$row[seller]; 

$variable3=$row[model]; 

$variable4=$row[description];

$variable5=$row[email];

 

//results

 

print (tr);

print (td class='body_1'$variable1/td);

print (td class='body_1'$variable2/td); 

print (td class='body_1'$variable3/td); 

print (td class='body_1'$variable4/td);

print (td class='body_1' style='border-right: 0px;'$variable5/td); 

print (/tr); 

}

 

 

// Figure out the total number of results in DB:

$total_results = mysql_result(mysql_query(SELECT COUNT(*) as Num FROM parts
where .'model'. like '%.$searchterm.%' AND .'seller'. like
'%.$searchterm1.%' AND .'description'. like 

Re: [PHP] Error when I try to display 20 records per page

2004-11-15 Thread James Kaufman
On Mon, Nov 15, 2004 at 06:56:45PM -0600, Scott McWhite wrote:
 Hi,
 
  
 
 I'm using an HTML search form that passes the searchterm to a php file.
 
 In my case the searchterm can have 1000s of records in my database, so I
 implemented a limit which displays 20 records per page.  The pagination
 function works fine with one exception.  Example of my problem: searchterm
 typed in the html search form equals ford, in the database there are 2000
 fords, the first page displays 20 fords and then the next page forgets that
 we are searching fords and displays the equivalent to a wildcard %
 search and displays accordingly.  
 
 Does anyone have sample code for using an HTML search form with pagination?
 
 Error.
 
 Notice: Undefined index: searchterm in
 C:\Inetpub\cars\search\my_php_file.php on line 2
 
 Notice: Undefined index: searchterm1 in
 C:\Inetpub\cars\search\my_php_file.php on line 3
 
 Notice: Undefined index: searchterm2 in
 C:\Inetpub\cars\search\my_php_file.php on line 4
 
 My php file. 
 
 ?php 
 $searchterm=$_POST['searchterm'];
 $searchterm1=$_POST['searchterm1'];
 $searchterm2=$_POST['searchterm2'];
 
 $searchterm = addslashes($searchterm);
 $searchterm1 = addslashes($searchterm1);
 $searchterm2 = addslashes($searchterm2);
  
 // Previous Link
 
 if($page  1){
 $prev = ($page - 1);
 echo a href=\.$_SERVER['PHP_SELF'].?page=$prev\Previous/anbsp;;
 }
 
  ...snip...

 Thank you,
 
  
 
 Scott
 

Start with the first error message:

 Notice: Undefined index: searchterm in
 C:\Inetpub\cars\search\my_php_file.php on line 2
 

Then look at line 2:
 $searchterm=$_POST['searchterm'];

This indicates that $_POST['searchterm'] is undefined. Why isn't it defined?
In order to show up in the $_POST array, it would have to be POSTED, ie you
could put it into a hidden field that could show up after the user pressed a
Submit button.

However, it doesn't appear that you are doing that. (Either that, or I snipped
too much off your original post!)  You have Previous and Next hyperlinks, each
of which passes the page number in the query string. Perhaps you could also
pass the searchterm(s) in the query string. Or, you could store them in the
$_SESSION array. If you do this, be sure to start the session.

-- 
Jim Kaufman
Linux Evangelist
public key 0x6D802619

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



Re: [PHP] Date handling

2004-11-15 Thread Justin French
On 16/11/2004, at 7:05 AM, Ryan wrote:
I would like to find out the 'official' way to handle dates in PHP.  I 
am
aware of the limits on a Unix timestamp, but I am writing a financial
application that needs to deal with dates both before 1970 and after 
2038
and of course have run into problems when trying to format those dates 
using
the date() and strftime() functions.  This of course then also impacts
Smarty as Smarty's date_format modifier is just a wrapper around 
strftime().
End of the day, you need to choose something which works for you.  
There's no right answer, but there's some good answers :)

I store everything in GMT.  If I need to know more about the timezone 
of the object, I'll either store the local time, or the offset from 
GMT.  I choose to store everything as a MySQL DATETIME (-MM-DD 
HH:II:SS), because it's human readable, easy to convert to a unix 
stamp, and more portable across platforms (eg Windows), although it 
does use a few extra bytes.

It's also important to note that (at least for Unix) Unix timestamps do 
work pre-1970... they are just a negative integer, so you need to allow 
for signed integers in your database if that's the format you choose to 
use.

I've spent a lot of time working with dates and times, trying to 
understand it all and come up with a solid process.  You need to really 
read the manuals and understand what you're storing, and what you're 
doing with functions like date() which assumes a GMT stamp, but outputs 
a TZ-corrected date.

I am looking at the PEAR Date module and that seems to resolve these 
issues,
but I would like to know if that is the standard/official way to handle
dates in PHP applications as in my application, I would like to have 
one
handler for dates, rather than separate code for dates within the Unix
timestamp range and for dates outside - so if I switch to PEAR Date, I 
will
use it everywhere in my code since I cannot take any chance of using 
date()
or strftime() and possibly getting invalid data.

I've never worked with the PEAR modules, but my recommendation is this:
- store everything as GMT, and store an offset if needed, and 
understand what it is you're storing
- transport your dates in your scripts as GMT as long as possible (this 
is what date() and strftime() expect anyway)
- understand when you want to use date(), and when you really want 
gmdate()
- write some wrapper functions which you understand implicitly, so that 
you can deal with your data in a way which makes sense to you

The catch here is if you use Windows for either development or 
production.  I have zero experience with this platform, and don't know 
how much of my knowledge applies in that situation.

Feel free to ask a detailed question to get a detailed answer :)
Justin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Date handling

2004-11-15 Thread Ryan
Hi Justin,

Thanks for your reply.  Actually the main issue that I'm running into is
that I cannot get Unix timestamps before 1970.  I'm running on Red Hat
Enterprise Linux (kernel 2.4.21-20.EL).  If I run:

?php
echo strtotime('1950-01-01');
?


the script outputs -1, which then of course translates to 1969-12-31.
According to http://us2.php.net/strtotime, it says ... dates prior to Jan
1, 1970 will not work on Windows, some Linux distributions, and a few other
operating systems.

I'm guessing Red Hat Enterprise or at least the kernel I'm using (which is
the latest RH kernel) qualifies under the Linux category above.  Also, with
the application I'm writing, I need to deal with dates after 2038 too.  So
that is why I'm investigating alternatives - just because I'd like something
that would definitely work on any platform and is 'official' as much as
possible - rather than have my date handling be OS-specific.

Thanks,
Ryan


Justin French [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On 16/11/2004, at 7:05 AM, Ryan wrote:

  I would like to find out the 'official' way to handle dates in PHP.  I
  am
  aware of the limits on a Unix timestamp, but I am writing a financial
  application that needs to deal with dates both before 1970 and after
  2038
  and of course have run into problems when trying to format those dates
  using
  the date() and strftime() functions.  This of course then also impacts
  Smarty as Smarty's date_format modifier is just a wrapper around
  strftime().

 End of the day, you need to choose something which works for you.
 There's no right answer, but there's some good answers :)

 I store everything in GMT.  If I need to know more about the timezone
 of the object, I'll either store the local time, or the offset from
 GMT.  I choose to store everything as a MySQL DATETIME (-MM-DD
 HH:II:SS), because it's human readable, easy to convert to a unix
 stamp, and more portable across platforms (eg Windows), although it
 does use a few extra bytes.

 It's also important to note that (at least for Unix) Unix timestamps do
 work pre-1970... they are just a negative integer, so you need to allow
 for signed integers in your database if that's the format you choose to
 use.

 I've spent a lot of time working with dates and times, trying to
 understand it all and come up with a solid process.  You need to really
 read the manuals and understand what you're storing, and what you're
 doing with functions like date() which assumes a GMT stamp, but outputs
 a TZ-corrected date.

  I am looking at the PEAR Date module and that seems to resolve these
  issues,
  but I would like to know if that is the standard/official way to handle
  dates in PHP applications as in my application, I would like to have
  one
  handler for dates, rather than separate code for dates within the Unix
  timestamp range and for dates outside - so if I switch to PEAR Date, I
  will
  use it everywhere in my code since I cannot take any chance of using
  date()
  or strftime() and possibly getting invalid data.


 I've never worked with the PEAR modules, but my recommendation is this:

 - store everything as GMT, and store an offset if needed, and
 understand what it is you're storing
 - transport your dates in your scripts as GMT as long as possible (this
 is what date() and strftime() expect anyway)
 - understand when you want to use date(), and when you really want
 gmdate()
 - write some wrapper functions which you understand implicitly, so that
 you can deal with your data in a way which makes sense to you


 The catch here is if you use Windows for either development or
 production.  I have zero experience with this platform, and don't know
 how much of my knowledge applies in that situation.


 Feel free to ask a detailed question to get a detailed answer :)


 Justin

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



[PHP] Re: sending mail attachment problem

2004-11-15 Thread Angelo Zanetti
well I have progressed but its still not working 100%

this is what i have done for now:

The email gets received and the size of the email is correct according
to the attachment but the problem I'm having is that the attachment
doesnt have the correct content, ie: if its a powerpoint slide it takes
forever to open and doesnt have anything in it.

I see that Content-Transfer-Encoding is set to  quoted-printable,
should this not be set to   
Content-Transfer-Encoding: base64\r\n; ???

as you can see that the content is being encoded using
base64_encode();
Im not too sure about that part. What is quoted-printable and why would
I use either that or base64_encode() over one another?

code below, 
thanks again in advance


$to=[EMAIL PROTECTED];
$mime_boundary = --==+X[.md5(time()).];

//Sort out your basic headers as usual, by piling them into a $headers
string.
$headers .= From: binc2 [EMAIL PROTECTED]\r\n; 
$headers .= To: bingi [EMAIL PROTECTED]\r\n; 

//Then you've got to specify the type of content you're dealing with.
This is also put into the $headers string. In this case, it will be
mixed between text, and some kind of attachment, hence the Content-Type
bit. The boundary bit uses the boundary variable you made earlier:
$headers .= MIME-Version: 1.0\r\n;
$headers .= Content-Type: multipart/mixed;\r\n;
$headers .=  boundary=\.$mime_boundary.\;

//Next, get on with piling the message into a $message string. You need
quite a bit of header looking stuff in here. The first bit is what is
displayed if the client receiveing the email doesn't support MIME,
followed by the boundary string (preceded by --, not sure why).
$message .= This is a multi-part message in MIME format.\r\n;
$message .= \r\n;
$message .= --.$mime_boundary.\r\n;

//Next comes the actual content of the email, each part needs it's own
mini header describing what it is.

$message .= Content-Type: text/plain; charset=\iso-8859-1\\r\n;
$message .= Content-Transfer-Encoding: 7bit\r\n;
$message .= \r\n;
$message .= Email content and what not: \r\n;
$message .= This is the file you asked for! \r\n;
$message .= --.$mime_boundary.\r\n;

//Finally, a plaintext attachment. In this case I already put your
contents into $fileContent.
$message .= Content-Type: application/octet-stream;\r\n;
$message .= 
name=/home/httpd/vhosts/futurealpha.com/httpdocs/pps/049.jpg\r\n;
$message .= Content-Transfer-Encoding: quoted-printable\r\n;
$message .= Content-Disposition: attachment;\r\n;
$message .=  filename=\049.jpg\\r\n;
$message .= \r\n;

//content of the attachment section

$pps=
/home/httpd/vhosts/futurealpha.com/httpdocs/pps/049.jpg;
$pps_size=(filesize($pps));
$fp = fopen($pps,'rb'); 
$file = fread($fp, $pps_size);
/*
Encode The Data For Transition using base64_encode();
And get a 32-character hexadecimal number
*/
$fileContent .= chunk_split(base64_encode($file));


$message .= $fileContent;
$message .= \r\n;
$message .= --.$mime_boundary.\r\n;

$ok = mail($to, file by email, $message, $headers);

 Manuel Lemos [EMAIL PROTECTED] 11/15/2004 5:26:25 PM 
Hello,

On 11/15/2004 12:28 PM, Angelo Zanetti wrote:
  I have a script that is supposed to use the mail function to send
an
  email with an attachment, however, when run the script I dont get
any
  errors but in the body of the email there is a lot of mixed up
text,
  which i presume is meant to be the attachment.

That is because you are setting it to be of text/plain.

Anyway, although you can, you should not be sending messages with 
attachments this way as modern spam filters will discard your
messages.

You may want to try this class to compose and send messages with 
attachments properly:

http://www.phpclasses.org/mimemessage 


-- 

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/ 

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/ 

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html 

-- 
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] unable to upload a directory using the web brower (HTTP).

2004-11-15 Thread Angelo Zanetti
cant you create the folder using php and then copy the contents (files)
to the newly created folder?
eg:

$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/mydir/'';
if(!is_dir($uploaddir))
{
$old = umask(0);
mkdir($uploaddir, 0777);
umask($old);
}
$uploadfile = $uploaddir .
$_FILES['userfile']['name'];
$uploadfileDB = $_FILES['userfile']['name'];

if
(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) 
{
echo (font  face=Arial,
Helvetica, sans-serif; font-size: 12px; font-weight: bold File is
valid, and was successfully uploaded. /font);
}

not sure if this is what your looking for???
hope this helps
ANgelo  

 Scott Fletcher [EMAIL PROTECTED] 11/16/2004 12:53:28 AM 
Um, look like I'm going to have to write a JAVA programming and have a
couple of friends to come to help me out with it.   Suck though!  So,
applets it is...

Zip it up, that gonna be tought because of lack of good cross-platform
support.  We have Robo-Help for Windows, since windows zip only work
for
windows then I http it over to AIX and have php extract it.  So, does
the
GNU zip work for that or not?  Probably not too well.  So, applet is
the way
to go.  It will also help me to avoid the need for the su or sudo
command
cause it doesn't work through Apache account too well.

Thanks,
 Scott



Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Scott Fletcher wrote:
  I found that on most web browsers, I can not upload the folder via
HTTP
  using hte web browser upload dialog box.

 Most? I thought all.

  So, I can't use the php's
  function, is_uploaded_file and move_uploaded_file.  Because the
web
browser
  see the folder as something to open with, like going down one
directory.
  So, any advice or suggestion??

 Zip it up. Or signed applets or activex objects

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


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



[PHP] From: mail() function

2004-11-15 Thread Garth Hapgood - Strickland
I am using the normal mail() function and currently using the from address
as:

mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website Registration' ,
$registree_email_text, 'from:[EMAIL PROTECTED]');

how can I make the from address look like Matchmakers Team instead of
'from:[EMAIL PROTECTED]'.

Regards
Garth

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