[PHP] Mail sending from nobody to nobody...

2004-04-05 Thread Jonathan Villa
For some reason mail is being sent from nobody to nobody every time.  I
have tried hardcoding the sendmail path, which is the default anyway,
and it still doesn't work?  

Has anyone encountered this before?

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



Re: [PHP] Mail sending from nobody to nobody...

2004-04-05 Thread hitek
Details?
How are you calling the mail function?
At 11:59 PM 4/4/2004, Jonathan Villa wrote:
For some reason mail is being sent from nobody to nobody every time.  I
have tried hardcoding the sendmail path, which is the default anyway,
and it still doesn't work?
Has anyone encountered this before?

--
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] Mail sending from nobody to nobody...

2004-04-05 Thread Jonathan Villa
$from = From: .$email.\n;
$from .= Reply-to: .$email.\n;
$message = The following person has been added to the Mailing
List.\n\n;
$message .= $name. (.$email.) from .$city. has been added to the
mailing list.;

if(mail([EMAIL PROTECTED],Added To Mailing
List,stripslashes($message),$from) == false)
die('failed');


On Mon, 2004-04-05 at 02:13, hitek wrote:
 Details?
 How are you calling the mail function?
 
 At 11:59 PM 4/4/2004, Jonathan Villa wrote:
 For some reason mail is being sent from nobody to nobody every time.  I
 have tried hardcoding the sendmail path, which is the default anyway,
 and it still doesn't work?
 
 Has anyone encountered this before?
 
 --
 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] mysql - can't use the copy/paste function

2004-04-05 Thread Burhan Khalid
Five wrote:
Windows 98 se

When using the dos window command line for mysql commands everything works fine except 
if I try to use the paste function to paste
pre-typed commands, the window freezes. This is aaannnoooyyyiiinnnggg.
This is PHP -- MySQL is down the hall to the left.

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


Re: [PHP] Extracting Output from File...

2004-04-05 Thread Burhan Khalid
Russell P Jones wrote:
Basically there is a php page... lets say

http://www.myserver.com/outputpage.php

that picks up some info from a database and echos it out as plain text to
the browser.
I want to use php in a different file to go pick up whatever is printed
out to that file and save it to a variable..
You can use file() fopen() (if you have url wrappers on), and then deal 
with the data.

You can also use a browser emulator (snoopy.sourceforge.net) to get the 
information.

Finally, you can create a webservice at outputpage.php and get the 
results as XML.

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


[PHP] Passing array as subject to preg_replace has odd behaviour with limit

2004-04-05 Thread Leon Derczynski
Hi everybody,

I'm sure this has been mentioned hundreds of times before, but why is 
preg_replace apparently ignoreing my limit when I pass it an array of text 
to work on (with just one string each for pattern and replacement)? Is it 
only obeying per element of the subject? If so, is there a way to correct 
this unwanted behaviour, maybe through setting a constant or something?

Cheers!

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] code design? modular?

2004-04-05 Thread Justin French
On 03/04/2004, at 5:37 AM, Andy B wrote:

is it ok practice to put code like the code to put results from an 
mysql query into a combo box into an include file and then just 
include it wherever its needed? the code i can see would have to be 
used at least 5 times in the same page
Typically if there's something you want to use/do more than once, you'd 
either:

a) include it from it's own file (as suggested), or
b) declare it as a function, and then group the functions into logical 
include files for certain parts of the website

If you had this one-off problem, then you'd just include it PHP code 
inline where needed:

? include(inc/combobox.php); ?

If you had 4 or 5 date  time functions you used site-wide, I'd declare 
them each as functions, then group those date and time functions into a 
single include file (eg datetime.php), include it at the top of each 
page (or where needed), and call the functions as needed.

---
Justin French
http://indent.com.au
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Mail sending from nobody to nobody...

2004-04-05 Thread hitek
Try getting rid of the stripslashes, or if you need to remove them, add an 
additional \n to the message after the strip slashes, like so:

if(mail([EMAIL PROTECTED],Added To Mailing 
List,stripslashes($message).\n,$from) == false) die('failed');

Also, see http://www.php.net/manual/en/function.mail.php if you haven't 
checked there yet. There are some good examples.

At 12:17 AM 4/5/2004, Jonathan Villa wrote:
$from = From: .$email.\n;
$from .= Reply-to: .$email.\n;
$message = The following person has been added to the Mailing
List.\n\n;
$message .= $name. (.$email.) from .$city. has been added to the
mailing list.;
if(mail([EMAIL PROTECTED],Added To Mailing
List,stripslashes($message),$from) == false)
die('failed');
On Mon, 2004-04-05 at 02:13, hitek wrote:
 Details?
 How are you calling the mail function?

 At 11:59 PM 4/4/2004, Jonathan Villa wrote:
 For some reason mail is being sent from nobody to nobody every time.  I
 have tried hardcoding the sendmail path, which is the default anyway,
 and it still doesn't work?
 
 Has anyone encountered this before?
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] How to built desktop applications.

2004-04-05 Thread francesco
Hi all,
I know that is possible to built desktop applications with PHP (applications that run 
only on desktop and not client applications).
How is possible this?
Is necessary use the php standard or there is help from other application or 
particular tool?
Can anyone show me how is possible this with example or link to resorces about this?
Thanks in advance,

Francesco
[EMAIL PROTECTED]



Re: [PHP] How to built desktop applications.

2004-04-05 Thread Red Wingate
PHP-GTK

Am Montag, 5. April 2004 10:43 schrieb [EMAIL PROTECTED]:
 Hi all,
 I know that is possible to built desktop applications with PHP
 (applications that run only on desktop and not client applications). How is
 possible this?
 Is necessary use the php standard or there is help from other application
 or particular tool? Can anyone show me how is possible this with example or
 link to resorces about this? Thanks in advance,

 Francesco
 [EMAIL PROTECTED]

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



php-general Digest 5 Apr 2004 09:24:06 -0000 Issue 2687

2004-04-05 Thread php-general-digest-help

php-general Digest 5 Apr 2004 09:24:06 - Issue 2687

Topics (messages 182300 through 182337):

\n is not working!
182300 by: Labunski
182302 by: Robert Cummings
182303 by: Monty
182306 by: DvDmanDT
182310 by: Chris Shiflett

$HTTP_SESSION_VARS still holds original values even after unset?
182301 by: Andy B
182304 by: John Holmes
182307 by: DvDmanDT
182308 by: Andy B
182309 by: Andy B
182311 by: Larry Brown
182312 by: DvDmanDT
182314 by: trlists.clayst.com
182315 by: Andy B
182317 by: John Holmes
182319 by: Andy B
182320 by: trlists.clayst.com
182321 by: Andy B
182327 by: Curt Zirzow

Re: Session hell: register_globals off
182305 by: DvDmanDT

Re: php as default value in html
182313 by: Larry Brown

[solved][PHP] php as default value in html
182316 by: Andy B

Sorting array of objects
182318 by: Richard Harb
182325 by: Tom Rogers

Re: session_exist() ?? Can this be done?
182322 by: Curt Zirzow
182323 by: Aaron Christopher Vonderhaar

Re: Regular Expressions
182324 by: Curt Zirzow

Weird variable issue encountered... help needed!
182326 by: gvarosky.conversent.com

Mail sending from nobody to nobody...
182328 by: Jonathan Villa
182329 by: hitek
182330 by: Jonathan Villa
182335 by: hitek

Re: mysql - can't use the copy/paste function
182331 by: Burhan Khalid

Re: Extracting Output from File...
182332 by: Burhan Khalid

Passing array as subject to preg_replace has odd behaviour with limit
182333 by: Leon Derczynski

Re: code design? modular?
182334 by: Justin French

How to built desktop applications.
182336 by: francesco.automationsoft.biz
182337 by: Red Wingate

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
\n isn't working properly.

Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to
the document
one|two|three\n
but not
one|two|three (and break)



whole code:

if ($a==new){
$post_0 = $_POST[one];
$post_1 = $_POST[two];
$post_2 = $_POST[three];
 if ($post_1 !=){
 if ($post_2 !=){
$m_fails=fopen('../data/menu.txt','a');
$new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n';
fwrite($m_fails,$new_topic);
fclose($m_fails);
}}
}
---End Message---
---BeginMessage---
On Sun, 2004-04-04 at 17:58, Labunski wrote:
 \n isn't working properly.
 
 Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to
 the document
 one|two|three\n
 but not
 one|two|three (and break)

