php-general Digest 20 Aug 2005 09:49:57 -0000 Issue 3635

2005-08-20 Thread php-general-digest-help

php-general Digest 20 Aug 2005 09:49:57 - Issue 3635

Topics (messages 220976 through 220998):

Re: Unique user?
220976 by: Labunski

Document source code for PHP5
220977 by: Markus Fischer

Automated data upload for customers
220978 by: Brian Dunning
220979 by: Jasper Bryant-Greene
220980 by: Richard Lynch
220981 by: Jasper Bryant-Greene
220992 by: Richard Lynch

Re: PHP MySQL insert
220982 by: Richard Lynch

Re: preg_match
220983 by: Richard Lynch
220984 by: Richard Lynch
220985 by: Richard Lynch

Re: upload large files troubles
220986 by: Richard Lynch
220988 by: Jasper Bryant-Greene

php explained in sql
220987 by: John Taylor-Johnston
220990 by: Jasper Bryant-Greene

Re: php 5.04 register_globals aint acting right.
220989 by: Richard Lynch

Re: Week Days
220991 by: Richard Lynch
220994 by: Robert Cummings
220995 by: benc11.gmail.com
220996 by: benc11.gmail.com

Hardware Detection
220993 by: Saenal M
220997 by: Burhan Khalid

Super globals ?
220998 by: Wong HoWang

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:
php-general@lists.php.net


--
---BeginMessage---
Simply ad some info to the Cookies (including date and time). 
---End Message---
---BeginMessage---

Hi,

I'm currently using phpdoc.org to generated documentation of my code, 
but it doesn't seem to support PHP5. Interfaces are not recognized and 
function headers defined therein are parsed as public function.


Can someone recommend a documentation tool which supports the new PHP5 
syntax?


thanks,
- markus
---End Message---
---BeginMessage---
I have a system where I'm trying to facilitate a process for  
customers to upload data to me (basically a list of people), and have  
it go into a database. I can give them certain parameters, like it  
has to be a CSV file, delimited in such a way, etc. but can't ask  
much more of them than that, since people are largely stupid.  :)


And then there would be the usual multipart form upload where they  
select their file and send it up. I'd need to import it into MySQL.


Before I sit down and start coding this thing from scratch, does  
anyone know if there is something similar out there already that  
could give me a head start?


- Brian
---End Message---
---BeginMessage---

Brian Dunning wrote:
I have a system where I'm trying to facilitate a process for  customers 
to upload data to me (basically a list of people), and have  it go into 
a database. I can give them certain parameters, like it  has to be a CSV 
file, delimited in such a way, etc. but can't ask  much more of them 
than that, since people are largely stupid.  :)


For CSV, it's as simple as explode() the data by \n (perhaps strip out 
any \r before you start) and then explode() by ,. Depending on the 
software they're using, you might also need to remove any delimiters on 
each field of data, such as quote marks ().


If other file formats are possible as well as CSV, you might like to 
look at the PEAR File Formats packages[1].


And then there would be the usual multipart form upload where they  
select their file and send it up. I'd need to import it into MySQL.


Again, just receive the file data, do some checking to make sure it's of 
the expected type, run mysql_real_escape_string() on it, and insert it 
into a MySQL table.


You could use a PEAR package such as HTTP_Upload[2] to help with the 
uploading bit, and perhaps a database abstraction layer such as PEAR's 
DB package[3] for the MySQL bit.


Before I sit down and start coding this thing from scratch, does  anyone 
know if there is something similar out there already that  could give me 
a head start?


HTH

Jasper

[1] http://pear.php.net/packages.php?catpid=33catname=File%20Formats
[2] http://pear.php.net/package/HTTP_Upload
[3] http://pear.php.net/package/DB
---End Message---
---BeginMessage---
On Fri, August 19, 2005 3:47 pm, Jasper Bryant-Greene wrote:
 Brian Dunning wrote:
 I have a system where I'm trying to facilitate a process for
 customers
 to upload data to me (basically a list of people), and have  it go
 into
 a database. I can give them certain parameters, like it  has to be a
 CSV
 file, delimited in such a way, etc. but can't ask  much more of them
 than that, since people are largely stupid.  :)

 For CSV, it's as simple as explode() the data by \n (perhaps strip
 out
 any \r before you start) and then explode() by ,. Depending on the
 software they're using, you might also need to remove any delimiters
 on
 each field of data, such as quote marks ().