Because it's in single quotes versus a double quotes.

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.  |
`'
---End Message---
---BeginMessage---
\n must be included in double-quotes because it's treated like a variable.

echo This works\n;  // Displays: This works

echo This doesn't work\n';  // Displays: This doesn't work\n


 From: [EMAIL PROTECTED] (Labunski)
 Newsgroups: php.general
 Date: Mon, 5 Apr 2004 00:58:35 +0300
 To: [EMAIL PROTECTED]
 Subject: \n is not working!
 
 \n isn't working properly.
 
 Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n'; writes to
 the document
 one|two|three\n
 but not
 one|two|three (and break)
 
 
 
 whole code:
 
 if ($a==new){
 $post_0 = $_POST[one];
 $post_1 = $_POST[two];
 $post_2 = $_POST[three];
 if ($post_1 !=){
 if ($post_2 !=){
 $m_fails=fopen('../data/menu.txt','a');
 $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n';
 fwrite($m_fails,$new_topic);
 fclose($m_fails);
 }}
 }
---End Message---
---BeginMessage---
 echo This doesn't work\n';  // Displays: This doesn't work\n

Seems to me like that would generate parse error.. :s But yea, we get your
point.. :)
-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
---End Message---
---BeginMessage---
--- Labunski [EMAIL PROTECTED] wrote:
 Why do this line $new_topic = $post_0.'|'.$post_1.'|'.'$post_2\n';
 writes to
 the document
 one|two|three\n

Actually, that's not true. Assuming:

$post_0 = 'one';
$post_1 = 'two';
$post_2 = 'three';

The code you posted will store the following in $new_topic:

one|two|$post_2\n


[PHP] Extension problem

2004-04-05 Thread Enrico Comini
I use php without problem, but my file is processed by php only if the
extension is .php , why ?
If I have for example a index.html with ?php at the beginning , this file
is not parsed by php and I have to rename in index.php
Thanks, Enrico



Re: [PHP] Extension problem

2004-04-05 Thread Duncan Hill
On Monday 05 April 2004 10:37, Enrico Comini wrote:
 I use php without problem, but my file is processed by php only if the
 extension is .php , why ?
 If I have for example a index.html with ?php at the beginning , this
 file is not parsed by php and I have to rename in index.php
 Thanks, Enrico

Apache (and other webservers) have a config option that maps file extensions 
to parsers (ie, .php to mod_php).

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



[PHP] ASP.NET in PHP

2004-04-05 Thread Hong Nguyen
Hi all

Please download and test KPF, a ASP.NET port PHP framework. URL
http://www.k-edge.com

Features:
  a.. Code behind
  b.. Databinding using array or ADOdb
  c.. Post back event for server controls
  d.. User control
  e.. Dynamic control
  f.. Validation tags
  g.. Master page (ASP.NET 2.0)
Hope to hear your opinion on this aproach.

Hong

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



Re: [PHP] How to built desktop applications.

2004-04-05 Thread Alireza Balouch
It's easy...
Al you have to do is call the php script like: php4  mydesktopscript.php
and use other languages like TCL/TK to have some GUI on your script..
but i would rather learn my self C instead of using php for Desktop app.

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi all,
I know that is possible to built desktop applications with PHP (applications
that run only on desktop and not client applications).
How is possible this?
Is necessary use the php standard or there is help from other application or
particular tool?
Can anyone show me how is possible this with example or link to resorces
about this?
Thanks in advance,

Francesco
[EMAIL PROTECTED]

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



Re: [PHP] Extension problem

2004-04-05 Thread Kim Steinhaug
In other words you could say that if youd like the HTML files to be parsed
as PHP files you would need to change the mapping on the server,

eg.

AddType application/x-httpd-php .php
AddType application/x-httpd-php .html

the second line would tell apache to run html files as php files.

You could also, to do some sneaky things do this :

AddType application/x-httpd-php .png

or

AddType application/x-httpd-php .myDocumentType
Url . http://www.mydomain.com/index.myDopcumentType

This can usually also be done in the .htaccess file, you need some
googling for this as I dont recall the syntax.

The PHP and HTML extension are nothing more than a way of
cataloging / seperating the files.

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--


Duncan Hill [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Monday 05 April 2004 10:37, Enrico Comini wrote:
  I use php without problem, but my file is processed by php only if the
  extension is .php , why ?
  If I have for example a index.html with ?php at the beginning , this
  file is not parsed by php and I have to rename in index.php
  Thanks, Enrico

 Apache (and other webservers) have a config option that maps file
extensions
 to parsers (ie, .php to mod_php).

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



[PHP] Re: Extension problem

2004-04-05 Thread Alireza Balouch
It's apache that runs the php script  it must some how know that this is a
script file.. and the way you tell the apache to run the script is by the
extention (.php)
since .html is not an serverside script, apache dont nead to run that before
sending it.

but you can declare that in apache.conf (if you want html files to use php
code)

:)


Enrico Comini [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I use php without problem, but my file is processed by php only if the
 extension is .php , why ?
 If I have for example a index.html with ?php at the beginning , this
file
 is not parsed by php and I have to rename in index.php
 Thanks, Enrico



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



[PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Kim Steinhaug
My first thought is that some dynamic code on this page has an error.
Typical like this :

input type=var value=?=$var?'
 ^^

Or maby a quote is missing? Looking at your examples it looks like there are
different parts of the HTML code comming into your var, which would
typically
be the case with broken quotes.  On the other hand it looked like there was
a
session ID aswell in there, but mainly I would run my code through the W3
validator just to double check.

You could also, just in case check that the get_magic_quotes_gpc hasnt
changed.
There could also be some quotes in some variables messing up your code
again.
Going from magic_quotes to no_magic can be annoying - I did that experience
with my database application some weeks ago...

Hope this is of any help.

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--


[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 This problem only seems to be happening on one of the virtual hosts on
this
 system, and I cannot seem to figure out just what it is.

 I have a simple form posting to search.php, with a text input field, with
a
 name of 'search'. And since this site is an internal site, register
globals
 are on, as we are not worried about anyone misuing any of the variables in
 use.

 In any even, this problem was noticed about a week ago, and it did not
exist
 before.

 After inputting some text into the search box, in this example, 'var',
sans
 quotes, and i hit submit... on the next page, I am just having it return
 just $search for testing, and, it comes back sporadically with: 'var', but
 most of the time, it comes back with:

 var^!#ndda/form

 or

 var4194092d098240928d12ed

 or

 var#c0c0c0

 or

 varput type=text

 etc. etc. it seems soemthing is somehow corrupting the variables, and I
 cannot seem to figure out what it might be. This has been working fine
until
 about the past week, and I cannot think of any major changes that may have
 happened within the past week that could have caused this... and as I
 mentioned above, it only seems to be this one virtual host. And ai also
 compared with backups of all of y included files at the beginnings and
ends
 of each script from before this problem started happening, and I can see
no
 major changes in any of them. And, this is happening around all php
scripts
 on the site...

 I am running 4.3.4, with apache 2, FreeBSD 4.8, and the data is all stored
 on a vinum partition. The server has been rebooted, a fresh install of
 php... tried setting output buffering on and flushing it at the end of the
 script(s), however, they seem to get hacked up when doing that, so I stay
 away from that band-aid fix...I am using sessions as well, as a few
scripts
 within the site store session variables... and also using SMBAuth to do
 authentication from our domain controller...

 I've been pulling out my hair for 4 days straight on this issue, and I am
 all out of ideas, any help would be *GREATLY* appreciated!

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



[PHP] Warning: exec(): Unable to fork

2004-04-05 Thread Mark C

Hi,

I curretly running: PHP 4.3.4 on a windows XP with IIS,
This is the first time developed using a windows platform (normally I use
apache on linux), but I'm trying to run ImageMagick in the background to
resize an image, as a test I'm trying to run the cmd shell, using exec
(I've tried system, exec, passthru), yet they all give this error:

Warning:  exec(): Unable to fork [C:\WINNT\SYSTEM32\CMD.EXE /?] in
index.php on line 45

From googleing this would seem a windows specfic problem, but as of yet I
have not found an answer, it seems pretty common on windows.

Has anyone else managed to get around this yet? or can advise on what the
error could be due to?

Thanks

Mark

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



[PHP] place list box using php

2004-04-05 Thread T UmaShankari

Hello,

 Is there possible to place a list box over one many background picture 
using php anyways ?


Regards,
Uma

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



[PHP] mktime error

2004-04-05 Thread Andrew
Hi there,

On a host running:
PHP 4.3.5 (cli) (built: Apr  3 2004 07:11:21)

I found a strange error produced by the mktime() function:

mktime(0, 0, 0, 4, 4, 2004)
returns -7262

On my personal machine the return value is:

1081026000

If anybody's aware of that bug and if it's fixed, please answer me.

Andrew

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



[PHP] mktime error

2004-04-05 Thread Andy B
On my personal machine the return value is:

1081026000
interesting... i got 1081054800 from mine with the code:
?
$time=mktime(0,0,0,4,4,2004);
echo $time;
?

 even on cli it gives the same thing

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



RE: [PHP] mktime error

2004-04-05 Thread Nunners
I got 1081033200

Two thoughts:
1 - is $time a global variable predefined as the current time? Don't think
it is?!?!?!

2 - Could it be to do with local time settings i.e. comparing american dates
with UK dates (1/Aug/04 and 8/1/04)?

Nunners



 -Original Message-
 From: Andy B [mailto:[EMAIL PROTECTED]
 Sent: 05 April 2004 11:29
 To: [EMAIL PROTECTED]
 Subject: [PHP] mktime error
 
 On my personal machine the return value is:
 
 1081026000
 interesting... i got 1081054800 from mine with the code:
 ?
 $time=mktime(0,0,0,4,4,2004);
 echo $time;
 ?
 
  even on cli it gives the same thing
 
 --
 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] mktime error

2004-04-05 Thread Red Wingate
Your Server will most likely run in a different timezone. If both of you
would use gmktime() the result will be the same.

As for the negative result: Had the same problem some time ago - seams
to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can
adjust the result by reducing the result by 1

$var = mktime ( 0,0,0,4,4,2004 ) - 1 ;

  -- red

Am Montag, 5. April 2004 12:29 schrieb Andy B:
 On my personal machine the return value is:

 1081026000
 interesting... i got 1081054800 from mine with the code:
 ?
 $time=mktime(0,0,0,4,4,2004);
 echo $time;
 ?

  even on cli it gives the same thing

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



Re: [PHP] mktime error

2004-04-05 Thread Red Wingate
Woops little mistake there, first of all it's 'gmmktime()' secondly the source
should look something like:

$var = mktime ( 0,0,1,4,4,2004 ) - 1;

You can find a nice article on this topic here:
http://www.phpbuilder.com/columns/ehresman20030911.php3?page=1

  -- red

[...]
 Your Server will most likely run in a different timezone. If both of you
 would use gmktime() the result will be the same.

 As for the negative result: Had the same problem some time ago - seams
 to me as if PHP doesn't like those 0,0,0 ( try 0,0,1 instead ) - You can
 adjust the result by reducing the result by 1

 $var = mktime ( 0,0,0,4,4,2004 ) - 1 ;

   -- red
[...]

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



RE: [PHP] mktime error

2004-04-05 Thread Hernan Marino
I got 1081047600 for
$time=mktime(0,0,0,4,4,2004);
echo $time;

(RH9, PHP 4.3.4)


On Mon, 5 Apr 2004 11:34:11 +0100, Nunners wrote:
I got 1081033200

Two thoughts:
1 - is $time a global variable predefined as the current time? Don't
think
it is?!?!?!

2 - Could it be to do with local time settings i.e. comparing american
dates
with UK dates (1/Aug/04 and 8/1/04)?

Nunners



 -Original Message-
 From: Andy B [mailto:[EMAIL PROTECTED]
 Sent: 05 April 2004 11:29
 To: [EMAIL PROTECTED]
 Subject: [PHP] mktime error

 On my personal machine the return value is:

 1081026000
 interesting... i got 1081054800 from mine with the code:
 ?
 $time=mktime(0,0,0,4,4,2004);
 echo $time;
 ?

  even on cli it gives the same thing

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



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

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



Re: [PHP] mktime error

2004-04-05 Thread Hernan Marino
Guys, second thought.
mktime builds a unix time stamp (since the unix epoch, Jan 1, 1970 [I
guess]), the difference are maybe due to time zones, because its the
number of seconds since Jan,1 1970.



On Mon, 5 Apr 2004 06:29:12 -0400, Andy B wrote:
On my personal machine the return value is:

1081026000
interesting... i got 1081054800 from mine with the code:
?
$time=mktime(0,0,0,4,4,2004);
echo $time;
?

 even on cli it gives the same thing

--
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] mktime error

2004-04-05 Thread Andy B
if you need to turn the result of mktime() into a valid mysql timestamp
format then put these 2 lines in your code when needed:
?
//create valid mysql timestamp(14 digit)
//change to fit your liking
//sorry turned into a function...
function CreateDate($day, $month, $year);
//make sure no arguments were left out
if!empty($day)  !empty($month)  !empty($year)){
$time=mktime(0,0,0,'$month','$year');
//convert to a formated stamp
$time=date(YmdHis, $time);
return $time;}
else{return false;}

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



Re: [PHP] mktime error

2004-04-05 Thread Red Wingate
You could do this like this ( as it is faster ):

function CreateDate($day, $month, $year) {
return $year.$month.$day.'00';
}

CreateDate(04,04,2004) - 2004040400

But make sure you add the leading zero to $month and $day ( can
be easily done (number_format for example) )

 -- red

Am Montag, 5. April 2004 13:20 schrieb Andy B:
 if you need to turn the result of mktime() into a valid mysql timestamp
 format then put these 2 lines in your code when needed:
 ?
 //create valid mysql timestamp(14 digit)
 //change to fit your liking
 //sorry turned into a function...
 function CreateDate($day, $month, $year);
 //make sure no arguments were left out
 if!empty($day)  !empty($month)  !empty($year)){
 $time=mktime(0,0,0,'$month','$year');
 //convert to a formated stamp
 $time=date(YmdHis, $time);
 return $time;}
 else{return false;}

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



Re: [PHP] passing variables

2004-04-05 Thread William Lovaton
You can use $_REQUEST too, it has $_GET, $_POST and $_COOKIES.

-William


El s?, 03-04-2004 a las 11:30, Larry E.Ullman escribió:
  When using a link like xxx.proceed.php?language=gbr
  the 'proceed.php' script does not receive any $language variable.
 
  Does someone know how to get it run?
 
 This is a register_globals issue. Refer to $_GET['language'] instead of 
 just language. Or, at the top of your script, add
 $language = $_GET['language'];
 and you shouldn't have to change anything else.
 
 See the manual for $_GET and $_POST for more information.
 
 Larry

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



[PHP] Printer Functions

2004-04-05 Thread Lou Apolonia
My question involves sending html to the printer to be printed properly.
Here is my code:

$handle = printer_open('Lexmark Z25-Z35'); printer_start_doc($handle,
test); printer_start_page($handle);

printer_set_option($handle, PRINTER_MODE, 'raw');
printer_set_option($handle, PRINTER_PAPER_FORMAT,
PRINTER_FORMAT_LETTER); $file =
file_get_contents('http://localhost/'.$page.'.php?mid='.$mid);
printer_draw_text($handle, $file, 10, 10);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

When this code runs, a page prints .. However all that prints is the
html source, and it only prints one line across the top of the page and
nothing else.  How does one send html to the printer and have the
rendered page print?

I've also tried using printer_write instead of printer_draw_text, but to
no avail.  

As always, any help is greatly appreciated.

Thank you in advance,
Lou

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



Re: [PHP] Sorting array of objects

2004-04-05 Thread Rob Ellis
On Mon, Apr 05, 2004 at 05:03:17AM +0200, Richard Harb wrote:
 Hi there,
 
 Supposed I have an array of objects, like:
 
 $this[$i]-property1
 $this[$i]-property2
 
 is there any 'cheap' way to sort the array according to the values of
 property1?
 

Try array_multisort() -

// create a temporary array of just the property
// you want to sort on...
foreach ($array_of_objects as $k = $o)
$temp[$k] = $o-property1;

// sort
array_multisort($temp, $array_of_objects);

- Rob

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



[PHP]

2004-04-05 Thread Nunners
I've got a series of functions which return a list in an array.  How can I
create an empty array?  Or do I need to check it's a valid array before I
use it?

Cheers
James

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



Re: [PHP]

2004-04-05 Thread Richard Davey
Hello Nunners,

Monday, April 5, 2004, 2:12:11 PM, you wrote:

N I've got a series of functions which return a list in an array. How can I
N create an empty array?  Or do I need to check it's a valid array before I
N use it?

$void = array();

That is an empty array. You can also use it to clear the contents of
an existing array.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] place list box using php

2004-04-05 Thread Burhan Khalid
T UmaShankari wrote:
Hello,

 Is there possible to place a list box over one many background picture 
using php anyways ?
No, this is not possible with PHP. PHP is not a client-side language. 
You need to solve this problem with HTML.

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


Re: [PHP] How to built desktop applications.

2004-04-05 Thread Burhan Khalid
Alireza Balouch wrote:

It's easy...
Al you have to do is call the php script like: php4  mydesktopscript.php
and use other languages like TCL/TK to have some GUI on your script..
but i would rather learn my self C instead of using php for Desktop app.
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi all,
I know that is possible to built desktop applications with PHP (applications
that run only on desktop and not client applications).
How is possible this?
http://gtk.php.net

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


Re: [PHP] Strange Numeric Conversion...

2004-04-05 Thread John Nichel
Jay Blanchard wrote:
[snip]
naked
[/snip]
Dang John, I guess I don't think octally any more!
John writes out his grocery list in Hex.  ;)

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


Re: [PHP]

2004-04-05 Thread Ryan A

On 4/5/2004 3:12:11 PM, Nunners ([EMAIL PROTECTED]) wrote:
 I've got a series of functions which return a list in an array.  How can I
 create an empty array?  Or do I need to check it's
 a valid array before I
 use it?

 Cheers
 James

James,
Please put the topic in the subject line so we will know what you need help
in before we open your mail as its just plain irritating to get a blank
subject (or with just [PHP]), even if people know the answer to your
question its likely that you wont get one because they will just ignore your
mail and not open it.

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



[PHP] can I get at screen size ?

2004-04-05 Thread E . H . Terwiel
I want to write a Server Side PHP program that generates a HTML page
client side.
How would I get at the clients' screen size, before serving the
generated page ?
Would it be a two-step process: first let the client execute a piece
of JavaScript to generate Height and Width, and then send those values
to the PHP server (FORM, PUT) ?
Or can it be done in only one PHP program ?


frgr
Erik

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



Re: [PHP] can I get at screen size ?

2004-04-05 Thread Richard Davey
Hello,

Monday, April 5, 2004, 3:20:03 PM, you wrote:

EHT I want to write a Server Side PHP program that generates a HTML
EHT page client side. How would I get at the clients' screen size,
EHT before serving the generated page ? Would it be a two-step
EHT process: first let the client execute a piece of JavaScript to
EHT generate Height and Width, and then send those values to the PHP
EHT server (FORM, PUT) ? Or can it be done in only one PHP program ?

PHP has no real interaction with the users system what-so-ever, so
it's not possible for it to get the screen size automatically. You
would have to pass values in from JavaScript.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] can I get at screen size ?

2004-04-05 Thread John Nichel
E.H.Terwiel wrote:
I want to write a Server Side PHP program that generates a HTML page
client side.
How would I get at the clients' screen size, before serving the
generated page ?
Would it be a two-step process: first let the client execute a piece
of JavaScript to generate Height and Width, and then send those values
to the PHP server (FORM, PUT) ?
Or can it be done in only one PHP program ?
frgr
Erik
You can't grab the screen size with php.  You'll have to do it with 
JavaScript, and pass the values.

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


RE: [PHP] can I get at screen size ?

2004-04-05 Thread Hawkes, Richard
I wrote a JavaScript page that redirects to a PHP page like this:

html
head
titleRedirecter/title
script language=JavaScript
function redirectUser()
{
location.href=http://www.mysite.com/page2.php?width=; + screen.width
+ height= + screen.height;
}
/script
/head
body onLoad=redirectUser()
/body
/html

The PHP script can then store it as it wishes.

Good luck!
Richard

-Original Message-
From: Richard Davey [mailto:[EMAIL PROTECTED]
Sent: 05 April 2004 15:25
To: [EMAIL PROTECTED]
Subject: Re: [PHP] can I get at screen size ?


Hello,

Monday, April 5, 2004, 3:20:03 PM, you wrote:

EHT I want to write a Server Side PHP program that generates a HTML
EHT page client side. How would I get at the clients' screen size,
EHT before serving the generated page ? Would it be a two-step
EHT process: first let the client execute a piece of JavaScript to
EHT generate Height and Width, and then send those values to the PHP
EHT server (FORM, PUT) ? Or can it be done in only one PHP program ?

PHP has no real interaction with the users system what-so-ever, so
it's not possible for it to get the screen size automatically. You
would have to pass values in from JavaScript.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



RE: [PHP] can I get at screen size ?

2004-04-05 Thread Hawkes, Richard
Scrap my last effort, this was the one I should have sent!

html
body
onLoad=javascript:location.href='http://www.jumbobridge.com/phpinfo.php?width='+screen.width+'height='+screen.height
/body
/html

Obviously replacing the web site details and PHP page name, but using the
'width' and 'height' values as you please!

Cheerio (again!)
Richard

-Original Message-
From: E.H.Terwiel [mailto:[EMAIL PROTECTED]
Sent: 05 April 2004 15:20
To: [EMAIL PROTECTED]
Subject: [PHP] can I get at screen size ?


I want to write a Server Side PHP program that generates a HTML page
client side.
How would I get at the clients' screen size, before serving the
generated page ?
Would it be a two-step process: first let the client execute a piece
of JavaScript to generate Height and Width, and then send those values
to the PHP server (FORM, PUT) ?
Or can it be done in only one PHP program ?


frgr
Erik

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



RE: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread gvarosky
Thank you all for your ideas so far, however, I ahve gone through all my
code, and cannot seem to find the culprit.

I did a var dump, and also a dump of the REQUEST, GET, and POST variables,
and here is an example of what I am seeing (submitting test):

string(7) testiU

_REQUEST: Array
(
[search] = testiU
[PHPSESSID] = 3aeab8d47f4a4383104e20a98963f608
)

_GET: Array
(
)

_POST: Array
(
[search] = testiU

and also removing just about everything, and even dropping all mysql table
indexes that are referenced in the headers, and it still seems to happen...
and even when going to just the search posting the code, sometimes it will
come up as:

string(7) test

_REQUEST: Array
(
[search] = test
[PHPSESSID] = 3aeab8d47f4a4383104e20a98963f608
)

_GET: Array
(
)

_POST: Array
(
[search] = test
)

again, any help is greatly appreciated! Is it possible that the sessions are
being corrupted somehow by apache/php? (the session here is leftover from
when I had some header files included)

Regards,
Geoff Varosky
Senior Systems Engineer
Conversent Communications
Phone: 888-885-4437 ext. 248 (Mon-Wed, Fri)
Phone: 508-480-4523 (Thursdays only)
[EMAIL PROTECTED] 
PGP Public Key - http://gvarosky.conversent.net/gvarosky.txt

-Original Message-
From: Kim Steinhaug [mailto:[EMAIL PROTECTED]
Sent: Monday, April 05, 2004 6:04 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Weird variable issue encountered... help needed!


My first thought is that some dynamic code on this page has an error.
Typical like this :

input type=var value=?=$var?'
 ^^

Or maby a quote is missing? Looking at your examples it looks like there are
different parts of the HTML code comming into your var, which would
typically
be the case with broken quotes.  On the other hand it looked like there was
a
session ID aswell in there, but mainly I would run my code through the W3
validator just to double check.

You could also, just in case check that the get_magic_quotes_gpc hasnt
changed.
There could also be some quotes in some variables messing up your code
again.
Going from magic_quotes to no_magic can be annoying - I did that experience
with my database application some weeks ago...

Hope this is of any help.

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--


[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 This problem only seems to be happening on one of the virtual hosts on
this
 system, and I cannot seem to figure out just what it is.

 I have a simple form posting to search.php, with a text input field, with
a
 name of 'search'. And since this site is an internal site, register
globals
 are on, as we are not worried about anyone misuing any of the variables in
 use.

 In any even, this problem was noticed about a week ago, and it did not
exist
 before.

 After inputting some text into the search box, in this example, 'var',
sans
 quotes, and i hit submit... on the next page, I am just having it return
 just $search for testing, and, it comes back sporadically with: 'var', but
 most of the time, it comes back with:

 var^!#ndda/form

 or

 var4194092d098240928d12ed

 or

 var#c0c0c0

 or

 varput type=text

 etc. etc. it seems soemthing is somehow corrupting the variables, and I
 cannot seem to figure out what it might be. This has been working fine
until
 about the past week, and I cannot think of any major changes that may have
 happened within the past week that could have caused this... and as I
 mentioned above, it only seems to be this one virtual host. And ai also
 compared with backups of all of y included files at the beginnings and
ends
 of each script from before this problem started happening, and I can see
no
 major changes in any of them. And, this is happening around all php
scripts
 on the site...

 I am running 4.3.4, with apache 2, FreeBSD 4.8, and the data is all stored
 on a vinum partition. The server has been rebooted, a fresh install of
 php... tried setting output buffering on and flushing it at the end of the
 script(s), however, they seem to get hacked up when doing that, so I stay
 away from that band-aid fix...I am using sessions as well, as a few
scripts
 within the site store session variables... and also using SMBAuth to do
 authentication from our domain controller...

 I've been pulling out my hair for 4 days straight on this issue, and I am
 all out of ideas, any help would be *GREATLY* appreciated!

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

[PHP] includes

2004-04-05 Thread Will
Hello all,
I have a problem.  My directory list is similar to this:
root
tmpl
inc
forums
test_forum
messages
test_forum1
.messages

My question is in the test_form and message forums.  How do I do the include
files to read from the tmpl and inc??

I can get the include files to work as long as they are in the root (include
tmpl/header.htm).

I hope I explained it right. :)

~WILL~

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



RE: [PHP] includes

2004-04-05 Thread Angelo Zanetti
I think you can do this:

../tmpl/header.htm

try it and let us know!!
hope this helps
Angelo

-Original Message-
From: Will [mailto:[EMAIL PROTECTED]
Sent: Monday, April 05, 2004 4:48 PM
To: [EMAIL PROTECTED]
Subject: [PHP] includes


Hello all,
I have a problem.  My directory list is similar to this:
root
tmpl
inc
forums
test_forum
messages
test_forum1
.messages

My question is in the test_form and message forums.  How do I do the include
files to read from the tmpl and inc??

I can get the include files to work as long as they are in the root (include
tmpl/header.htm).

I hope I explained it right. :)

~WILL~

--
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] Re: imagecreatefromjpeg

2004-04-05 Thread Todd Cary
Jason -

I would like to give users the ability to upload jpeg images and have my 
php app size them into thumbnails as well as have a larger image 
available if the thumbnail is clicked.

Are there examples of this available?

Todd

Jason Barnett wrote:

 From http://www.php.net/manual/en/function.imagecreatefromjpeg.php

To all those having trouble with a message to the effect of:br
CreateImageFromJpeg() not supported in this PHP buildbr
Start by adding --with-jpeg-dir to your ./configure options as I left 
this out (not knowing I needed it) and I spent the best part of 6 hours 
trying to compile to get this option. (RH 6.2, PHP 4.0.1pl2, Apache 
1.3.12, GD 1.8.3)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] includes

2004-04-05 Thread Hawkes, Richard
If I think I understand you, your 'root' directory is the 'forums' directory,
and you'll probably want to do something like:

   include($_SERVER[DOCUMENT_ROOT] . /../inc/include1.php);

The double-dots take you back a directory.

Is that what you're after?!

Richard

-Original Message-
From: Will [mailto:[EMAIL PROTECTED]
Sent: 05 April 2004 15:48
To: [EMAIL PROTECTED]
Subject: [PHP] includes


Hello all,
I have a problem.  My directory list is similar to this:
root
tmpl
inc
forums
test_forum
messages
test_forum1
.messages

My question is in the test_form and message forums.  How do I do the include
files to read from the tmpl and inc??

I can get the include files to work as long as they are in the root (include
tmpl/header.htm).

I hope I explained it right. :)

~WILL~

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



RE: [PHP] Re: imagecreatefromjpeg

2004-04-05 Thread Hawkes, Richard
I think you'll want to use the 'imagecopyresized' function. Something like
this:

$thumbnail = imagecreate(100, 100);
$original = imagecreatefromjpeg(uploadedfile.jpg);
imagecopyresized($thumbnail, $original, 0, 0, 0, 0, 100, 100,
imagesx($original), imagesy($original));
imagejpeg($thumbnail, thumb.jpg);

That would create a 100x100 thumbnail image with no scaling, but you get the
idea! I do have the code that returns the uploaded image filename somewhere,
and I'll hunt that out if you like.

Thanks
Richard

-Original Message-
From: Todd Cary [mailto:[EMAIL PROTECTED]
Sent: 05 April 2004 15:54
To: [EMAIL PROTECTED]
Subject: [PHP] Re: imagecreatefromjpeg


Jason -

I would like to give users the ability to upload jpeg images and have my 
php app size them into thumbnails as well as have a larger image 
available if the thumbnail is clicked.

Are there examples of this available?

Todd

Jason Barnett wrote:

  From http://www.php.net/manual/en/function.imagecreatefromjpeg.php
 
 To all those having trouble with a message to the effect of:br
 CreateImageFromJpeg() not supported in this PHP buildbr
 Start by adding --with-jpeg-dir to your ./configure options as I left 
 this out (not knowing I needed it) and I spent the best part of 6 hours 
 trying to compile to get this option. (RH 6.2, PHP 4.0.1pl2, Apache 
 1.3.12, GD 1.8.3)

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


==
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==

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



Re: [PHP] includes

2004-04-05 Thread Chris Hayes
At 16:47 5-4-04, you wrote:
Hello all,
I have a problem.  My directory list is similar to this:
root
tmpl
inc
forums
test_forum
messages
test_forum1
.messages
My question is in the test_form and message forums.  How do I do the include
files to read from the tmpl and inc??
It is vital to understand that relative paths in the include command always 
are relative to the file as opened in the browser.
Therefore if you open index.php, which includes inc/somefile.php, and 
somefile.php includes anotherfile.php, you may expect it looks in the inc 
directory but in reality it looks in the root directory, because it looks 
relative to index.php.



I can get the include files to work as long as they are in the root (include
tmpl/header.htm).
I hope I explained it right. :)

~WILL~

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

2004-04-05 Thread Daniel Clark
I had some similar problems !  Here's what I did.

include $_SERVER['DOCUMENT_ROOT'] . '/includes/_myInclude.php' ;

Putting the DOCUMENT_ROOT ensured I was always pointing to the top
directory of the web pages.

Daniel Clark

I have a problem.  My directory list is similar to this:
 root
 tmpl
 inc
 forums
 test_forum
 messages
 test_forum1
 .messages

My question is in the test_form and message forums.  How do I do the
 include
files to read from the tmpl and inc??

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



[PHP] PHP 4.3.4, Apache w/ mod_ssl Compile Help

2004-04-05 Thread trlists
Hi Folks ...

A small problem here ...

I just rebuilt Apache 1.3.29 with mod_ssl.

When doing apachectl startssl I get:

[Mon Apr  5 12:19:53 2004] [warn] Loaded DSO libexec/libphp4.so
uses plain Apache 1.3 API, this module might crash under EAPI!
(please recompile it with -DEAPI)

I read through many postings on this topic and the opinion seemed to be 
that rebuilding PHP with CFLAGS=-DEAPI would fix this, as would simply 
rebuilding it after Apache as the rebuild should pick up the new APXS 
file which would define this symbol.

After rebuilding Apache with modssl as follows:

./configure --enable-module=so --enable-module=ssl
make
make install

I ran from the PHP directory:

make clean
make
make install

If I then do an apachectl stop followed by apachectl startssl I get the 
error again.

I have verified that the new libphp4.so is installed in 
/usr/local/apache/libexec, and that /usr/local/apache/bin contains the 
latest apxs file, and that the PHP configuration line points to that 
file.

I have tried the PHP rebuild both before and after setting CFLAGS=-
DEAPI in my local shell environment (with export).  The results are the 
same -- the error shown above.

What am I missing?

FYI, the PHP config as shown in config.status is:

--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i386-
redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr
--bindir=/us r/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/u sr/include --libdir=/usr/lib
--libexecdir=/usr/libexec --localstatedir=/var --sh
aredstatedir=/usr/com --mandir=/usr/share/man
--infodir=/usr/share/info --prefix =/usr
--with-config-file-path=/etc --enable-inline-optimization
--with-exec-dir= /usr/bin --with-pear=/usr/share/pear
--with-mysql=shared,/usr --with-apxs=/usr/local/apache/bin/apxs
--with-openssl --with-mcrypt --with-curl 

Thanks,

--
Tom

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



[PHP] Question, what to do when finding an error while validating data

2004-04-05 Thread Mike Zornek
I'm making a conscience effort to improve my PHP skills, that being making
objects, unit testing, better error handling etc. So I have a questions.

I have a database that is storing all of my records. One column is of type
enum where the two legal values currently are home and work; work is
default. I'm building a PHP object that will be my interface to the DB. In
the object I have a variable called $EmailType which will hold the value of
the database column. I wrote some set and get methods to work with the
variable and am now asking myself: What should I do if someone tries to set
$EmailType to a value that is not listed in the enum set?

Please give me some advice. Thanks!

~ Mike
-
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: http://MikeZornek.com
New Project: http://WebDevWiki.com

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



[PHP] PHP Access Violation using PEAR::Mail_smtp

2004-04-05 Thread Ben Ramsey
I'm getting the following error when using the Mail_smtp package from PEAR:

PHP has encountered an Access Violation at 0177A8B4

It does not occur everytime I use it, but even when send() returns true, 
e-mail messages are not being sent.  However, it all worked fine a week 
ago when I was testing it, and I don't think anything has changed to my 
installation of PHP.

I'm using PHP 5RC1 on a Windows Server 2003.  The localhost has no 
built-in mail functionality, so I cannot use mail().  I must use 
Mail_smtp to log in to the mail server.  I also have Net_SMTP and 
Net_Socket installed, and, like I said, when I first dropped in my code, 
all was working fine.

My code is, as follows:

code
require_once 'Mail/smtp.php';
$smtp_settings = array(
'host' = 'localhost',
'port' = '25',
'auth' = 'LOGIN',
'username' = 'username',
'password' = 'password'
);
$to = [EMAIL PROTECTED];
$msg = Line 1\nLine 2\nLine 3;
$headers = array(
'Subject'  = My Subject,
'From' = [EMAIL PROTECTED],
'Date' = date('r'),
'Content-Type' = 'text/plain',
'X-Mailer' = PHP/ . phpversion()
);
$mail = new Mail_smtp($smtp_settings);

if ($mail-send($to, $headers, $msg)) {
echo h2Sent successfully/h2;
} else {
echo h2Not sent/h2;
}
/code
If I don't get the access violation error, I get the message Sent 
successfully.  Yet, I don't receive any messages.

In the code for Mail_smtp (in Mail/smtp.php), I have added the following 
line just under the function declaration line for the send() method:

echo test;

When the access violation occurs, I get this line:

PHP has encountered an Access Violation at 0177A8B4test

From this, it appears to me that the access violation is not occurring 
when the class tries to send mail, but sometime earlier than that. 
However, I do not know much more about these Access Violoations, other 
than PHP is trying to access memory that it doesn't have permission to 
access.  I couldn't find anything at bugs.php.net or through Google that 
helped much with this problem.

Any help would be greatly appreciated.  I am on a tight deadline, so any 
help ASAP would be even more greatly appreciated.  ;-)

--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PEAR Sequences

2004-04-05 Thread Jeremy Clifton
Greetings,

Has anyone out there transitioned an existing app from using the 
mysql_* functions in PHP to PEAR DB?

I'm re-writing an existing PHP application, and I'm required to utilize 
PEAR's DB class as the database layer. Currently, the application is 
using the mysql_* functions to access the database and the primary 
key/identity column is using AUTO_INCREMENT to calculate the id for 
each record in several tables.

I realize that PEAR doesn't provide direct access to the last insert id 
(like I could get with mysql_insert_id()), and instead utilizes the 
sequences facility to emulate AUTO_INCREMENT (I'm assuming this is to 
provide similar functionality to some engines that don't have 
AUTO_INCREMENT). So, I need to have a seamless way to transition from 
using the AUTO_INCREMENT.

In experimenting, I've seen that when creating a sequence, PEAR DB 
creates a table named {$sequence_name}_seq and that table contains a 
single record with a single column that contains the last used sequence 
id.

So, let's assume I have a table called item_master, and I'm going to 
utilize a sequence I'm going to name item_master as well. Normally PEAR 
would create an item_master_seq table and keep track of the unique ID 
in that table. When I implement the new code, can I just create a 
item_master_seq table in the production database with the appropriate 
characteristics, update the record in that table to the next available 
id for the item_master table, and then turn off AUTO_INCREMENT on the 
table? In experimenting, this appears to be the case, but since I'm 
going to updating a production application, but I want to be absolutely 
sure this isn't going to cause any unforseen problems before I do this.

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


Re: [PHP] Question, what to do when finding an error while validating data

2004-04-05 Thread Jason Giangrande
Mike Zornek wrote:

Oops, forgot to send my original response to the list last time.

On 4/5/04 1:33 PM, Jason Giangrande [EMAIL PROTECTED] wrote:
What I usually do is create a select box that has only the values of the
enum.  That way no one should be able to (in theory) put any value other
than the ones you set.  You could also code up a check that runs before
you build your sql query. Simply check that if the value of the input of
that enum field is anything other than what you expect, change it to
your default then inset it into your database.


I am going to create a select box, but am still trying to write enough tests
to catch myself if I try to do something foolish. The in theory part is
what I'm trying to check for. :-)
I questions is, if someone tries to set the var to an invalid type should I
throw a warning, or die or do nothing and just use the default or previous
value. I'm inclined to stay away from the last option cause it invites
strangeness to people who might be new to the system.
As long as register_globals is set to off what come in from your select 
box should be used as the value of the enum field.  It is always best to 
do as much data validation as you feel is worth it.  IMO, in the case of 
using a select box to set the values of an enum MYSQL field, (unless 
this application is for something that is really security conscience, 
like banking or something), I feel I can usually trust the select field. 
 Remember that if someone tries to set the enum filed to something 
other than what is specified, an empty string will be stored. 
Therefore, when you are reading from the database you could always check 
for that, too.

--
Jason Giangrande [EMAIL PROTECTED]
http://www.giangrande.org
http://www.dogsiview.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Printer Functions

2004-04-05 Thread jon roig
Do you have the option of printing through Word or something similar?

We had the same problem and ended up saving the file to a cache and
using COM objects to print to the default printer through Word.

The code looks a bit like this... Of course, it expects you to define
the $saveFile as the file it's trying to open.

?
// initialize the word components
$word = new COM(word.application) or die(Unable to instantiate
Word);

print Loaded word version ($word-Version)\n;
$word-visible = true;
$word-Documents-Add();
 
// open the file
$word-Documents-Open($saveFile);

// output the file to the default printer
$word-ActiveDocument-PrintOut(1);

// shutdown word
$word-Quit();

?

-- jon

---
jon roig
web developer
email: [EMAIL PROTECTED]
phone: 888.230.7557

-Original Message-
From: Lou Apolonia [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 05, 2004 6:02 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Printer Functions


My question involves sending html to the printer to be printed properly.
Here is my code:

$handle = printer_open('Lexmark Z25-Z35'); printer_start_doc($handle,
test); printer_start_page($handle);

printer_set_option($handle, PRINTER_MODE, 'raw');
printer_set_option($handle, PRINTER_PAPER_FORMAT,
PRINTER_FORMAT_LETTER); $file =
file_get_contents('http://localhost/'.$page.'.php?mid='.$mid);
printer_draw_text($handle, $file, 10, 10);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

When this code runs, a page prints .. However all that prints is the
html source, and it only prints one line across the top of the page and
nothing else.  How does one send html to the printer and have the
rendered page print?

I've also tried using printer_write instead of printer_draw_text, but to
no avail.  

As always, any help is greatly appreciated.

Thank you in advance,
Lou

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


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.644 / Virus Database: 412 - Release Date: 3/26/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.644 / Virus Database: 412 - Release Date: 3/26/2004
 

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



[PHP] cURL upload meter

2004-04-05 Thread Steve Murphy
Can cURL be used to create an HTTP or FTP upload meter?

Steve

Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Jason Wong
On Monday 05 April 2004 22:46, [EMAIL PROTECTED] wrote:
 Thank you all for your ideas so far, however, I ahve gone through all my
 code, and cannot seem to find the culprit.

I believe it is a known bug with a particular old version of PHP, try using 
the latest.

-- 
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
--
/*
Please forgive me if, in the heat of battle, I sometimes forget which
side I'm on.
*/

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



Re: [PHP] Question, what to do when finding an error while validating data

2004-04-05 Thread John W. Holmes
From: Mike Zornek [EMAIL PROTECTED]


 I'm making a conscience effort to improve my PHP skills, that being making
 objects, unit testing, better error handling etc. So I have a questions.

 I have a database that is storing all of my records. One column is of type
 enum where the two legal values currently are home and work; work is
 default. I'm building a PHP object that will be my interface to the DB. In
 the object I have a variable called $EmailType which will hold the value
of
 the database column. I wrote some set and get methods to work with the
 variable and am now asking myself: What should I do if someone tries to
set
 $EmailType to a value that is not listed in the enum set?

Either throw an error and stop the whole action from completing, or just
silently ignore it and give it the default value.

I would go with the second action, personally. If you're giving the user a
clear way of choosing home or work, like radio buttons or a dropdown and
you receive another value, someone is trying to pull something. I'd log the
error somewhere for future analysis and then just give them the default.

---John Holmes...

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



Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread John W. Holmes
From: Jason Wong [EMAIL PROTECTED]

 On Monday 05 April 2004 22:46, [EMAIL PROTECTED] wrote:
  Thank you all for your ideas so far, however, I ahve gone through all my
  code, and cannot seem to find the culprit.

 I believe it is a known bug with a particular old version of PHP, try
using
 the latest.

It may be the old bug that dealt with a specific version of PHP and Apache2,
also. Either upgrading PHP or downgrading Apache to a version compatible
with PHP would solve the problem.

---John Holmes...

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



Re: [PHP] Sorting array of objects

2004-04-05 Thread Marek Kilimajer
Richard Harb wrote:
Hi there,

Supposed I have an array of objects, like:

$this[$i]-property1
$this[$i]-property2
is there any 'cheap' way to sort the array according to the values of
property1?
http://www.php.net/usort

Example:

function cmp($a, $b)
{
   if ($a-property1 == $b-property1) {
   return 0;
   }
   return ($a-property1  $b-property1) ? -1 : 1;
}
usort($object_array, cmp);

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


RE: [PHP] cURL upload meter

2004-04-05 Thread Pablo Gosse
Steve Murphy wrote:
 Can cURL be used to create an HTTP or FTP upload meter?
 
 Steve

By upload meter do you mean a progress bar which can tell a user how
much of a large upload has been processed thus far?

As far as I understand it PHP cannot access raw POST data so this cannot
be done with PHP alone.

There exists a set of perl/php scripts at
http://www.raditha.com/php/progress.php which does exactly this.

HTH.

Pablo

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



[PHP] allowed memory size of

2004-04-05 Thread Mathias Brito
Hello, I made a script that make a backup of the
entire site with the PHPZip lib. It's works well with
small sites, but when the size grow, i receive the
following message:

Fatal error: Allowed memory size of 1048680 bytes
exhausted at (null):0 (tried to allocate 170685 bytes)
in /srv/www/htdocs/zip/pclzip.lib.php on line 2386

What it mean, and what can i do to fix it...

regards
Mathias Brito

=
Mathias Brito
Universidade Estadual de Santa Cruz - UESC
Departamento de Ciências Exatas e Tecnológicas
Estudante do Curso de Ciência da Computação

__

Yahoo! Mail - O melhor e-mail do Brasil! Abra sua conta agora:
http://br.yahoo.com/info/mail.html

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



[PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread DvDmanDT
Hmm.. Are there any PHP settings that only applies to that vhost? Can you
please try to run PHP as CGI few tries.. If the input is corrupt, that
_could_ be caused by the Apache2 which accutually is marked as
experimental... Basicly, this would get currupt?

(wierd-var-test.php)
?
if($action=='post')
var_dump($_REQUEST);
else
{
?
form action=wierd-var-test.php?action=post
input type=text name=var
input type=submit
/form
?
}
?

Or are there some other details I've missed?
-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
[EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 This problem only seems to be happening on one of the virtual hosts on
this
 system, and I cannot seem to figure out just what it is.

 I have a simple form posting to search.php, with a text input field, with
a
 name of 'search'. And since this site is an internal site, register
globals
 are on, as we are not worried about anyone misuing any of the variables in
 use.

 In any even, this problem was noticed about a week ago, and it did not
exist
 before.

 After inputting some text into the search box, in this example, 'var',
sans
 quotes, and i hit submit... on the next page, I am just having it return
 just $search for testing, and, it comes back sporadically with: 'var', but
 most of the time, it comes back with:

 var^!#ndda/form

 or

 var4194092d098240928d12ed

 or

 var#c0c0c0

 or

 varput type=text

 etc. etc. it seems soemthing is somehow corrupting the variables, and I
 cannot seem to figure out what it might be. This has been working fine
until
 about the past week, and I cannot think of any major changes that may have
 happened within the past week that could have caused this... and as I
 mentioned above, it only seems to be this one virtual host. And ai also
 compared with backups of all of y included files at the beginnings and
ends
 of each script from before this problem started happening, and I can see
no
 major changes in any of them. And, this is happening around all php
scripts
 on the site...

 I am running 4.3.4, with apache 2, FreeBSD 4.8, and the data is all stored
 on a vinum partition. The server has been rebooted, a fresh install of
 php... tried setting output buffering on and flushing it at the end of the
 script(s), however, they seem to get hacked up when doing that, so I stay
 away from that band-aid fix...I am using sessions as well, as a few
scripts
 within the site store session variables... and also using SMBAuth to do
 authentication from our domain controller...

 I've been pulling out my hair for 4 days straight on this issue, and I am
 all out of ideas, any help would be *GREATLY* appreciated!

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



Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Blake Schroeder
One problem
wrong
form action=wierd-var-test.php?action=post
right
form action=wierd-var-test.php method=post
?action is a variable with a value of post
-Blake

DvDmanDT wrote:

Hmm.. Are there any PHP settings that only applies to that vhost? Can you
please try to run PHP as CGI few tries.. If the input is corrupt, that
_could_ be caused by the Apache2 which accutually is marked as
experimental... Basicly, this would get currupt?
(wierd-var-test.php)
?
if($action=='post')
var_dump($_REQUEST);
else
{
?
form action=wierd-var-test.php?action=post
input type=text name=var
input type=submit
/form
?
}
?
Or are there some other details I've missed?
 

--

+-+-++
| Blake Schroeder | Owner/Developer |lhwd.net|
+--(http://www.lhwd.net)+--/3174026352\--+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Blake Schroeder
Is this what your are trying to do?
?php
$var = $_POST['var'];
   

if($var)
var_dump($_REQUEST);
else
{
?
form action=index.php method=post
input type=text name=var
input type=submit
/form
?
  }
?
DvDmanDT wrote:

Hmm.. Are there any PHP settings that only applies to that vhost? Can you
please try to run PHP as CGI few tries.. If the input is corrupt, that
_could_ be caused by the Apache2 which accutually is marked as
experimental... Basicly, this would get currupt?
(wierd-var-test.php)
?
if($action=='post')
var_dump($_REQUEST);
else
{
?
form action=wierd-var-test.php?action=post
input type=text name=var
input type=submit
/form
?
}
?
Or are there some other details I've missed?
 

--

+-+-++
| Blake Schroeder | Owner/Developer |lhwd.net|
+--(http://www.lhwd.net)+--/3174026352\--+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Daniel Clark
I agree.   I believe the default FORM METHOD is GET.

 One problem
 wrong
 form action=wierd-var-test.php?action=post
 right
 form action=wierd-var-test.php method=post
 ?action is a variable with a value of post

 -Blake


 DvDmanDT wrote:

Hmm.. Are there any PHP settings that only applies to that vhost? Can you
please try to run PHP as CGI few tries.. If the input is corrupt, that
_could_ be caused by the Apache2 which accutually is marked as
experimental... Basicly, this would get currupt?

(wierd-var-test.php)
?
if($action=='post')
var_dump($_REQUEST);
else
{
?
form action=wierd-var-test.php?action=post
input type=text name=var
input type=submit
/form

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



Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread DvDmanDT
Accutually, I intented ?action=post, and if($action=='post'), just forgot to
add method=post.. :p

-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
Blake Schroeder [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 One problem
 wrong
 form action=wierd-var-test.php?action=post
 right
 form action=wierd-var-test.php method=post
 ?action is a variable with a value of post

 -Blake


 DvDmanDT wrote:

 Hmm.. Are there any PHP settings that only applies to that vhost? Can you
 please try to run PHP as CGI few tries.. If the input is corrupt, that
 _could_ be caused by the Apache2 which accutually is marked as
 experimental... Basicly, this would get currupt?
 
 (wierd-var-test.php)
 ?
 if($action=='post')
 var_dump($_REQUEST);
 else
 {
 ?
 form action=wierd-var-test.php?action=post
 input type=text name=var
 input type=submit
 /form
 ?
 }
 ?
 
 Or are there some other details I've missed?
 
 

 -- 

 +-+-++
 | Blake Schroeder | Owner/Developer |lhwd.net|
 +--(http://www.lhwd.net)+--/3174026352\--+

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



Re: [PHP] Question, what to do when finding an error while validating data

2004-04-05 Thread Mike Zornek
Thanks the feedback so far. To expand the scope of my issue past enums
(which by their limited nature are easy to check and set defaults) let me
ask this...

There is a column called Address in my email table, Thus I am creating a PHP
object called Email to interact with it. The Address variable of this object
will hold a string like [EMAIL PROTECTED].

In the setAddress method should I check for a valid email address and throw
a warning then? And if so how?

Or should I simply create a method isValidAddress and do the verification in
my own interface code?

~ Mike
-
Mike Zornek
Web Designer, Media Developer, Programmer and Geek
Personal site: http://MikeZornek.com
New Project: http://WebDevWiki.com

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



Re: [PHP] Question, what to do when finding an error whilevalidating data

2004-04-05 Thread John W. Holmes
From: Mike Zornek [EMAIL PROTECTED]

 There is a column called Address in my email table, Thus I am creating a
PHP
 object called Email to interact with it. The Address variable of this
object
 will hold a string like [EMAIL PROTECTED].

 In the setAddress method should I check for a valid email address and
throw
 a warning then? And if so how?

 Or should I simply create a method isValidAddress and do the verification
in
 my own interface code?

Either way I would create a ValidAddress() method. I would use it as an
interface, but you could also have the default action of the set() method
also check it or have the validation within set() controlled by some flag.

---John Holmes...

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



[PHP] Bug with multipart/form-data ?

2004-04-05 Thread gayard
Hi. 

I have a form in a page 1, that POSTs a file and some hidden's to page 2. If 
the file size is bigger that the max in php.ini, in page 2,  $_POST is 
empty. 

In the mood for a look ? 

upload.html: 

html 
body 

h1Attach your file here:/h1 
form name=anexar action=upload2.php enctype=multipart/form-data 
method=post onSubmit=return(validar(this)); 
input type=hidden name=duck value=duck / 
input type=file name=arquivo / 
input type=hidden name=pig value=pig / 
input type=submit value=Sub ! / 
/form 
/body 
/html 

upload2.php: 

pre 
?php 
var_dump($_POST); 
var_dump($_FILES); 
? 
/pre 

$_POST is empty... 

Is this a bug ? Or have I done some wrong ? 

Thanks 
Leonel 

_
Voce quer um iGMail protegido contra vírus e spams? 
Clique aqui: http://www.igmailseguro.ig.com.br


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

Re: [PHP] Re: Weird variable issue encountered... help needed!

2004-04-05 Thread Ben Ramsey
Just don't use register globals and use if ($_POST) instead of 
if($action=='post') so you don't have to include that ?action=post in 
the query string of your action.

Dvdmandt wrote:
Accutually, I intented ?action=post, and if($action=='post'), just forgot to
add method=post.. :p
--
Regards,
 Ben Ramsey
 http://benramsey.com
 http://www.phpcommunity.org/wiki/People/BenRamsey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Bug with multipart/form-data ?

2004-04-05 Thread Jay Blanchard
[snip]
I have a form in a page 1, that POSTs a file and some hidden's to page
2. If 
the file size is bigger that the max in php.ini, in page 2,  $_POST is 
empty. 
[/snip]

Why, of course it is! The php.ini sets the max file size $_POST will be
empty because it would not be allowed to load. You have two choices;

A. increase the max file size in the php.ini
2. reduce the size of the file being uploaded.

It is not a bug.

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



[PHP] Re: session_exist() ?? Can this be done?

2004-04-05 Thread Monty
Thanks, Aaron, I tried this method and it appears to work just fine. Here's
a simplified version of what I'm doing:

if (isset($_COOKIE[session_name()])) {

session_start();

if ($_SESSION['loggedin']  'yea_baby';

session_destroy();
$_SESSION = array();
// Return to log-in page to re-authenticate.
header(Location:/login.php);
}

So, this allows me to check to see if a session exists without having to
first start the session. If the cookie is found, then the session is started
and verified by checking a value. If the session value isn't there, then I
destroy the session, clear out the $_SESSION vars and send back to log-in
pgae. This only works if you are restricting passing sessions IDs via a
cookie, which I am doing to make my sessions a bit more secure.

Monty


 From: [EMAIL PROTECTED] (Aaron Christopher Vonderhaar)
 Newsgroups: php.general
 Date: Mon, 05 Apr 2004 00:43:52 -0400
 To: [EMAIL PROTECTED]
 Subject: Re: session_exist() ?? Can this be done?
 
 I've been doing exactly that, it works great.  I use,
 
 $sessid = $_COOKIE[PHPSESSID];
 
 if ( isset($sessid) ) {
 session_start();
 } 
 
 I use 'if( isset($sessid) )' in the rest of the code if there are things
 that should only be done if there is a session.  Only my login
 authentication page starts the session if there isn't a cookie.  Of course,
 for security you ought to verify the session after starting it, and unset
 $sessid (and destroy_session() ) if something screwy is going on.
 
 The reason I set things up like this is so that users are not bothered with
 cookies unless they need to be.  I use cookies for the administration side
 of the site, but casual users don't need a session, so why should they have
 a cookie? -- I'm a not a proponent of passing around useless data :).
 
 Aaron VonderHaar
 ([EMAIL PROTECTED]) 

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



Re: [PHP] Bug with multipart/form-data ?

2004-04-05 Thread John W. Holmes
From: Jay Blanchard [EMAIL PROTECTED]
  [snip]
  I have a form in a page 1, that POSTs a file and some hidden's to page
  2. If
  the file size is bigger that the max in php.ini, in page 2,  $_POST is
  empty.
  [/snip]

 Why, of course it is! The php.ini sets the max file size $_POST will be
 empty because it would not be allowed to load. You have two choices;

 A. increase the max file size in the php.ini
 2. reduce the size of the file being uploaded.

 It is not a bug.

I understand what you're saying, and maybe the OP will agree with me here,
but does that seem like the natural way for it to be handled? Shouldn't
$_FILES be empty and $_POST still have the rest of the posted data? PHP
decides to reject the file, but why does it reject the rest of the post
data, also?

Maybe off-topic for this list, but if that's what the OP was talking about,
then I've got to kind of agree with him.

---John Holmes...

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



Re: [PHP] Re: session_exist() ?? Can this be done?

2004-04-05 Thread Red Wingate
Hi,

just on a side-note, the session is not always kept in a cookie ( if 
cookies are deactivated the session is saved in the _GET or _POST variables.

A check for $_REQUEST[session_name()] might help you some more but can 
be exploited quite fast

eg: index.php?SID=foo

I guess the best way to solve your problem would be to set a _SESSION 
variable on creation and check for it's presence

if ( isset ( $_SESSION['session_activ'] )
AND $_SESSION['session_activ'] === TRUE ) {
  // session runnning
} else {
  // no session running
}
  -- red

[...]
Thanks, Aaron, I tried this method and it appears to work just fine. Here's
a simplified version of what I'm doing:
if (isset($_COOKIE[session_name()])) {

session_start();

if ($_SESSION['loggedin']  'yea_baby';

session_destroy();
$_SESSION = array();
// Return to log-in page to re-authenticate.
header(Location:/login.php);
}
[...]

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


Re: [PHP] Re: session_exist() ?? Can this be done?

2004-04-05 Thread Red Wingate
Again,

as a sidenote, this is the first example of the PHP session documentation:

[ quote - http://de.php.net/session ]
?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
   $_SESSION['count'] = 0;
} else {
   $_SESSION['count']++;
}
?
[ /quote ]
When using exactly this script you could check wether $_SESSION['count'] 
equals 0 to make sure the session was just created.

  -- red again :-)

Red Wingate wrote:

Hi,

just on a side-note, the session is not always kept in a cookie ( if 
cookies are deactivated the session is saved in the _GET or _POST 
variables.

A check for $_REQUEST[session_name()] might help you some more but can 
be exploited quite fast

eg: index.php?SID=foo

I guess the best way to solve your problem would be to set a _SESSION 
variable on creation and check for it's presence

if ( isset ( $_SESSION['session_activ'] )
AND $_SESSION['session_activ'] === TRUE ) {
  // session runnning
} else {
  // no session running
}
  -- red

[...]

Thanks, Aaron, I tried this method and it appears to work just fine. 
Here's
a simplified version of what I'm doing:

if (isset($_COOKIE[session_name()])) {

session_start();
if ($_SESSION['loggedin']  'yea_baby';
session_destroy();
$_SESSION = array();
// Return to log-in page to re-authenticate.
header(Location:/login.php);
}
[...]



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


[PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Monty
I am trying to use fewer resources and processes when making database
connections in my scripts, so, upon the first call to make a DB connection,
I store the Link Resource ID in a constant variable that can be accessed by
all other functions that need a DB connection, like this...

function connect_db() {

if (!defined('_CONNECT_DB')) {

$result = @mysql_pconnect(localhost, Username, Password);
@mysql_select_db(database_name);
define('_CONNECT_DB', $result);
}
return _CONNECT_DB;

I call this function this way...

$query = SELECT * FROM table;
$connid = connect_db();
$result = mysql_query($query, $connid);


What's odd is that this works for the first query, but after that the
Resource Link ID stored in _CONNECT_DB ceases to work, making MySQL issue
the error: mysql_query(): 4 is not a valid MySQL-Link resource...

Is there any reason why this isn't working? Normally I store the Resource
Link ID in a local variable that I can re-use with no problem, so, I can't
understand why storing the Resource Link ID in a constant var won't work? Is
it not possible to re-use the same connection for multiple queries to
different tables in the DB? I know I can do this if the Resource Link ID is
assigned to a local var, so, maybe it can't be stored in a constant var??

Only other solution I can think of is to use non-persistent connections and
simply make a connection to the DB then immediately disconnect for each
function that needs DB access, but, I'm wondering if this will create more
overhead and overload the database with too many connections?

I've searched and read just about everything I could find about exactly how
PHP and MySQL work together, but, if there's anything that explains in
detail exactly what is happening when you call mysql_connect or mysql_query,
please point me in its direction.

Any input on this is most appreciated!

Monty

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



Re: [PHP] Bug with multipart/form-data ?

2004-04-05 Thread DvDmanDT
Maybe the post_max_size is also exceeded, and therefore it's handled with
sense I think.. Otherwise I'm not sure I think this is handled the right
way, if it's only upload_max_filesize that's exceeded.

-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
John W. Holmes [EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]
 From: Jay Blanchard [EMAIL PROTECTED]
   [snip]
   I have a form in a page 1, that POSTs a file and some hidden's to page
   2. If
   the file size is bigger that the max in php.ini, in page 2,  $_POST is
   empty.
   [/snip]
 
  Why, of course it is! The php.ini sets the max file size $_POST will be
  empty because it would not be allowed to load. You have two choices;
 
  A. increase the max file size in the php.ini
  2. reduce the size of the file being uploaded.
 
  It is not a bug.

 I understand what you're saying, and maybe the OP will agree with me here,
 but does that seem like the natural way for it to be handled? Shouldn't
 $_FILES be empty and $_POST still have the rest of the posted data? PHP
 decides to reject the file, but why does it reject the rest of the post
 data, also?

 Maybe off-topic for this list, but if that's what the OP was talking
about,
 then I've got to kind of agree with him.

 ---John Holmes...

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



Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Matt Matijevich
[snip]
function connect_db() {

if (!defined('_CONNECT_DB')) {

$result = @mysql_pconnect(localhost, Username,
Password);
@mysql_select_db(database_name);
define('_CONNECT_DB', $result);
}
return _CONNECT_DB;

I call this function this way...

$query = SELECT * FROM table;
$connid = connect_db();
$result = mysql_query($query, $connid);

[/snip]

I think you want to look into pass by reference.

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



Re: [PHP] Re: session_exist() ?? Can this be done?

2004-04-05 Thread Monty
Hi Red... Actually, I have my site set to only use cookies for storing
session ids to make it more secure and so that session ids aren't passed via
the URL. Only problem with checking for existence of a session using your
method is that you have to first start the session, which is what I'm trying
to avoid. I only want to create a session for a user that I know has already
been authenticated first, which for my site seems to be the existence of the
session cookie.

Monty

 just on a side-note, the session is not always kept in a cookie ( if
 cookies are deactivated the session is saved in the _GET or _POST variables.
 
 A check for $_REQUEST[session_name()] might help you some more but can
 be exploited quite fast
 
 eg: index.php?SID=foo
 
 I guess the best way to solve your problem would be to set a _SESSION
 variable on creation and check for it's presence
 
 if ( isset ( $_SESSION['session_activ'] )
 AND $_SESSION['session_activ'] === TRUE ) {
 // session runnning
 } else {
 // no session running
 }
 
 -- red
 
 [...]
 Thanks, Aaron, I tried this method and it appears to work just fine. Here's
 a simplified version of what I'm doing:
 
 if (isset($_COOKIE[session_name()])) {
 
 session_start();
 
 if ($_SESSION['loggedin']  'yea_baby';
 
 session_destroy();
 $_SESSION = array();
 // Return to log-in page to re-authenticate.
 header(Location:/login.php);
 }
 
 [...]

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



[PHP] Re: Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Justin Patrin
Monty wrote:

I am trying to use fewer resources and processes when making database
connections in my scripts, so, upon the first call to make a DB connection,
I store the Link Resource ID in a constant variable that can be accessed by
all other functions that need a DB connection, like this...
function connect_db() {

if (!defined('_CONNECT_DB')) {

$result = @mysql_pconnect(localhost, Username, Password);
@mysql_select_db(database_name);
define('_CONNECT_DB', $result);
}
return _CONNECT_DB;
I call this function this way...

$query = SELECT * FROM table;
$connid = connect_db();
$result = mysql_query($query, $connid);
What's odd is that this works for the first query, but after that the
Resource Link ID stored in _CONNECT_DB ceases to work, making MySQL issue
the error: mysql_query(): 4 is not a valid MySQL-Link resource...
Is there any reason why this isn't working? Normally I store the Resource
Link ID in a local variable that I can re-use with no problem, so, I can't
understand why storing the Resource Link ID in a constant var won't work? Is
it not possible to re-use the same connection for multiple queries to
different tables in the DB? I know I can do this if the Resource Link ID is
assigned to a local var, so, maybe it can't be stored in a constant var??
Only other solution I can think of is to use non-persistent connections and
simply make a connection to the DB then immediately disconnect for each
function that needs DB access, but, I'm wondering if this will create more
overhead and overload the database with too many connections?
I've searched and read just about everything I could find about exactly how
PHP and MySQL work together, but, if there's anything that explains in
detail exactly what is happening when you call mysql_connect or mysql_query,
please point me in its direction.
Any input on this is most appreciated!

Monty
A define is pretty much for strings only, not objects or resources. Try 
using $GLOBALS['_CONNECT_DB'] instead.

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


Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Monty
It appears you can't pass constant vars by reference, or am I missing your
point? I understand passing vars by reference, but not sure where you
suggest I need to use it. I tried define('_CONNECT_DB', $result); and
return _CONNECT_DB; separately, but neither worked.

 [snip]
 function connect_db() {
 
 if (!defined('_CONNECT_DB')) {
 
 $result = @mysql_pconnect(localhost, Username,
 Password);
 @mysql_select_db(database_name);
 define('_CONNECT_DB', $result);
 }
 return _CONNECT_DB;
 
 I call this function this way...
 
 $query = SELECT * FROM table;
 $connid = connect_db();
 $result = mysql_query($query, $connid);
 
 [/snip]
 
 I think you want to look into pass by reference.

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



[PHP] Re: Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Monty
 A define is pretty much for strings only, not objects or resources. Try
 using $GLOBALS['_CONNECT_DB'] instead.

I tried this, but, same results. If I store the Resource ID from a
mysql_pconnect() in $GLOBALS['_CONNECT_DB'] and then call...

mysql_query($query, $GLOBALS['_CONNECT_DB']);

PHP gives me the following error:

4 is not a valid MySQL-Link resource

When I look into this var, here's what I see:

Resource id #4

This is the same that was stored in the constant var, so, it appears that
whether it's a Global or Constant isn't making a difference.

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



[PHP] Code Review PLEASE !!!

2004-04-05 Thread Matthew Oatham
Hi,

I am a newbie PHP programmer, I have some code that works but I want some tips on how 
I an Improve my code, i.e. should I be doing my updates / deletes on same php page as 
the display page, am I using transactions correctly, am I capturing SQL errors 
correctly am I handling form data as efficient as possible?

My code displays some information from a database and gives users the chance to delete 
or edit any field and is as follows: 

? 

include (../db.php);

$acton = $_POST['action'];

if ($action == update) {
  if (isset($_POST['delete'])) {
$deleteList = join(', ', $_POST['delete']);
  }

  //Enter info into the database
  mysql_query(begin);
  foreach ($_POST['fleet_id'] as $key = $value) {
$fleetCode = $_POST['fleet_code'][$key];
$historyUrl = $_POST['history_url'][$key];
$downloadUrl = $_POST['download_url'][$key];
mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode', history_url = 
'$historyUrl', download_url = '$downloadUrl' WHERE fleet_id = $value) or die 
(mysql_error());
  }
  if ($deleteList) {
mysql_query(DELETE FROM imp_fleet WHERE fleet_id IN($deleteList)) or die 
(mysql_error());
  }
  if (mysql_error()) {
echo (There has been an error with your edit / delete request. Please contact the 
webmaster);
mysql_query(rollback);
  } else {
mysql_query(commit);
  }
}

?
html
head
  title/title
/head
body
form name=edit method=post
h1Edit / Delete Fleet/h1
  table
tr
  tdFleet Code/td
  tdDownload URL/td
  tdHistory URL/td
  tdDelete/td
/tr
? 
$sql = mysql_query(SELECT fleet_id, fleet_code, download_url, history_url FROM 
imp_fleet);

if (mysql_num_rows($sql)  0) { 
while ($row = mysql_fetch_array($sql)) {
?  
tr 
  tdinput type=text name=fleet_code[] 
value=?=$row['fleet_code']?input type=hidden name=fleet_id[] 
value=?=$row['fleet_id']?/td
  tdinput type=text name=download_url[] 
value=?=$row['download_url']?/td
  tdinput type=text name=history_url[] 
value=?=$row['history_url']?/td
  tdinput type=checkbox name=delete[] value=?=$row['fleet_id']?/td   
   
/tr
? 
}
}
?
tr 
  td colsapn=4
table
  tr
tdinput type=hidden name=action value=updateinput type=reset 
value=cancel/td
td colspan=2input type=submit value=submit/td  
  /tr
/table
  /td
/tr
  /table
/form
/body
/html

Thanks for your time and feedback.

Matt

Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Daniel Clark
 I am a newbie PHP programmer, I have some code that works but I want some
 tips on how I an Improve my code, i.e. should I be doing my updates /

 include (../db.php);

 Some things I do is use single quotes   include '../db.php' ;
 (they are slightly faster, no replacments looking for $ variables)

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



[PHP] Re: Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Justin Patrin
Monty wrote:

A define is pretty much for strings only, not objects or resources. Try
using $GLOBALS['_CONNECT_DB'] instead.


I tried this, but, same results. If I store the Resource ID from a
mysql_pconnect() in $GLOBALS['_CONNECT_DB'] and then call...
mysql_query($query, $GLOBALS['_CONNECT_DB']);

PHP gives me the following error:

4 is not a valid MySQL-Link resource

When I look into this var, here's what I see:

Resource id #4

This is the same that was stored in the constant var, so, it appears that
whether it's a Global or Constant isn't making a difference.
How are you setting the global?

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


Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Jordan S. Jones
Wells first of all, you are going to want better form input validation.
For Example:
foreach ($_POST['fleet_id'] as $key = $value) {
   $fleetCode = $_POST['fleet_code'][$key];
   $historyUrl = $_POST['history_url'][$key];
   $downloadUrl = $_POST['download_url'][$key];
   mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode', history_url = 
'$historyUrl', download_url = '$downloadUrl' WHERE fleet_id = $value) or die 
(mysql_error());
 }
Are you sure that $_POST['fleet_id'] is valid? or even a number?

What happens with $_POST['fleet_id'] == '1 = 1'??  Well, long story 
short, imp_fleet has no more records.

Just a simple example of a huge problem.

Jordan S. Jones

Matthew Oatham wrote:

Hi,

I am a newbie PHP programmer, I have some code that works but I want some tips on how I an Improve my code, i.e. should I be doing my updates / deletes on same php page as the display page, am I using transactions correctly, am I capturing SQL errors correctly am I handling form data as efficient as possible?

My code displays some information from a database and gives users the chance to delete or edit any field and is as follows: 

? 

include (../db.php);

$acton = $_POST['action'];

if ($action == update) {
 if (isset($_POST['delete'])) {
   $deleteList = join(', ', $_POST['delete']);
 }
 //Enter info into the database
 mysql_query(begin);
 foreach ($_POST['fleet_id'] as $key = $value) {
   $fleetCode = $_POST['fleet_code'][$key];
   $historyUrl = $_POST['history_url'][$key];
   $downloadUrl = $_POST['download_url'][$key];
   mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode', history_url = 
'$historyUrl', download_url = '$downloadUrl' WHERE fleet_id = $value) or die 
(mysql_error());
 }
 if ($deleteList) {
   mysql_query(DELETE FROM imp_fleet WHERE fleet_id IN($deleteList)) or die 
(mysql_error());
 }
 if (mysql_error()) {
   echo (There has been an error with your edit / delete request. Please contact the 
webmaster);
   mysql_query(rollback);
 } else {
   mysql_query(commit);
 }
}
?
html
head
 title/title
/head
body
form name=edit method=post
h1Edit / Delete Fleet/h1
 table
   tr
 tdFleet Code/td
 tdDownload URL/td
 tdHistory URL/td
 tdDelete/td
   /tr
? 
$sql = mysql_query(SELECT fleet_id, fleet_code, download_url, history_url FROM 
   imp_fleet);

if (mysql_num_rows($sql)  0) { 
while ($row = mysql_fetch_array($sql)) {
?  
   tr 
 tdinput type=text name=fleet_code[] value=?=$row['fleet_code']?input type=hidden name=fleet_id[] value=?=$row['fleet_id']?/td
 tdinput type=text name=download_url[] value=?=$row['download_url']?/td
 tdinput type=text name=history_url[] value=?=$row['history_url']?/td
 tdinput type=checkbox name=delete[] value=?=$row['fleet_id']?/td  
   /tr
? 
}
}
?
   tr 
 td colsapn=4
   table
 tr
   tdinput type=hidden name=action value=updateinput type=reset value=cancel/td
   td colspan=2input type=submit value=submit/td  
 /tr
   /table
 /td
   /tr
 /table
/form
/body
/html

Thanks for your time and feedback.

Matt
 

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


Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Matthew Oatham
Yes I agree I need some validation, dunno whether to do server or client
side validation. I don't think the fleet_id example will be a problem though
as this is retrieved from the database where the field is an int.

Thanks for your feedback

Matt
- Original Message - 
From: Jordan S. Jones [EMAIL PROTECTED]
To: Matthew Oatham [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Monday, April 05, 2004 11:56 PM
Subject: Re: [PHP] Code Review PLEASE !!!


 Wells first of all, you are going to want better form input validation.
 For Example:

 foreach ($_POST['fleet_id'] as $key = $value) {
 $fleetCode = $_POST['fleet_code'][$key];
 $historyUrl = $_POST['history_url'][$key];
 $downloadUrl = $_POST['download_url'][$key];
 mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode',
history_url = '$historyUrl', download_url = '$downloadUrl' WHERE fleet_id =
$value) or die (mysql_error());
   }


 Are you sure that $_POST['fleet_id'] is valid? or even a number?

 What happens with $_POST['fleet_id'] == '1 = 1'??  Well, long story
 short, imp_fleet has no more records.

 Just a simple example of a huge problem.

 Jordan S. Jones

 Matthew Oatham wrote:

 Hi,
 
 I am a newbie PHP programmer, I have some code that works but I want some
tips on how I an Improve my code, i.e. should I be doing my updates /
deletes on same php page as the display page, am I using transactions
correctly, am I capturing SQL errors correctly am I handling form data as
efficient as possible?
 
 My code displays some information from a database and gives users the
chance to delete or edit any field and is as follows:
 
 ?
 
 include (../db.php);
 
 $acton = $_POST['action'];
 
 if ($action == update) {
   if (isset($_POST['delete'])) {
 $deleteList = join(', ', $_POST['delete']);
   }
 
   //Enter info into the database
   mysql_query(begin);
   foreach ($_POST['fleet_id'] as $key = $value) {
 $fleetCode = $_POST['fleet_code'][$key];
 $historyUrl = $_POST['history_url'][$key];
 $downloadUrl = $_POST['download_url'][$key];
 mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode',
history_url = '$historyUrl', download_url = '$downloadUrl' WHERE fleet_id =
$value) or die (mysql_error());
   }
   if ($deleteList) {
 mysql_query(DELETE FROM imp_fleet WHERE fleet_id IN($deleteList))
or die (mysql_error());
   }
   if (mysql_error()) {
 echo (There has been an error with your edit / delete request.
Please contact the webmaster);
 mysql_query(rollback);
   } else {
 mysql_query(commit);
   }
 }
 
 ?
 html
 head
   title/title
 /head
 body
 form name=edit method=post
 h1Edit / Delete Fleet/h1
   table
 tr
   tdFleet Code/td
   tdDownload URL/td
   tdHistory URL/td
   tdDelete/td
 /tr
 ?
 $sql = mysql_query(SELECT fleet_id, fleet_code, download_url,
history_url FROM
 imp_fleet);
 
 if (mysql_num_rows($sql)  0) {
 while ($row = mysql_fetch_array($sql)) {
 ?
 tr
   tdinput type=text name=fleet_code[]
value=?=$row['fleet_code']?input type=hidden name=fleet_id[]
value=?=$row['fleet_id']?/td
   tdinput type=text name=download_url[]
value=?=$row['download_url']?/td
   tdinput type=text name=history_url[]
value=?=$row['history_url']?/td
   tdinput type=checkbox name=delete[]
value=?=$row['fleet_id']?/td
 /tr
 ?
 }
 }
 ?
 tr
   td colsapn=4
 table
   tr
 tdinput type=hidden name=action value=updateinput
type=reset value=cancel/td
 td colspan=2input type=submit value=submit/td
   /tr
 /table
   /td
 /tr
   /table
 /form
 /body
 /html
 
 Thanks for your time and feedback.
 
 Matt
 
 

 -- 
 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] Code Review PLEASE !!!

2004-04-05 Thread Gabriel Guzman
On Monday 05 April 2004 04:00 pm, Matthew Oatham wrote:
 Yes I agree I need some validation, dunno whether to do server or client
 side validation.

*both*  :) 
 
you should always do server side validation on any data, especially if you are 
going to be putting it into your database.   Client side validation, can be 
helpful to the user, but is easy to bypass. 

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



Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Gabriel Guzman
On Monday 05 April 2004 04:00 pm, Matthew Oatham wrote:

 I don't think the fleet_id example will be a problem
 though as this is retrieved from the database where the field is an int.

google for SQL injection and you will see why what you currently have may 
cause you some problems. 

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



Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Jordan S. Jones
If it were me I would do both Client and Server side validation.

The majority of the time the client side will suffice, but, simply put, 
because you don't/may not look at the HTML source of a web page, doesn't 
mean that nobody else does.

The fact of the matter is, you should not trust any data that comes from 
a form.  Even if the ids come from the database, you still want to 
ensure that they really are a valid numerical value or whatever your ids 
happen to be based upon.

Jordan S. Jones

Matthew Oatham wrote:

Yes I agree I need some validation, dunno whether to do server or client
side validation. I don't think the fleet_id example will be a problem though
as this is retrieved from the database where the field is an int.
Thanks for your feedback

Matt
- Original Message - 
From: Jordan S. Jones [EMAIL PROTECTED]
To: Matthew Oatham [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Monday, April 05, 2004 11:56 PM
Subject: Re: [PHP] Code Review PLEASE !!!

 

Wells first of all, you are going to want better form input validation.
For Example:
foreach ($_POST['fleet_id'] as $key = $value) {
   $fleetCode = $_POST['fleet_code'][$key];
   $historyUrl = $_POST['history_url'][$key];
   $downloadUrl = $_POST['download_url'][$key];
   mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode',
   

history_url = '$historyUrl', download_url = '$downloadUrl' WHERE fleet_id =
$value) or die (mysql_error());
 

 }

Are you sure that $_POST['fleet_id'] is valid? or even a number?

What happens with $_POST['fleet_id'] == '1 = 1'??  Well, long story
short, imp_fleet has no more records.
Just a simple example of a huge problem.

Jordan S. Jones

Matthew Oatham wrote:

   

Hi,

I am a newbie PHP programmer, I have some code that works but I want some
 

tips on how I an Improve my code, i.e. should I be doing my updates /
deletes on same php page as the display page, am I using transactions
correctly, am I capturing SQL errors correctly am I handling form data as
efficient as possible?
 

My code displays some information from a database and gives users the
 

chance to delete or edit any field and is as follows:
 

?

include (../db.php);

$acton = $_POST['action'];

if ($action == update) {
if (isset($_POST['delete'])) {
  $deleteList = join(', ', $_POST['delete']);
}
//Enter info into the database
mysql_query(begin);
foreach ($_POST['fleet_id'] as $key = $value) {
  $fleetCode = $_POST['fleet_code'][$key];
  $historyUrl = $_POST['history_url'][$key];
  $downloadUrl = $_POST['download_url'][$key];
  mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode',
 

history_url = '$historyUrl', download_url = '$downloadUrl' WHERE fleet_id =
$value) or die (mysql_error());
 

}
if ($deleteList) {
  mysql_query(DELETE FROM imp_fleet WHERE fleet_id IN($deleteList))
 

or die (mysql_error());
 

}
if (mysql_error()) {
  echo (There has been an error with your edit / delete request.
 

Please contact the webmaster);
 

  mysql_query(rollback);
} else {
  mysql_query(commit);
}
}
?
html
head
title/title
/head
body
form name=edit method=post
h1Edit / Delete Fleet/h1
table
  tr
tdFleet Code/td
tdDownload URL/td
tdHistory URL/td
tdDelete/td
  /tr
?
$sql = mysql_query(SELECT fleet_id, fleet_code, download_url,
 

history_url FROM
 

  imp_fleet);

if (mysql_num_rows($sql)  0) {
while ($row = mysql_fetch_array($sql)) {
?
  tr
tdinput type=text name=fleet_code[]
 

value=?=$row['fleet_code']?input type=hidden name=fleet_id[]
value=?=$row['fleet_id']?/td
 

tdinput type=text name=download_url[]
 

value=?=$row['download_url']?/td
 

tdinput type=text name=history_url[]
 

value=?=$row['history_url']?/td
 

tdinput type=checkbox name=delete[]
 

value=?=$row['fleet_id']?/td
 

  /tr
?
}
}
?
  tr
td colsapn=4
  table
tr
  tdinput type=hidden name=action value=updateinput
 

type=reset value=cancel/td
 

  td colspan=2input type=submit value=submit/td
/tr
  /table
/td
  /tr
/table
/form
/body
/html
Thanks for your time and feedback.

Matt

 

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

 




Re: [PHP] Re: session_exist() ?? Can this be done?

2004-04-05 Thread Jochem Maas
for those who haven't yet read it:

Monty wrote:
Hi Red... Actually, I have my site set to only use cookies for storing
session ids to make it more secure and so that session ids aren't passed via
why is this more secure? the cookies go over the same wire as the post/get.

with regard to security have a look at:
http://nl.php.net/manual/en/function.session-regenerate-id.php
I have personally thought about binding the IP addr of the initial 
request  to the session but I don't no if this a good idea (also IP 
spoofing gets round that.)

the URL. Only problem with checking for existence of a session using your
I doesn't sound like its a problem of the session existence (which does 
not define state) but of state (which the session stores) and this is 
something you define. every user who visits your site and hits more than 
one page instrinscally has (could have) a session, by default:
$_SESSION[ 'LOGGED_IN' ] = false;
and its set to true if a user successfully completes a login procedure 
(and presumably remains so until the session is destroy for whatever 
reason.)

method is that you have to first start the session, which is what I'm trying
to avoid. I only want to create a session for a user that I know has already
been authenticated first, which for my site seems to be the existence of the
session cookie.
to verify whether a session has been previously created for the browser, 
may be something like this:

session_start();
if(! isset($_SESSION[ 'HIT_COUNT' ]) ) {
$_SESSION[ 'HIT_COUNT' ] = 1;
} else {
$_SESSION[ 'HIT_COUNT' ]++; 
}
if ($_SESSION[ 'HIT_COUNT' ] == 1) {
echo 'hi new person! welcome to xyz.com';
}
which is just a variation of what what written below:

Monty


just on a side-note, the session is not always kept in a cookie ( if
cookies are deactivated the session is saved in the _GET or _POST variables.
A check for $_REQUEST[session_name()] might help you some more but can
be exploited quite fast
eg: index.php?SID=foo

I guess the best way to solve your problem would be to set a _SESSION
variable on creation and check for it's presence
if ( isset ( $_SESSION['session_activ'] )
AND $_SESSION['session_activ'] === TRUE ) {
// session runnning
} else {
// no session running
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Curt Zirzow
* Thus wrote Matthew Oatham ([EMAIL PROTECTED]):
 Hi,
 
 I am a newbie PHP programmer, I have some code that works but I want some tips on 
 how I an Improve my code, i.e. should I be doing my updates / deletes on same php 
 page as the display page, am I using transactions correctly, am I capturing SQL 
 errors correctly am I handling form data as efficient as possible?
 
 
 ? 

use full php tags: ?php

   if (isset($_POST['delete'])) {
 $deleteList = join(', ', $_POST['delete']);

be careful here!  if I add to the _POST  data something like
  delete%5B%5D=%29%20OR%281

then I just deleted all your records.

   //Enter info into the database
   mysql_query(begin);
   foreach ($_POST['fleet_id'] as $key = $value) {
 $fleetCode = $_POST['fleet_code'][$key];
 $historyUrl = $_POST['history_url'][$key];
 $downloadUrl = $_POST['download_url'][$key];

I would set up your array's so they are a little more readable and
dont rely on autoincrementing array key's. So your loop would look
something like this:

  foreach($_POST['fleets'] as $fleet_id = $fleet) {
 echo $fleet_id; // the fleet_id
 echo $fleet['code'];
 echo $fleet['urls']['history'];
 echo $fleet['ulrs']['download'];
 ...

 
 mysql_query(UPDATE imp_fleet SET fleet_code = '$fleetCode', history_url = 
 '$historyUrl', download_url = '$downloadUrl' WHERE fleet_id = $value) or die 
 (mysql_error());

escape your data that is untrusted, see http://php.net/mysql_real_escape_string

   }
   if ($deleteList) {
 mysql_query(DELETE FROM imp_fleet WHERE fleet_id IN($deleteList)) or die 
 (mysql_error());
   }
   if (mysql_error()) {

  this is never reached if there was an error since you die'd() on
  errors befor.
   }
 }
 ...

 while ($row = mysql_fetch_array($sql)) {
 ?  
 tr 
   tdinput type=text name=fleet_code[] 
 value=?=$row['fleet_code']?input type=hidden name=fleet_id[] 
 value=?=$row['fleet_id']?/td
   tdinput type=text name=download_url[] 
 value=?=$row['download_url']?/td
   tdinput type=text name=history_url[] 
 value=?=$row['history_url']?/td
   tdinput type=checkbox name=delete[] value=?=$row['fleet_id']?/td 
  

  // set up a variable for the input form names for easier reading.
  $var_name = 'fleets['.$row['fleet_id'].']';
  ?
   td
   input name=?php echo $var_name?[code]
   input name=?php echo $var_name?[urls][history]
   input name=?php echo $var_name?[urls][download]
   ...

I'd suggest not using the ?= shorthand also.

HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Richard Harb
Monday, April 5, 2004, 11:23:29 PM, you wrote:

 I am trying to use fewer resources and processes when making database
 connections in my scripts, so, upon the first call to make a DB connection,
 I store the Link Resource ID in a constant variable that can be accessed by
 all other functions that need a DB connection, like this...

 function connect_db() {

 if (!defined('_CONNECT_DB')) {

 $result = @mysql_pconnect(localhost, Username, Password);
 @mysql_select_db(database_name);
 define('_CONNECT_DB', $result);
 }
 return _CONNECT_DB;

snipped

From: http://www.php.net/manual/en/language.constants.php

Only scalar data (boolean, integer, float and string) can be contained
in constants.

--
somewhere in the manual it is said that while a resource or link or
some such identifier might look like an integer, it actually isn't.
So by extension it is not a scalar value and thus cannot be stored via
the means of a define().
Use a 'normal' variable instead.

Richard

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



[PHP] mysql_query problem with multi dim arrays

2004-04-05 Thread Andy B
hi...
i cant cut and paste my exact mysql query because it takes the '' stuff out doubles 
the $'s and the ,'s in the whole thing (dont know why but anyways...)...

i have a query that goes something like this:
mysql_query(insert into $GuestbookTable values(NULL, '$_SESSION[add][date]', 
'$_SESSION[add][name]', $_SESSION[add][email]..);

the problem i get is using the multi dimentional arrays to insert text and stuff all i 
actually get when i echo the query or do a real insert is:

echoed it would be something like:
insert into rnjresort.guestbook values(NULL, 'array([add]), 'array([add])', 
'array([add])', ...

any idea what the problem is here? do i have the '' in the wrong places?? i know that 
works on single dimention arrays but doubled?



Re: [PHP] includes

2004-04-05 Thread Richard Harb
Monday, April 5, 2004, 4:47:52 PM, you wrote:

 Hello all,
 I have a problem.  My directory list is similar to this:
root
 tmpl
 inc
 forums

snipped

 My question is in the test_form and message forums.  How do I do the include
 files to read from the tmpl and inc??

 I can get the include files to work as long as they are in the root (include
 tmpl/header.htm).

snipped

Check the online manual:
http://www.php.net/manual/en/function.dirname.php

and read the comments (bottom first and up ..)
good info there on that very subject.

Richard

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



Re: [PHP] Code Review PLEASE !!!

2004-04-05 Thread Jochem Maas
Matthew Oatham wrote:

Hi,
only use double quotes () if you want to have variables interpolated e.g.

$myVal = 'its amazing';
$x = wow $myVal;
think out about the way you layout your code - it helps when you
come back to it 12 months later ;-)
sanitize all incoming variables (POST/GET/COOKIE) by changing their type
or performing some other function on them to make them safe.
writing:
(int) $someVar;

means make $someVar an integer; which has the nice side affect of turn 
ALL strings into 0 (apart from those beginning with a number in which 
case it keeps the numbers but that is quite sane I think)

limit your use of temporary variables e.g: don't create $action if you 
are only going to use it on the next line - its a performance hit and 
looks unelegant - a good place for temp vars is to increase readability 
in your code, more often than not, I feel, readability is king.

DO:
if ($_POST['action'] == 'update') {
NOT:
$action = $_POST['action'];
if ($action == 'update') {
DO:
$action = perform_check_on_var( $_POST['action'],
array($arg1, $arg3),
$arg2 );
if ($action == 'update') {
speaking of readability -
comment you code; especially the bit the make your eyes water! google 
around for stuff like phpDoc or phpDocumentor; that will at the very 
least give you good tips on what to stuff put in your comments and how 
to define them (getting into this habit pays dividends later when 
documentation generation come into play - for which tools like 
phpDocumentor are written ;-) ... all kinda based on javaDoc (something 
to google ;-) as far as I can see.

if you are just starting out and its feasable why not give php5 a go - 
its feature complete and quite stable (RC1 currently); alot of the new 
features are really quite cool! besides as you learn you will not have 
to step over to a new version (which in itself can be a learning 
experience!).

BTW: there is nothing wrong with having one page handle all 
updates/deletes etc - although becareful of filesize, longfile are a 
pain to edit/maintain - in such case you maybe want to create functions 
of the update and delete code and call them from your main script.
At the end of the day its a matter of preference and application design 
choices which lead to one or the other scenario. try googling for 'Model 
View Controller PHP' - hopefully you'll get some useful code/examples of
request processing control which uses single entry points (i.e. a single 
page) to perform all actions.

lastly I made a few slight alterations to your example script:

?

include ('./db.php');

if ($_POST['action'] == 'update') {

  //Enter info into the database
  mysql_query(begin);
  if (isset($_POST['delete'])  @count($_POST['delete'])) {
foreach ($_POST['delete'] as $k = $val) {
(int) $_POST['delete'][ $k ];
if (! $_POST['delete'][ $k ]) {
unset($_POST['delete']);
}
}
if ($deleteList = join(', ', $_POST['delete'])) {
mysql_query(DELETE FROM imp_fleet
 WHERE fleet_id IN($deleteList))  
or die (mysql_error());
}   
  } else {
foreach ($_POST['fleet_id'] as $k = $val) {
$fleetCode   = (int) $_POST['fleet_code'][ $k ];
if (! $fleetcode) { continue; } 

$historyUrl  = str_replace(', '',
$_POST['history_url'][ $k ]);
$downloadUrl = str_replace(', '',
$_POST['download_url'][ $k ]);
	mysql_query(UPDATE imp_fleet SET
			fleet_code = '$fleetCode', 			history_url = '$historyUrl',
			download_url = '$downloadUrl'
		 WHERE fleet_id = $val)
		or die (mysql_error());
  }
  if (mysql_error()) {
echo (There has been an error with your edit / delete request. 
Please contact the webmaster);
mysql_query('rollback');
  } else {
mysql_query('commit');
  }
}
?

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


Re: [PHP] mysql_query problem with multi dim arrays

2004-04-05 Thread Richard Harb
Tuesday, April 6, 2004, 1:21:52 AM, you wrote:

 hi...
 i cant cut and paste my exact mysql query because it takes the ''
 stuff out doubles the $'s and the ,'s in the whole thing (dont know
 why but anyways...)...

 i have a query that goes something like this:
 mysql_query(insert into $GuestbookTable values(NULL,
 '$_SESSION[add][date]', '$_SESSION[add][name]',
 $_SESSION[add][email]..);

 the problem i get is using the multi dimentional arrays to insert
 text and stuff all i actually get when i echo the query or do a real
 insert is:

 echoed it would be something like:
 insert into rnjresort.guestbook values(NULL, 'array([add]),
 'array([add])', 'array([add])', ...

 any idea what the problem is here? do i have the '' in the wrong
 places?? i know that works on single dimention arrays but doubled?


Well, then again you can still write your query as:

$sql = INSERT INTO table (field1, field2, ..., fieldn)
$sql .=  VALUES (' . $ar['index1']['index2'][$i] . ' .
 ,' . $ar['index1']['index2'][$i] . ';


or some such ... close/open the strings in between :)

HTH

Richard


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



  1   2   >