No, it's not that simple, as embedded commas can be inside of quotes,
and then quote quote is used for quotes inside 

Re: [PHP] Week Days

2005-08-20 Thread [EMAIL PROTECTED]
Rob, 

I tried your code below, but it didn't work. I put the number of week days 
in $addWeekdays variable. Am I doing something wrong or is there an error in 
the code? Appreciate your help!

On 8/18/05, Robert Cummings [EMAIL PROTECTED] wrote:
 
 On Fri, 2005-08-19 at 02:17, Robert Cummings wrote:
  This doesn't work since the value can be user defined and thus may span
  multiple weeks :) The following works but is dirty, I'm sure there's a
  better solution using modulus operator and adding and subtracting and a
  little voodoo... I'm just too lazy atm to think it up ;)
 
 Ok so I felt like doing it :)
 
 ?php
 
 //
 // For every 5 days to add we wrap a week and are right back where we
 // started so...
 //
 
 $addWeekdays = isset( $argv[1] ) ? $argv[1] : 0; // command line for fun
 $start = time();
 
 $addWeeks = (int)($addWeekdays / 5);
 $addWeekDays = ($addWeekdays % 5);
 
 $daySeconds = (24 * 60 * 60);
 
 $final = $start + ($addWeeks * 7 * $daySeconds);
 while( $addWeekDays  0 )
 {
 $final += $daySeconds;
 
 $day = date( 'D', $final );
 if( $day != 'Sat'  $day != 'Sun' )
 {
 $addWeekDays--;
 }
 }
 
 echo 'Start: '.date( 'Y-m-d (D)', $start ).\n;
 echo 'Final: '.date( 'Y-m-d (D)', $final ).\n;
 
 
 --
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting |
 | a powerful, scalable system for accessing system services |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for |
 | creating re-usable components quickly and easily. |
 `'
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



Re: [PHP] Week Days

2005-08-20 Thread [EMAIL PROTECTED]
Rob, 
 This code works great! Thank you for all of your help and everyone else who 
responded!

 On 8/18/05, Robert Cummings [EMAIL PROTECTED] wrote: 
 
 On Fri, 2005-08-19 at 02:10, Jasper Bryant-Greene wrote:
  [EMAIL PROTECTED] wrote:
   I am trying to add 3 (or a user-defined amount) week days to a certain 
 date..
   An example is today 2005-08-18 then adding 3 week days to give me a 
 date of
   2005-08-23. I have tried searching online but cannot find an easy way 
 of
   doing so.
 
  $numDaysToAdd = 3;
  $s = ($numDaysToAdd == 1) ? '' : 's';
 
  $dayInFuture = strtotime(+$numDaysToAdd day$s);
  $dayName = date('l', $dayInFuture);
  if($dayName == 'Saturday') {
  $dayInFuture = strtotime(+2 days, $dayInFuture);
  } else if($dayName == 'Sunday') {
  $dayInFuture = strtotime(+1 day, $dayInFuture);
  }
 
  Disclaimer: untested code.
 
 This doesn't work since the value can be user defined and thus may span
 multiple weeks :) The following works but is dirty, I'm sure there's a
 better solution using modulus operator and adding and subtracting and a
 little voodoo... I'm just too lazy atm to think it up ;)
 
 ?php
 
 $weekdays = array
 (
 'Mon' = true,
 'Tue' = true,
 'Wed' = true,
 'Thu' = true,
 'Fri' = true,
 );
 
 $daySeconds = (60 * 60 * 24);
 
 $start = time();
 $addWeekdays = 3;
 
 $final = $start;
 while( $i  $addWeekdays )
 {
 $final += $daySeconds;
 echo date( 'D', $final ).\n;
 if( isset( $weekdays[date( 'D', $final )] ) )
 {
 $i++;
 }
 }
 
 echo 'Start: '.date( 'Y-m-d (D)', $start ).\n;
 echo 'Final: '.date( 'Y-m-d (D)', $final ).\n;
 
 Cheers,
 Rob.
 --
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting |
 | a powerful, scalable system for accessing system services |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for |
 | creating re-usable components quickly and easily. |
 `'
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



Re: [PHP] Hardware Detection

2005-08-20 Thread Burhan Khalid

Saenal M wrote:

Hi,

Can we get information about hardware on client's PC. (e.g. hard disk, 
processor, keyboard, etc).? And How?

anyone knows? please reply back.


No, this is not possible with PHP.

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



[PHP] Super globals ?

2005-08-20 Thread Wong HoWang
Dear all,

Hello, I want to know that is there any way to create a super global in PHP?

Please help!
Thanks. 

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



[PHP] Super globals ?

2005-08-20 Thread Wong HoWang
Dear all,

Hello, I want to know that is there any way to create a super global in PHP?

Please help!
Thanks.

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



Re: [PHP] Super globals ?

2005-08-20 Thread Jasper Bryant-Greene

Wong HoWang wrote:

Hello, I want to know that is there any way to create a super global in PHP?


Only with the runkit extension. Take a look:

http://www.php.net/runkit

Jasper

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



Re: [PHP] Super globals ?

2005-08-20 Thread Kevin Waterson
This one time, at band camp, Jasper Bryant-Greene [EMAIL PROTECTED] wrote:

 Wong HoWang wrote:
  Hello, I want to know that is there any way to create a super global in PHP?
 
 Only with the runkit extension. Take a look:
 
 http://www.php.net/runkit

This is exactly what $_GLOBALS is for, why not use it?

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



Re: [PHP] Super globals ?

2005-08-20 Thread Jasper Bryant-Greene

Kevin Waterson wrote:

This one time, at band camp, Jasper Bryant-Greene [EMAIL PROTECTED] wrote:



Wong HoWang wrote:


Hello, I want to know that is there any way to create a super global in PHP?


Only with the runkit extension. Take a look:

http://www.php.net/runkit



This is exactly what $_GLOBALS is for, why not use it?


Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS) 
happens to be an example of a superglobal.


Jasper

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



Re: [PHP] Document source code for PHP5

2005-08-20 Thread Markus Fischer

Denis Gerasimov wrote:

Can someone recommend a documentation tool which supports the new PHP5
syntax?



PHPDocumentor (http://www.phpdoc.org/) does. I am using Zend Studio
integrated version and it works fine.


Then I'm wondering what I'm doing wrong because it puts interface 
function definitions into the global function scope ...


- Markus

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



Re: [PHP] preg_match

2005-08-20 Thread John Nichel

Richard Lynch wrote:

On Fri, August 19, 2005 7:03 am, Matthew Weier O'Phinney wrote:


* John Nichel [EMAIL PROTECTED] :


Richard Lynch wrote:


On Thu, August 18, 2005 2:50 pm, Jon wrote:


preg_match_all(/Charges \s\s+ $total x (.+) /siU, $single,
$from_invoice);


I would recommend using \\s instead of \s -- While \s doesn't have


any


meaning in PHP strings, so PHP just figures you must have meant


\\s
snip

But in perl type regex's, the \s is a space.  Without testing it, I
don't think \\s would match what the OP was looking for (I *think*



But Perl isn't going to *SEE* \\s !!!

PHP is going to *EAT* \\ and make \ out of it.

That's why \ is an escape character in PHP.

It's also an escape character in Perl/PCRE.

Some days I think PHP's escape character should have been | or
something, just so this topic wouldn't come up every damn month.

snip

Personally, I have never used \\ in PCRE when looking for things like 
spaces (\s), word boundraries (\b), etc. and it's all worked out fine.


--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

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



Re: [PHP] Super globals ?

2005-08-20 Thread Kevin Waterson
This one time, at band camp, Jasper Bryant-Greene [EMAIL PROTECTED] wrote:

 Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)
meh, force of habit
 happens to be an example of a superglobal.

and variable can be set within its scope, so why not use it?
As we see in the manual at $GLOBALS _is_ a super global and available
to all scopes within the script.
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
it refers to $GLOBALS as  This is a 'superglobal', or automatic global, 
variable. 

gotta love the php manual
kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



Re: [PHP] preg_match

2005-08-20 Thread Jasper Bryant-Greene

John Nichel wrote:
Personally, I have never used \\ in PCRE when looking for things like 
spaces (\s), word boundraries (\b), etc. and it's all worked out fine.


It will work fine, but only because those (\s and \b) just happen to not 
be special characters in PHP *at this time*.


It's sloppy programming because the backslash is known to be a special 
character, and \s or \b could conceivably become special characters at 
some time in the future. It's unlikely, but possible.


Not only that, but it makes it more likely that you'll forget and put \n 
when you meant \\n, \r when you meant \\r, \t when you meant \\t, and so 
on...


Jasper

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



Re: [PHP] Super globals ?

2005-08-20 Thread Jasper Bryant-Greene

Kevin Waterson wrote:

This one time, at band camp, Jasper Bryant-Greene [EMAIL PROTECTED] wrote:



Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)


meh, force of habit


happens to be an example of a superglobal.



and variable can be set within its scope, so why not use it?
As we see in the manual at $GLOBALS _is_ a super global and available
to all scopes within the script.
http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
it refers to $GLOBALS as  This is a 'superglobal', or automatic global, variable. 


gotta love the php manual


Exactly Kevin. What the OP wanted was to create another superglobal, 
just like $GLOBALS. The contents of $GLOBALS refer to the global 
variables, which are *not* all superglobals. The only superglobals by 
default in PHP (apart from $GLOBALS) are $_SERVER, $_GET, $_POST, and so on.


He asked a question, and I provided the answer. Why he wants to do it is 
another question, but telling him to use $GLOBALS isn't answering his 
question, it's answering a different question, namely how to access the 
global variables.


Jasper

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



Re: [PHP] Super globals ?

2005-08-20 Thread Wong HoWang
yes, I am asking how to start my own super global...
And even a PHP beginner know that $GLOBALS is a array containing all the 
global variables and it is used in a function or a class. So I think no one 
will ask a question here which the answer is simply $GLOBALS.

Any finally, thanks Jasper for the answer.

Jasper Bryant-Greene [EMAIL PROTECTED] 
wrote:[EMAIL PROTECTED]
 Kevin Waterson wrote:
 This one time, at band camp, Jasper Bryant-Greene 
 [EMAIL PROTECTED] wrote:


Because he asked for superglobals, not globals. $GLOBALS (not $_GLOBALS)

 meh, force of habit

happens to be an example of a superglobal.


 and variable can be set within its scope, so why not use it?
 As we see in the manual at $GLOBALS _is_ a super global and available
 to all scopes within the script.
 http://www.php.net/manual/en/reserved.variables.php#reserved.variables.globals
 it refers to $GLOBALS as  This is a 'superglobal', or automatic global, 
 variable. 

 gotta love the php manual

 Exactly Kevin. What the OP wanted was to create another superglobal, just 
 like $GLOBALS. The contents of $GLOBALS refer to the global variables, 
 which are *not* all superglobals. The only superglobals by default in PHP 
 (apart from $GLOBALS) are $_SERVER, $_GET, $_POST, and so on.

 He asked a question, and I provided the answer. Why he wants to do it is 
 another question, but telling him to use $GLOBALS isn't answering his 
 question, it's answering a different question, namely how to access the 
 global variables.

 Jasper 

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



[PHP] __sleep, __wakeup and persistent connections

2005-08-20 Thread Marcus Bointon
I'm sorting out some code to handle session object storage,  
particularly where the objects contain DB connections. I've found  
lots of articles that go on about how __sleep should clean up db  
stuff, close connections etc and how __wakeup should reconnect, but  
weirdly enough I've not found a single concrete example of doing this!


It's also not quite clear how this behaviour interacts with  
persistent connections. For example, If I do this:


class foo {

protected $db;

public function __construct() {
$this-db = mysql_pconnect();
}

protected function __wakeup() {
$this-db = mysql_pconnect();
}

protected function __sleep() {
mysql_close($this-db);
$this-db = NULL;
return array();
}
}

given that the connection is persistent, and may thus be used by  
other scripts, is calling mysql_close a particularly bad idea? Should  
I just not bother closing the connection, letting PHP deal with it -  
the object will not attempt to re-use the stale connection because it  
will get a new instance courtesy of __wakeup when unserialized.


I'm also unclear about how __sleep acts in subclasses - it seems that  
as soon as I have a __sleep function in a base class, I don't have  
any choice but to implement __sleep functions in every subclass of  
it, even if I don't want them to do anything that would not be done  
if __sleep were not defined. in the exampel, the base class has no  
properties to save, so it returns an empty array from __sleep, but  
that's unlikely to be useful for a subclass that does have properties  
(and serializing an object without any properties is pointless!).


Ideas?

Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk

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



Re: [PHP] Week Days

2005-08-20 Thread Robert Cummings
On Sat, 2005-08-20 at 03:15, [EMAIL PROTECTED] wrote:
 Rob, 
 
 I tried your code below, but it didn't work. I put the number of week days 
 in $addWeekdays variable. Am I doing something wrong or is there an error in 
 the code? Appreciate your help!

There's an error... I didn't account for the starting day being a
weekend day :) The following should work (somewhat tested) and I also
removed locale dependency from it (check for Sat and Sun).

?php

//
// For every 5 days to add we wrap a week and are right back where we
// started so...
//

$addWeekdays = isset( $argv[1] ) ? $argv[1] : 0; // command line for fun
$start = time();

$addWeeks = (int)($addWeekdays / 5);
$addWeekDays = ($addWeekdays % 5);

$daySeconds = (24 * 60 * 60);

$final = $start + ($addWeeks * 7 * $daySeconds);
$day = date( 'w', $final );

if( $day == 1 ) // Saturday
{
$final += ($daySeconds * 2);
}
else
if( $day == 0 ) // Sunday
{
$final += $daySeconds;
}
else
{
while( $addWeekDays  0 )
{
$final += $daySeconds;

$day = date( 'w', $final );
if( $day != '0'  $day != '6' )
{
$addWeekDays--;
}
}
}

echo 'Start: '.date( 'Y-m-d (D)', $start ).\n;
echo 'Final: '.date( 'Y-m-d (D)', $final ).\n;


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

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



[PHP] error while running com

2005-08-20 Thread sangram
Hi,
 i had uploaded the com application on win2003 server with word 2003
installed.It runs perfect The traffic of word files increases or other
reasons the following message starts displaying.

Warning: (null)(): Unable to obtain IDispatch interface for CLSID
{000209FF---C000-0046}: Server execution failed in
c:\inetpub\wwwroot\localuser\sound1007\www\com.php on line 15
Unable to instanciate Word


 If the server is rebooted again the application starts without errors.
Pls help me what will be the problem.
Sangram.

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



Re: [PHP] Re: PHP MySQL insert

2005-08-20 Thread areguera
On 8/19/05, Richard Lynch [EMAIL PROTECTED] wrote:
 On Fri, August 19, 2005 12:56 pm, areguera wrote:
  could you suggest something about Latin characters and portability?.
 
 As I understand it, or not, more likely, you want to configure your
 MySQL server to use UTF-8, and your MySQL client to use UTF-8 and
 pretty much everything to use UTF-8, and then you can convert your
 data to UTF-8 and its gonna store it in a way that you'll be able to
 convert back to Latin-1 or whatever you like.
 
 At least, that's what Mark Matthews of MySQL A/B said in his talk
 about this at our more recent Chicago MySQL User Group meeting.
 
 You may want to take this question to the i18n PHP list, where people
 who have actually done it hang out. :-)

thanks Richard, I'll make a walk around i18n php list...:) ... it
seems that utf-8 is the solution for internationalization, but I ask
my self what would happen with prior versions of mysql without utf-8
support? and how to design an application to both run as utf-8 or
iso-8859-1 in the require situation. can it be?

 
 --
 Like Music?
 http://l-i-e.com/artists.htm
 
 


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



[PHP] apache sessions

2005-08-20 Thread Bawt T. Eggdrop
im trying to change my session backend for apache from files to mysql.
is there something php provides that allows a php script to execute
before each page gets loaded in apache. if not i have to edit hundreds
of php files...theres gotta be an easier way. thanks.

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



[PHP] build sql query struture and values from form fields

2005-08-20 Thread Andras Kende

Hello,


I would like to create the mysql insert query for my html form fields,
I have a small problem it will have an extra , at the end of $sqlstruct
And extra  at $sqldata..

Anyone can give a hint ?


foreach ($_POST as $variable=$value){
$sqlstruct.=$variable,;
$sqldata.=$value.\','\;
}

$query=insert into db ($sqlstruct) VALUES ($sqldata);




Best regards,

Andras Kende
http://www.kende.com


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.13/78 - Release Date: 8/19/2005
 

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



Re: [PHP] build sql query struture and values from form fields

2005-08-20 Thread Greg Donald
On 8/20/05, Andras Kende [EMAIL PROTECTED] wrote:
 I would like to create the mysql insert query for my html form fields,
 I have a small problem it will have an extra , at the end of $sqlstruct
 And extra  at $sqldata..
 
 Anyone can give a hint ?
 
 
 foreach ($_POST as $variable=$value){
 $sqlstruct.=$variable,;
 $sqldata.=$value.\','\;
 }
 
 $query=insert into db ($sqlstruct) VALUES ($sqldata);

$k = implode( ',', array_keys( $_POST ) );
$v = implode( ',', array_values( $_POST ) );

$sql = INSERT INTO db ( $k ) VALUES ( $v );

I'd never do something like this though, just begs for SQL injection.


-- 
Greg Donald
Zend Certified Engineer
MySQL Core Certification
http://destiney.com/

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



Re: [PHP] preg_match

2005-08-20 Thread Edin Kadibašić
Richard Lynch wrote:
 But Perl isn't going to *SEE* \\s !!!
 
 PHP is going to *EAT* \\ and make \ out of it.
 
 That's why \ is an escape character in PHP.
 
 It's also an escape character in Perl/PCRE.
 
 Some days I think PHP's escape character should have been | or
 something, just so this topic wouldn't come up every damn month.

All true, except you would then end up having problems with regexs like
(this|or|that) :)

Edin

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



Re: [PHP] preg_match

2005-08-20 Thread Edin Kadibašić
Jasper Bryant-Greene wrote:
 John Nichel wrote:
 
 Personally, I have never used \\ in PCRE when looking for things like
 spaces (\s), word boundraries (\b), etc. and it's all worked out fine.
 
 
 It will work fine, but only because those (\s and \b) just happen to not
 be special characters in PHP *at this time*.
 
 It's sloppy programming because the backslash is known to be a special
 character, and \s or \b could conceivably become special characters at
 some time in the future. It's unlikely, but possible.
 
 Not only that, but it makes it more likely that you'll forget and put \n
 when you meant \\n, \r when you meant \\r, \t when you meant \\t, and so
 on...

Also people thinking that PHP's single-quoted strings don't have any
escape sequences run into trouble when they have backslash as the last
character of the string:

$path = 'c:\';

This will give you parse error because the parser would think that you
wanted literal ' character and looks in vain for the string end. The
correct line should be:

$path = 'c:\\';

Edin

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] $BM_5aITK~$J1|MM$r%O%a%F8+$^$;$s$+(B

2005-08-20 Thread info
-
$B5U!o8r:](B $Bv5U!o8r:](B
-
[EMAIL PROTECTED],[EMAIL PROTECTED];~Be$O=*$j$^$7$?!#Ev%5%$%H$O5U!o4uK[EMAIL 
PROTECTED],[EMAIL PROTECTED]+M3$KA*$Y$k%7%9%F%`$r:NMQ$7$F$$$^$9!#(B

$B[EMAIL PROTECTED](B $B!D(B [EMAIL 
PROTECTED]D!Bh$G$O%(%C%A$$j(B+$B$*Ni$b$$j(B
$B[EMAIL PROTECTED](B $B!D(B [EMAIL PROTECTED]+M3$K8rD$7$F(BOK!!

[EMAIL PROTECTED]:$1$^$9$,![EMAIL 
PROTECTED]:$-$^$9!#$^$?!$4?75,EPO?$K4X$7$^$7$F$O?3::@)$H$J$C$F$*$j$^$9!#(B

http://awg.webchu.com/deai/?meet

$B!!~!!~!!~!!~!!~!!~!!~!!~!!~!!~!!~(B
[EMAIL PROTECTED]@-$X$N%5%]!%H!o$O$$/$^$G$bK\?M!Bh$G$9!#(B
[EMAIL PROTECTED]@-$X$N%5%]!%H$O+M38rD$G$*4j$$$7$^$9!#(B 
$B!!~!!~!!~!!~!!~!!~!!~!!~!!~!!~!!~(B

[EMAIL PROTECTED]6bA,[EMAIL PROTECTED](B 

$B$^$?![EMAIL PROTECTED][EMAIL 
PROTECTED],!$*Ajj$NG/Np!MF;Q$OJ]cCW$7$^$;$s!#(B
$B$G$bB:]$K7]G=4X78!2;[EMAIL PROTECTED]$j$^$9!#(B
$B$I$s$J?M$K=P0)$($k$+$O!B3$1$J$$$H$o$+$j$^$;$s$h$M!#(B
[EMAIL PROTECTED]%k%P%$%H463P$G$*;n$72$5$$!#(B  

http://awg.webchu.com/deai/?meet

$B!ZMxMQEPO?![(B
[EMAIL PROTECTED][EMAIL PROTECTED];YJ'$$(B
$B---(B
$B!Z%a%C%;!%88r49![(B
$B$[EMAIL PROTECTED];d=qH$r$4MxMQD:$1$^$9(B
$B!J%a!%k%%I%l%9!EEOCHV9f$N8r49$b+M3!K(B
$B---(B
$B!Z8rD![(B
$B6b3[!9g$2s?t!%W%l%$FbMF$J$I(B
$B---(B
$B!Z5U!o8r:]%9%?!%H![(B
[EMAIL PROTECTED]'[EMAIL PROTECTED]r7o$K9g$o$;$F8r:](B+$B%5%]!%H(B
[EMAIL PROTECTED]':GDc(BSEX$B$r%5%]!%H(B

$B-6=L#$r;}$?$l$?J}$OAaB.EPO?-(B  
 $B--(B
http://awg.webchu.com/deai/?meet

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



[PHP] exec ping

2005-08-20 Thread Juan Pablo Herrera
Hi all!
I have following script:
$comando = system('ping 168.192.0.1', $nn);
echo $nn;
Well, i need that only show the first ten lines of the ping and kill
the process.
How can i make it?

Regards,
JP

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



Re: [PHP] exec ping

2005-08-20 Thread Jasper Bryant-Greene

Juan Pablo Herrera wrote:

Hi all!
I have following script:
$comando = system('ping 168.192.0.1', $nn);
echo $nn;
Well, i need that only show the first ten lines of the ping and kill
the process.
How can i make it?


If I understand your question correctly...

$comando = system('ping -c 10 168.192.0.1', $nn);

Jasper

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



Re: [PHP] exec ping

2005-08-20 Thread Juan Pablo Herrera
On 8/21/05, Jasper Bryant-Greene [EMAIL PROTECTED] wrote:
 Juan Pablo Herrera wrote:
  Hi all!
  I have following script:
  $comando = system('ping 168.192.0.1', $nn);
  echo $nn;
  Well, i need that only show the first ten lines of the ping and kill
  the process.
  How can i make it?
 
 If I understand your question correctly...
 
 $comando = system('ping -c 10 168.192.0.1', $nn);
 
 Jasper


Thanks Jasper,
well, i need make a explode of results of the ping. The idea is check
a host and when the host don´ t response send a email.
I don't explode the result of the ping.

Thanks.,
JP

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



Re: [PHP] apache sessions

2005-08-20 Thread Chris Shiflett

Bawt T. Eggdrop wrote:

im trying to change my session backend for apache from files to mysql.
is there something php provides that allows a php script to execute
before each page gets loaded in apache. if not i have to edit hundreds
of php files...theres gotta be an easier way. thanks.


I may be misunderstanding your question, but if you're wanting to change 
the session data store that PHP uses, you can use 
session_set_save_handler() and write your own functions.


Apache handles incoming HTTP requests, so it doesn't make sense for a 
PHP script to execute before it has been requested.


Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



Re: [PHP] exec ping

2005-08-20 Thread Jasper Bryant-Greene

Juan Pablo Herrera wrote:

Thanks Jasper,
well, i need make a explode of results of the ping. The idea is check
a host and when the host don´ t response send a email.
I don't explode the result of the ping.


If it was me, I'd try opening a socket connection to the host instead, 
and check to see if you can connect or not. Whether or not that is 
suitable to your application I don't know...


Jasper

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