php-general Digest 4 May 2007 11:11:10 -0000 Issue 4772

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

php-general Digest 4 May 2007 11:11:10 - Issue 4772

Topics (messages 254377 through 254394):

Re: Script feedback: insert string into another string
254377 by: Tijnema !

Re: File uploading and saving info on mysql
254378 by: itoctopus

Re: Redirect via GET is loosing characters
254379 by: itoctopus

Re: Split string
254380 by: itoctopus

Re: What does  mean?
254381 by: itoctopus

Re: A problem with passing $_GET in an url
254382 by: Davis Chan
254383 by: Davis Chan

Re: MySQL change-tracking
254384 by: Chris

Re: [opinions] Ashop Commerce
254385 by: Marco Sottana
254386 by: Chris

passing GET via include
254387 by: Mark Smith
254389 by: Miguel J. Jiménez
254393 by: Edward Kay
254394 by: Oliver Block

Custom session save handler. What's happens really?
254388 by: n.quirin.free.fr

Why does this encoding work in PHP?
254390 by: Arno Kuhl
254391 by: Dave Goodchild

PHP 5.2.2 and PHP 4.4.7 Released!
254392 by: Derick Rethans

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


I owe you and Tijnema a beer!

Have a great day/night!
Cheers,
Micky


I'm sorry, you have to wait another 9 months, because only than i can
legally drink a beer :) (than i will be  16 :) )

Tijnema
---End Message---
---BeginMessage---
Here's the file upload class making your life easier:

?php
 /*
  @class FileManager
  @description This class handles interaction with Files
  @copyright itoctopus 2007 - The Genoc Library
 */
 class FileManager{
  /*
   [EMAIL PROTECTED] save
   [EMAIL PROTECTED] this function saves the file in the database
   [EMAIL PROTECTED] array $file_handle A handle on the file (ex. 
$_FILES['the_file'])
   [EMAIL PROTECTED] string $field_name The name of the field
   [EMAIL PROTECTED] string $action Update or save the file in the table. 
Defaults to 
save.
   [EMAIL PROTECTED] string $file_source The name of the source table saving 
the file 
(such as realestate)
   [EMAIL PROTECTED] string $file_source_id The id of the row in the source 
table
   [EMAIL PROTECTED] object $db The database handle
  */
  static function save($file_handle, $file_source, $file_source_id, 
$action='save', $allowed_types = array(), $db){
   if (empty($file_handle['tmp_name']))
return;
   $data = addslashes(fread(fopen($file_handle['tmp_name'], r), 
$file_handle['size']));
   if ($action == 'save'){
$creationdate = $lastupdatedate = Date(Y-m-d H:i:s);
$sql = 'INSERT INTO file (file_name, file_type, file_size, file_source, 
file_source_id, file_binary, file_creationdate, file_lastupdatedate) VALUES 
(\''.$file_handle['name'].'\', \''.$file_handle['type'].'\', 
\''.$file_handle['size'].'\', \''.$file_source.'\', \''.$file_source_id.'\', 
\''.$data.'\', \''.$creationdate.'\', \''.$lastupdatedate.'\')';

//now if the type is an image, then create a thumbnail (resize should be 
relative)

   }
   else{
$lastupdatedate = Date(Y-m-d H:i:s);
$sql = 'UPDATE file SET file_name=\''.$file_handle['name'].'\', 
file_type=\''.$file_handle['type'].'\', file_source=\''.$file_source.'\', 
file_source_id=\''.$file_source_id.'\', file_binary=\''.$data.'\', 
file_lastupdatedate=\''.$lastupdatedate.'\'';

//now if the type is an image, then update a thumbnail

   }
   $result= $db-query($sql);
  }

  /*
   [EMAIL PROTECTED] get
   [EMAIL PROTECTED] This function returns a link to the file based on the id
   [EMAIL PROTECTED] string $file_id The id of the file in the database
   [EMAIL PROTECTED] object $db The database handle
   [EMAIL PROTECTED] void
  */
  static function get($file_id, $db){
   $sql = 'SELECT file_id, file_name, file_type, file_size, file_binary FROM 
file where file_id=\''.$file_id.'\'';
   $result= $db-query($sql);
   header('Content-length:'.$result[0]['file_size']);
   header('Content-type:'.$result[0]['file_type']);
   //if it's not an image then download it, otherwise display it
   if (strpos($result[0]['file_type'], 'image') !== FALSE)
header(Content-type: .$result[0]['file_type'].; 
filename=.$result[0]['file_name']);
   else
header(Content-Disposition: attachment; 
filename=.$result[0]['file_name']);
   echo($result[0]['file_binary']);
  }

  /*
   [EMAIL PROTECTED] delete
   [EMAIL PROTECTED] This function delete a file from the database
   [EMAIL PROTECTED] integer $file_id The id of the file to be deleted
   [EMAIL PROTECTED] object $db The database handle
   [EMAIL PROTECTED]
  */
  static function delete($file_id, $db){
   $sql = 'DELETE FROM file WHERE file_id=\'$file_id\'';
   $result= $db-query($sql);
  }

 }
?

-- 
itoctopus - http://www.itoctopus.com
Marcelo Wolfgang [EMAIL PROTECTED] wrote in 

Re: [PHP] [opinions] Ashop Commerce

2007-05-04 Thread Marco Sottana

if you have nothing to say.. say nothing
- Original Message - 
From: Richard Lynch [EMAIL PROTECTED]

To: Marco Sottana [EMAIL PROTECTED]
Cc: Stut [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Thursday, May 03, 2007 6:04 PM
Subject: Re: [PHP] [opinions] Ashop Commerce



On Thu, May 3, 2007 6:36 am, Marco Sottana wrote:

i am new ...
say me .. 2 or 3 nice e-commerce and why is nice.. please..


RTFA

I was sick of this thread in 1997!!!

I sure don't want to see it again!

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
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] [opinions] Ashop Commerce

2007-05-04 Thread Chris

Marco Sottana wrote:

if you have nothing to say.. say nothing


LOL. You're the one spamming  trolling the list.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP] passing GET via include

2007-05-04 Thread Mark Smith

Hello all,
Is there a way to allow the passing of variables to included scripts 
using the GET method, for example includefile.php?name=person; or is 
there another method of including files that allow you to do this. I 
have attempted to do this without success, I just get a message saying 
the file cannot be found.


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



[PHP] Custom session save handler. What's happens really?

2007-05-04 Thread n . quirin
Hi,

i'm using in each script:

?
session_set_save_handler(...); //register my custom function to store session
//into a mysql database

session_start(); //session.auto_start is set to 0 in php.ini
register_shutdown(session_write_close);

$object = unserialize($_SESSION['objectname']);
//modify the object
//
$_SESSION['objectname'] = serialize($object);
?

When are exactly called the write and read function of my custom handler?
Is it at the session_start that read function is called?
or is it at $object = unserialize($_SESSION['objectname'])?

Is write function called at session_write_close only?
or any time $_SESSION[] is writted?

Thanks a lot, I have no clue from PHP tutorial about this...

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



Re: [PHP] passing GET via include

2007-05-04 Thread Miguel J. Jiménez

Mark Smith escribió:

Hello all,
Is there a way to allow the passing of variables to included scripts 
using the GET method, for example includefile.php?name=person; or is 
there another method of including files that allow you to do this. I 
have attempted to do this without success, I just get a message saying 
the file cannot be found.


If you define the variables before the *include* the included file will 
see them without problem...


--
Miguel J. Jiménez
Programador Senior
Área de Internet/XSL/PHP
[EMAIL PROTECTED]



ISOTROL
Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta.
Parque Tecnológico Cartuja '93, 41092 Sevilla.
Teléfono: 955 036 800 - Fax: 955 036 849
http://www.isotrol.com

You let a political fight  come between you and your best friend you have in all 
the world. Do you realize how foolish that is? How ominous? How can this country survive 
if friends can't rise above the quarrel.
Constance Hazard, North  South (book I)


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

[PHP] Why does this encoding work in PHP?

2007-05-04 Thread Arno Kuhl
I recently came across a script that was oddly encoded. A bit of digging
revealed it was encoded in octal. What puzzles me is why the php interpreter
is able to understand the script.

An example (not from the original script)

require_once ../file.php;
require_once \56\56\57\146\151\154\145\56\160\150\160;

Arno

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



Re: [PHP] Why does this encoding work in PHP?

2007-05-04 Thread Dave Goodchild

The characters are encoded in octal and the php interpreter converts them
into the corresponding ASCII characters and then the sequence is represented
as a string which is included?


[PHP] PHP 5.2.2 and PHP 4.4.7 Released!

2007-05-04 Thread Derick Rethans

The PHP development team would like to announce the immediate 
availability of PHP 5.2.2 and availability of PHP 4.4.7. These releases 
are major stability and security enhancements of the 5.x and 4.4.x 
branches, and all users are strongly encouraged to upgrade to it as soon 
as possible. Further details about the PHP 5.2.2 release can be found in 
the release announcement for 5.2.2 (http:// 
www.php.net/releases/5_2_2.php). Details about the PHP 4.4.7 release can 
be found in the release announcement for 4.4.7 (http:// 
www.php.net/releases/4_4_7.php).

Security Enhancements and Fixes in PHP 5.2.2 and PHP 4.4.7:

- Fixed CVE-2007-1001, GD wbmp used with invalid image size (by Ivan
  Fratric) 
- Fixed asciiz byte truncation inside mail() (MOPB-33 by Stefan Esser) 
- Fixed a bug in mb_parse_str() that can be used to activate
  register_globals (MOPB-26 by Stefan Esser) 
- Fixed unallocated memory access/double free in in
  array_user_key_compare() (MOPB-24 by Stefan Esser) 
- Fixed a double free inside session_regenerate_id() (MOPB-22 by Stefan
  Esser) 
- Added missing open_basedir  safe_mode checks to zip:// and bzip://
  wrappers. (MOPB-21 by Stefan Esser). 
- Limit nesting level of input variables with max_input_nesting_level as
  fix for (MOPB-03 by Stefan Esser) 
- Fixed CRLF injection inside ftp_putcmd(). (by loveshell[at]
  Bug.Center.Team) 
- Fixed a possible super-global overwrite inside
  import_request_variables(). (by Stefano Di Paola, Stefan Esser) 
- Fixed a remotely trigger-able buffer overflow inside bundled libxmlrpc
  library. (by Stanislav Malyshev)

Security Enhancements and Fixes in PHP 5.2.2 only:

- Fixed a header injection via Subject and To parameters to the mail()
  function (MOPB-34 by Stefan Esser)
- Fixed wrong length calculation in unserialize S type (MOPB-29 by
  Stefan Esser)
- Fixed substr_compare and substr_count information leak (MOPB-14 by
  Stefan Esser) (Stas, Ilia)
- Fixed a remotely trigger-able buffer overflow inside
  make_http_soap_request(). (by Ilia Alshanetsky)
- Fixed a buffer overflow inside user_filter_factory_create(). (by Ilia
  Alshanetsky)

Security Enhancements and Fixes in PHP 4.4.7 only:

- XSS in phpinfo() (MOPB-8 by Stefan Esser)

While majority of the issues outlined above are local, in some
circumstances given specific code paths they can be triggered
externally. Therefor, we strongly recommend that if you use code
utilizing the functions and extensions identified as having had
vulnerabilities in them, you consider upgrading your PHP.


Derick Rethans
PHP 4.4 Release Master

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

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



RE: [PHP] passing GET via include

2007-05-04 Thread Edward Kay
 -Original Message-
 From: Mark Smith [mailto:[EMAIL PROTECTED]
 Sent: 04 May 2007 08:23

 Hello all,
 Is there a way to allow the passing of variables to included scripts
 using the GET method, for example includefile.php?name=person; or is
 there another method of including files that allow you to do this. I
 have attempted to do this without success, I just get a message saying
 the file cannot be found.


Hi Mark,

No, this isn't possible as it makes no sense. When you include a file, you
are not performing a request that generates a response - you are simply
including the contents of one file in another. When you call include, think
of it as just copy/pasting the contents of the included file at that point.

Any variables already defined (and in scope) will therefore be be available
to the code included file, for example:

--- main.php ---

$strTitle = 'The title';
$intTitleLength = strlen($strTitle);

include('display.php');


--- display.php ---

echo 'Title is '.$strTitle.' and is '.$intTitleLength.' characters long';


I hope this makes sense but feel free to reply to the list if you have any
questions.

Edward

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



Re: [PHP] passing GET via include

2007-05-04 Thread Oliver Block
Am Freitag, 4. Mai 2007 09:22 schrieb Mark Smith:
 Hello all,
 Is there a way to allow the passing of variables to included scripts

See it another way: The includED script will be part of the includING script. 

---includeme.inc-
?php
$message=Hello!\n;
?
---includer.php--
?php
include('includeme.inc');
echo $message;
?
-

Will be the same as
---dont_like_inclusions.php---
?php
$message=Hello\n;
echo $message;
?
---


Regards,

Oliver

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



[PHP] Re: Custom session save handler. What's happens really?

2007-05-04 Thread itoctopus
You have to explicitly serialize and unserialize the objects.
I think the confusion here is with the automatic __wakeup and __sleep 
functions:
http://www.devshed.com/c/a/PHP/Using-the-Sleep-and-Wakeup-Functions-to-Serialize-Objects-in-PHP/


-- 
itoctopus - http://www.itoctopus.com
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 i'm using in each script:

 ?
 session_set_save_handler(...); //register my custom function to store 
 session
 //into a mysql database

 session_start(); //session.auto_start is set to 0 in php.ini
 register_shutdown(session_write_close);

 $object = unserialize($_SESSION['objectname']);
 //modify the object
 //
 $_SESSION['objectname'] = serialize($object);
 ?

 When are exactly called the write and read function of my custom handler?
 Is it at the session_start that read function is called?
 or is it at $object = unserialize($_SESSION['objectname'])?

 Is write function called at session_write_close only?
 or any time $_SESSION[] is writted?

 Thanks a lot, I have no clue from PHP tutorial about this... 

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



Re: [PHP] passing GET via include

2007-05-04 Thread Tijnema !

On 5/4/07, Oliver Block [EMAIL PROTECTED] wrote:

Am Freitag, 4. Mai 2007 09:22 schrieb Mark Smith:
 Hello all,
 Is there a way to allow the passing of variables to included scripts

See it another way: The includED script will be part of the includING script.

---includeme.inc-
?php
   $message=Hello!\n;
?
---includer.php--
?php
   include('includeme.inc');
   echo $message;
?
-

Will be the same as
---dont_like_inclusions.php---
?php
   $message=Hello\n;
   echo $message;
?
---


Regards,

Oliver


Actually, it will be this:
?php
?
?php
  $message=Hello\n;
?
?php
  echo $message;
?

As you could, for example, include a HTML document :)

Tijnema

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



Re: [PHP] Re: Custom session save handler. What's happens really?

2007-05-04 Thread n . quirin
Thanks, but I serialize and unserialize the objects and this is not my
problem...(I known best practices for php5 about object serialization).

Please read again the post.

Selon itoctopus [EMAIL PROTECTED]:

 You have to explicitly serialize and unserialize the objects.
 I think the confusion here is with the automatic __wakeup and __sleep
 functions:

http://www.devshed.com/c/a/PHP/Using-the-Sleep-and-Wakeup-Functions-to-Serialize-Objects-in-PHP/


 --
 itoctopus - http://www.itoctopus.com
 [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi,
 
  i'm using in each script:
 
  ?
  session_set_save_handler(...); //register my custom function to store
  session
  //into a mysql database
 
  session_start(); //session.auto_start is set to 0 in php.ini
  register_shutdown(session_write_close);
 
  $object = unserialize($_SESSION['objectname']);
  //modify the object
  //
  $_SESSION['objectname'] = serialize($object);
  ?
 
  When are exactly called the write and read function of my custom handler?
  Is it at the session_start that read function is called?
  or is it at $object = unserialize($_SESSION['objectname'])?
 
  Is write function called at session_write_close only?
  or any time $_SESSION[] is writted?
 
  Thanks a lot, I have no clue from PHP tutorial about this...

 --
 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] Using timezones

2007-05-04 Thread Rob Desbois
I have a script which uses UTC times read from a database.

Up until now the users have just provided their current timezone offset from 
UTC in hours, but this needs to be changed as the script may not be running on 
a server with UTC set and I'd like to use set_default_timezone().

Looking at the documentation, all of the timezones which I want to provide 
(Etc/GMT+N, Etc/GMT-N and UTC) are listed as 'only existing for backward 
compatible reasons'.
Is there any reason why UTC should exist only for backward compatible reasons?? 
It seems like a pretty important timezone to me...

What's the best way to go about providing this functionality? Should I just 
provide an option of all regional timezones (how do I use this? The manual says 
where to download a pre-compiled Windows DLL but doesn't explain how to use 
it). Even if I do that how should I obtain UTC time if UTC is a deprecated 
timezone?

Thanks!
Rob


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

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



Re: [PHP] Using timezones

2007-05-04 Thread Tijnema !

On 5/4/07, Rob Desbois [EMAIL PROTECTED] wrote:

I have a script which uses UTC times read from a database.

Up until now the users have just provided their current timezone offset from 
UTC in hours, but this needs to be changed as the script may not be running on 
a server with UTC set and I'd like to use set_default_timezone().

Looking at the documentation, all of the timezones which I want to provide 
(Etc/GMT+N, Etc/GMT-N and UTC) are listed as 'only existing for backward 
compatible reasons'.
Is there any reason why UTC should exist only for backward compatible reasons?? 
It seems like a pretty important timezone to me...

What's the best way to go about providing this functionality? Should I just 
provide an option of all regional timezones (how do I use this? The manual says 
where to download a pre-compiled Windows DLL but doesn't explain how to use 
it). Even if I do that how should I obtain UTC time if UTC is a deprecated 
timezone?

Thanks!
Rob


Quite strange that UTC and GMT are deprecated timezones..., anyway, if
you don't want to use them, use one of the cities that are in GMT
timezone (Europe/London for example). I don't know how this will
behave as London (and whole GB) uses DST, so that might have affect
the real time ...

Tijnema

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



[PHP] Limit query results

2007-05-04 Thread Dan Shirah

Good Morning everyone.

In the below code I am pulling records from two tables.  the records are
tied together by a common key in a 3rd table.  Everything works correctly
down to the $result.


// Connect to the database
 $connection = mssql_pconnect($host, $user, $pass) or die ('server
connection failed');
 $database = mssql_select_db($database, $connection) or die ('DB
selection failed');
 // Query the table and load all of the records into an array.
  $sql = SELECT
support_payment_request.credit_card_id,
support_payment_request.status_code,
criminal_payment_request.credit_card_id,
criminal_payment_request.status_code,
credit_card_payment_request.credit_card_id,
credit_card_payment_request.date_request_received
   FROM
credit_card_payment_request LEFT OUTER JOIN support_payment_request
   ON support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
LEFT OUTER JOIN criminal_payment_request
   ON criminal_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
   WHERE support_payment_request.status_code = 'P'
   OR criminal_payment_request.status_code = 'P';

   // print_r ($sql);
 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
 $number_rows= mssql_num_rows($result);
?
table width='780' border='1' align='center' cellpadding='2' cellspacing='2'
bordercolor='#00'
?php
if(!empty($result)) {
while ($row= mssql_fetch_array($result)) {
 $id = $row['credit_card_id'];
 $dateTime = $row['date_request_received'];
 //print_r ($id);
?
tr
td width='88' height='13' align='center' class='tblcell'div
align='center'?php echo a href='javascript:editRecord($id)'$id/a
?/div/td
td width='224' height='13' align='center' class='tblcell'div
align='center'?php echo $dateTime ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo To Be Processed ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo Payment Type ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo Last Processed By ?/div/td
/tr
?php
}
}
?

The picture below is what mu output looks like.  BUT, what I am trying to do
is have only ONE row returned per ID regardless of however many records may
be associated with that ID.   Below record number 122 has three results, I
only want one row for record 122 to be displayed.

Any ideas?


  2 javascript:editRecord(2)
Oct 6 2010 12:00AM
To Be Processed
Payment Type
Last Processed By
46 javascript:editRecord(46)
Feb 23 2007 2:27PM
To Be Processed
Payment Type
Last Processed By
66 javascript:editRecord(66)
Feb 26 2007 3:16PM
To Be Processed
Payment Type
Last Processed By
68 javascript:editRecord(68)
Feb 26 2007 3:39PM
To Be Processed
Payment Type
Last Processed By
76 javascript:editRecord(76)
Mar 21 2007 7:36AM
To Be Processed
Payment Type
Last Processed By
77 javascript:editRecord(77)
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
78 javascript:editRecord(78)
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
79 javascript:editRecord(79)
Mar 21 2007 7:41AM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By


Re: [PHP] Limit query results

2007-05-04 Thread Fredrik Thunberg

GROUP BY whatever_id_you_want in the SQL

Dan Shirah skrev:

Good Morning everyone.

In the below code I am pulling records from two tables.  the records are
tied together by a common key in a 3rd table.  Everything works correctly
down to the $result.


// Connect to the database
 $connection = mssql_pconnect($host, $user, $pass) or die ('server
connection failed');
 $database = mssql_select_db($database, $connection) or die ('DB
selection failed');
 // Query the table and load all of the records into an array.
  $sql = SELECT
support_payment_request.credit_card_id,
support_payment_request.status_code,
criminal_payment_request.credit_card_id,
criminal_payment_request.status_code,
credit_card_payment_request.credit_card_id,
credit_card_payment_request.date_request_received
   FROM
credit_card_payment_request LEFT OUTER JOIN support_payment_request
   ON support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
LEFT OUTER JOIN criminal_payment_request
   ON criminal_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id
   WHERE support_payment_request.status_code = 'P'
   OR criminal_payment_request.status_code = 'P';

   // print_r ($sql);
 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
 $number_rows= mssql_num_rows($result);
?
table width='780' border='1' align='center' cellpadding='2' 
cellspacing='2'

bordercolor='#00'
?php
if(!empty($result)) {
while ($row= mssql_fetch_array($result)) {
 $id = $row['credit_card_id'];
 $dateTime = $row['date_request_received'];
 //print_r ($id);
?
tr
td width='88' height='13' align='center' class='tblcell'div
align='center'?php echo a href='javascript:editRecord($id)'$id/a
?/div/td
td width='224' height='13' align='center' class='tblcell'div
align='center'?php echo $dateTime ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo To Be Processed ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo Payment Type ?/div/td
td width='156' height='13' align='center' class='tblcell'div
align='center'?php echo Last Processed By ?/div/td
/tr
?php
}
}
?

The picture below is what mu output looks like.  BUT, what I am trying 
to do

is have only ONE row returned per ID regardless of however many records may
be associated with that ID.   Below record number 122 has three results, I
only want one row for record 122 to be displayed.

Any ideas?


  2 javascript:editRecord(2)
Oct 6 2010 12:00AM
To Be Processed
Payment Type
Last Processed By
46 javascript:editRecord(46)
Feb 23 2007 2:27PM
To Be Processed
Payment Type
Last Processed By
66 javascript:editRecord(66)
Feb 26 2007 3:16PM
To Be Processed
Payment Type
Last Processed By
68 javascript:editRecord(68)
Feb 26 2007 3:39PM
To Be Processed
Payment Type
Last Processed By
76 javascript:editRecord(76)
Mar 21 2007 7:36AM
To Be Processed
Payment Type
Last Processed By
77 javascript:editRecord(77)
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
78 javascript:editRecord(78)
Mar 21 2007 7:40AM
To Be Processed
Payment Type
Last Processed By
79 javascript:editRecord(79)
Mar 21 2007 7:41AM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By
122 javascript:editRecord(122)
Mar 27 2007 5:29PM
To Be Processed
Payment Type
Last Processed By



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



Re: [PHP] Limit query results

2007-05-04 Thread Zoltán Németh
SELECT DISTINCT?

greets
Zoltán Németh

2007. 05. 4, péntek keltezéssel 08.44-kor Dan Shirah ezt írta:
 Good Morning everyone.
 
 In the below code I am pulling records from two tables.  the records are
 tied together by a common key in a 3rd table.  Everything works correctly
 down to the $result.
 
 
  // Connect to the database
   $connection = mssql_pconnect($host, $user, $pass) or die ('server
 connection failed');
   $database = mssql_select_db($database, $connection) or die ('DB
 selection failed');
   // Query the table and load all of the records into an array.
$sql = SELECT
  support_payment_request.credit_card_id,
  support_payment_request.status_code,
  criminal_payment_request.credit_card_id,
  criminal_payment_request.status_code,
  credit_card_payment_request.credit_card_id,
  credit_card_payment_request.date_request_received
 FROM
  credit_card_payment_request LEFT OUTER JOIN support_payment_request
 ON support_payment_request.credit_card_id =
 credit_card_payment_request.credit_card_id
  LEFT OUTER JOIN criminal_payment_request
 ON criminal_payment_request.credit_card_id =
 credit_card_payment_request.credit_card_id
 WHERE support_payment_request.status_code = 'P'
 OR criminal_payment_request.status_code = 'P';
 
 // print_r ($sql);
   $result = mssql_query($sql) or die(mssql_error());
// print_r ($result);
   $number_rows= mssql_num_rows($result);
 ?
 table width='780' border='1' align='center' cellpadding='2' cellspacing='2'
 bordercolor='#00'
 ?php
 if(!empty($result)) {
  while ($row= mssql_fetch_array($result)) {
   $id = $row['credit_card_id'];
   $dateTime = $row['date_request_received'];
   //print_r ($id);
 ?
 tr
 td width='88' height='13' align='center' class='tblcell'div
 align='center'?php echo a href='javascript:editRecord($id)'$id/a
 ?/div/td
 td width='224' height='13' align='center' class='tblcell'div
 align='center'?php echo $dateTime ?/div/td
 td width='156' height='13' align='center' class='tblcell'div
 align='center'?php echo To Be Processed ?/div/td
 td width='156' height='13' align='center' class='tblcell'div
 align='center'?php echo Payment Type ?/div/td
 td width='156' height='13' align='center' class='tblcell'div
 align='center'?php echo Last Processed By ?/div/td
 /tr
 ?php
  }
 }
 ?
 
 The picture below is what mu output looks like.  BUT, what I am trying to do
 is have only ONE row returned per ID regardless of however many records may
 be associated with that ID.   Below record number 122 has three results, I
 only want one row for record 122 to be displayed.
 
 Any ideas?
 
 
2 javascript:editRecord(2)
  Oct 6 2010 12:00AM
  To Be Processed
  Payment Type
  Last Processed By
  46 javascript:editRecord(46)
  Feb 23 2007 2:27PM
  To Be Processed
  Payment Type
  Last Processed By
  66 javascript:editRecord(66)
  Feb 26 2007 3:16PM
  To Be Processed
  Payment Type
  Last Processed By
  68 javascript:editRecord(68)
  Feb 26 2007 3:39PM
  To Be Processed
  Payment Type
  Last Processed By
  76 javascript:editRecord(76)
  Mar 21 2007 7:36AM
  To Be Processed
  Payment Type
  Last Processed By
  77 javascript:editRecord(77)
  Mar 21 2007 7:40AM
  To Be Processed
  Payment Type
  Last Processed By
  78 javascript:editRecord(78)
  Mar 21 2007 7:40AM
  To Be Processed
  Payment Type
  Last Processed By
  79 javascript:editRecord(79)
  Mar 21 2007 7:41AM
  To Be Processed
  Payment Type
  Last Processed By
  122 javascript:editRecord(122)
  Mar 27 2007 5:29PM
  To Be Processed
  Payment Type
  Last Processed By
  122 javascript:editRecord(122)
  Mar 27 2007 5:29PM
  To Be Processed
  Payment Type
  Last Processed By
  122 javascript:editRecord(122)
  Mar 27 2007 5:29PM
  To Be Processed
  Payment Type
  Last Processed By

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



Re: [PHP] Limit query results

2007-05-04 Thread Miguel J. Jiménez

Use SELECT DISTINCT in your SQL syntax.

--
Miguel J. Jiménez
Programador Senior
Área de Internet/XSL/PHP
[EMAIL PROTECTED]



ISOTROL
Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta.
Parque Tecnológico Cartuja '93, 41092 Sevilla.
Teléfono: 955 036 800 - Fax: 955 036 849
http://www.isotrol.com

You let a political fight  come between you and your best friend you have in all 
the world. Do you realize how foolish that is? How ominous? How can this country survive 
if friends can't rise above the quarrel.
Constance Hazard, North  South (book I)


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

[PHP] cURL: multipart/form-data POST request with empty file part

2007-05-04 Thread Emmanuel Raulo-Kumagai

Hello

I'm writting a client in PHP for some CMS.
I need to send an HTTP POST request with a multipart/form-data content.
One of the parts is a file which must look like the request was issued 
after submitting a web form with a input type=file ... field left 
empty, which is *NOT* the same as sending an empty file.

This means the part should look like this in the request:

-8179530329826\r\n
Content-Disposition: form-data; name=file; filename=\r\n
Content-Type: application/octet-stream\r\n
\r\n
\r\n
-8179530329826\r\n

Is there a way to do so with cURL ?
Thanks in advance

--
Emmanuel

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



Re: [PHP] File uploading and saving info on mysql

2007-05-04 Thread Marcelo Wolfgang

Richard Lynch wrote:


Browsers will probably NOT populate these reliably...

Mac Safari, might, for example, choose application/x-pdf for the PDF
file.

You really can't rely on 'type' to be useful in any way, shape, or form.



Thanks for the tips, I've deleted this check, and changed how I check 
for the file type in the code.


and I've redone the code to match Jim Lucas suggestion also, it's 
working very nicely right now.


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



[PHP] Selecting a special row from the database

2007-05-04 Thread Marcelo Wolfgang

Hi all,

I'm building a news display page for a website, and since the user has 2 
ways to arrive there, I want to know if this is possible:


1) the user arrive at news.php

I will run a query at the db, and get the latest news to be the main one 
 (full display) and display the others news in a list


2) the user arrived from a link to a specific news to news.php?id=10

It should display the news with id = 10 as the main news and get the 
latest ones to display in a list of other news


I've so far was able to add a dinamic WHERE to my query ( if I have or 
not the id GET parameter ) and if I don't have it, I'm able to display 
the latest result as the main news, but when I have an id as a GET 
parameter, I have a where clause in my query and it will return only the 
main news and not build up the news list


what I want is to separate the news that the user want to see ( the 
id=XX one ) from the others rows, can someone advice me ?


Here is the code I have so far, I hope it serve as a better explanation 
than mine!


?
$newsId = $_GET['id'];
if (isset($newsID)){
$whereClause = 'WHERE auto_id ='.$newsId;
} else {
$whereClause = '';
}
mysql_connect(localhost,$user,$pass) or die (mysql_error());
mysql_select_db ($db_table);
$SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;
$news_Query = mysql_query($SQL);
$recordCount = mysql_numrows($news_Query);
mysql_close();
?

TIA
Marcelo Wolfgang

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



[PHP] Problem with timeout

2007-05-04 Thread Frank Arensmeier

Hello.

I am currently working on a script that parses a given http adress by  
looking for anchor tags, background images and so on - a crawler if  
you like. The downloaded content is temporarily stored on the server  
(Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the  
content is packed into a ZIP archive. It seems that I am having  
trouble with my Apache timeout setting. Because the script downloads  
between 250 and 300MB of html, pdf, css files and so on, it is  
terminated automatically after the specified timeout setting  
(currently 1200 seconds). Setting max execution time to -1 in the  
script has no effect (which has been noticed previously on the  
php.net manual page).


Is there any other way (with PHP) to come around this problem besides  
setting the time-out in the Apache config to more than 1200 seconds?  
The Apache manual says that the time out value can only be changed  
within the core configuration scope. My initial idea was to set the  
value in a .htaccess file which unfortunately is not allowed. I might  
also add that the script is already optimized for speed so to say.


Hope you get what I mean.

//frank

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



Re: [PHP] Selecting a special row from the database

2007-05-04 Thread Alister Bulman

On 04/05/07, Marcelo Wolfgang [EMAIL PROTECTED] wrote:


I'm building a news display page for a website, and since the user has 2
ways to arrive there, I want to know if this is possible:

1) the user arrive at news.php

I will run a query at the db, and get the latest news to be the main one
  (full display) and display the others news in a list

2) the user arrived from a link to a specific news to news.php?id=10

It should display the news with id = 10 as the main news and get the
latest ones to display in a list of other news



Here is the code I have so far, I hope it serve as a better explanation
than mine!



?
$newsId = $_GET['id'];
if (isset($newsID)){
$whereClause = 'WHERE auto_id ='.$newsId;
} else {
$whereClause = '';
}
mysql_connect(localhost,$user,$pass) or die (mysql_error());
mysql_select_db ($db_table);
$SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;


Yep, thats pretty classic.
One thing I would do - assuming $newsId should always be an integer

$whereClause = '';
if (isset($_GET['id']) {
 $newsId = intval($_GET['id']);
 if ($newsId)  // if not 0
   $whereClause = 'WHERE auto_id ='.$newsId;
}
.


Alister

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



Re: [PHP] Using timezones

2007-05-04 Thread Oliver Block
Am Freitag, 4. Mai 2007 13:39 schrieb Rob Desbois:
 What's the best way to go about providing this functionality? Should I just
 provide an option of all regional timezones (how do I use this?

If the user specifies the timezone, it might be comfortable to use the time 
zones as described in Appendix I.

http://de.php.net/manual/de/timezones.php

 The manual 
 says where to download a pre-compiled Windows DLL but doesn't explain how
 to use it). Even if I do that how should I obtain UTC time if UTC is a
 deprecated timezone?

AFAIK the timezone data is builtin by default, so you would not need to 
install anything else.

Regards,

Oliver

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



[PHP] Drawing all characters using GD

2007-05-04 Thread Seth Price
I have enough fonts installed on my machine to draw most of the  
world's UTF-8 characters. But they aren't all in one font file. How  
can I use the resources I have to reliably draw any character using  
imagetttext()?


For example: Most of the text I want to draw is regular ASCII, many  
words contain Extended ASCII. Then some of it is Korean, Chinese,  
Japanese or Arabic. I don't know when I'll come across what charset.  
I want to draw them all. Is this even possible?

~Seth

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay


 -Original Message-
 From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
 Sent: 04 May 2007 14:37
 To: php-general@lists.php.net
 Subject: [PHP] Selecting a special row from the database


 Hi all,

 I'm building a news display page for a website, and since the user has 2
 ways to arrive there, I want to know if this is possible:

 1) the user arrive at news.php

 I will run a query at the db, and get the latest news to be the main one
   (full display) and display the others news in a list

 2) the user arrived from a link to a specific news to news.php?id=10

 It should display the news with id = 10 as the main news and get the
 latest ones to display in a list of other news

 I've so far was able to add a dinamic WHERE to my query ( if I have or
 not the id GET parameter ) and if I don't have it, I'm able to display
 the latest result as the main news, but when I have an id as a GET
 parameter, I have a where clause in my query and it will return only the
 main news and not build up the news list

 what I want is to separate the news that the user want to see ( the
 id=XX one ) from the others rows, can someone advice me ?

 Here is the code I have so far, I hope it serve as a better explanation
 than mine!

 ?
 $newsId = $_GET['id'];
 if (isset($newsID)){
   $whereClause = 'WHERE auto_id ='.$newsId;
 } else {
   $whereClause = '';
 }
 mysql_connect(localhost,$user,$pass) or die (mysql_error());
 mysql_select_db ($db_table);
 $SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;
 $news_Query = mysql_query($SQL);
 $recordCount = mysql_numrows($news_Query);
 mysql_close();
 ?

 TIA
 Marcelo Wolfgang


If id is set, query the DB for this news article and put as the first
element in an array. Then perform a second query WHERE ID != id and append
the results to the array. If id isn't set, just perform the one query
without any where clause.

If you want to do it all in one query, if id is provided use SELECT... WHERE
ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get the ordering
you want. If id isn't set just use SELECT ... ORDER BY id DESC.

I'm not sure if there would be much difference in performance as I still
think the database would perform two queries internally.

Edward

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay
 -Original Message-
 From: Alister Bulman [mailto:[EMAIL PROTECTED]
 Sent: 04 May 2007 15:07
 To: php-general@lists.php.net
 Subject: Re: [PHP] Selecting a special row from the database


 On 04/05/07, Marcelo Wolfgang [EMAIL PROTECTED] wrote:

  I'm building a news display page for a website, and since the user has 2
  ways to arrive there, I want to know if this is possible:
 
  1) the user arrive at news.php
 
  I will run a query at the db, and get the latest news to be the main one
(full display) and display the others news in a list
 
  2) the user arrived from a link to a specific news to news.php?id=10
 
  It should display the news with id = 10 as the main news and get the
  latest ones to display in a list of other news

  Here is the code I have so far, I hope it serve as a better explanation
  than mine!

  ?
  $newsId = $_GET['id'];
  if (isset($newsID)){
  $whereClause = 'WHERE auto_id ='.$newsId;
  } else {
  $whereClause = '';
  }
  mysql_connect(localhost,$user,$pass) or die (mysql_error());
  mysql_select_db ($db_table);
  $SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;

 Yep, thats pretty classic.
 One thing I would do - assuming $newsId should always be an integer

 $whereClause = '';
 if (isset($_GET['id']) {
   $newsId = intval($_GET['id']);
   if ($newsId)  // if not 0
 $whereClause = 'WHERE auto_id ='.$newsId;
 }
 .


 Alister


This doesn't solve the problem. If ID is set, you'll only get one result.
Several results are always required, just with a different ordering. See my
other reply.

Edward

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



Re: [PHP] Selecting a special row from the database

2007-05-04 Thread Fredrik Thunberg



Edward Kay skrev:



-Original Message-
From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
Sent: 04 May 2007 14:37
To: php-general@lists.php.net
Subject: [PHP] Selecting a special row from the database


Hi all,

I'm building a news display page for a website, and since the user has 2
ways to arrive there, I want to know if this is possible:

1) the user arrive at news.php

I will run a query at the db, and get the latest news to be the main one
  (full display) and display the others news in a list

2) the user arrived from a link to a specific news to news.php?id=10

It should display the news with id = 10 as the main news and get the
latest ones to display in a list of other news

I've so far was able to add a dinamic WHERE to my query ( if I have or
not the id GET parameter ) and if I don't have it, I'm able to display
the latest result as the main news, but when I have an id as a GET
parameter, I have a where clause in my query and it will return only the
main news and not build up the news list

what I want is to separate the news that the user want to see ( the
id=XX one ) from the others rows, can someone advice me ?

Here is the code I have so far, I hope it serve as a better explanation
than mine!

?
$newsId = $_GET['id'];
if (isset($newsID)){
$whereClause = 'WHERE auto_id ='.$newsId;
} else {
$whereClause = '';
}
mysql_connect(localhost,$user,$pass) or die (mysql_error());
mysql_select_db ($db_table);
$SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;
$news_Query = mysql_query($SQL);
$recordCount = mysql_numrows($news_Query);
mysql_close();
?

TIA
Marcelo Wolfgang



If id is set, query the DB for this news article and put as the first
element in an array. Then perform a second query WHERE ID != id and append
the results to the array. If id isn't set, just perform the one query
without any where clause.

If you want to do it all in one query, if id is provided use SELECT... WHERE
ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get the ordering
you want. If id isn't set just use SELECT ... ORDER BY id DESC.

I'm not sure if there would be much difference in performance as I still
think the database would perform two queries internally.

Edward



Maybe
SELECT ..., if (id = my_id,1,0) as foo
...
ORDER BY foo DESC;

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Edward Kay


 -Original Message-
 From: Fredrik Thunberg [mailto:[EMAIL PROTECTED]
 Sent: 04 May 2007 15:31
 To: Edward Kay
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Selecting a special row from the database

 Edward Kay skrev:
 
  -Original Message-
  From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
  Sent: 04 May 2007 14:37
  To: php-general@lists.php.net
  Subject: [PHP] Selecting a special row from the database
 
 
  Hi all,
 
  I'm building a news display page for a website, and since the
 user has 2
  ways to arrive there, I want to know if this is possible:
 
  1) the user arrive at news.php
 
  I will run a query at the db, and get the latest news to be
 the main one
(full display) and display the others news in a list
 
  2) the user arrived from a link to a specific news to news.php?id=10
 
  It should display the news with id = 10 as the main news and get the
  latest ones to display in a list of other news
 
  I've so far was able to add a dinamic WHERE to my query ( if I have or
  not the id GET parameter ) and if I don't have it, I'm able to display
  the latest result as the main news, but when I have an id as a GET
  parameter, I have a where clause in my query and it will
 return only the
  main news and not build up the news list
 
  what I want is to separate the news that the user want to see ( the
  id=XX one ) from the others rows, can someone advice me ?
 
  Here is the code I have so far, I hope it serve as a better explanation
  than mine!
 
  ?
  $newsId = $_GET['id'];
  if (isset($newsID)){
 $whereClause = 'WHERE auto_id ='.$newsId;
  } else {
 $whereClause = '';
  }
  mysql_connect(localhost,$user,$pass) or die (mysql_error());
  mysql_select_db ($db_table);
  $SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;
  $news_Query = mysql_query($SQL);
  $recordCount = mysql_numrows($news_Query);
  mysql_close();
  ?
 
  TIA
  Marcelo Wolfgang
 
 
  If id is set, query the DB for this news article and put as the first
  element in an array. Then perform a second query WHERE ID != id
 and append
  the results to the array. If id isn't set, just perform the one query
  without any where clause.
 
  If you want to do it all in one query, if id is provided use
 SELECT... WHERE
  ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get
 the ordering
  you want. If id isn't set just use SELECT ... ORDER BY id DESC.
 
  I'm not sure if there would be much difference in performance as I still
  think the database would perform two queries internally.
 
  Edward
 

 Maybe
 SELECT ..., if (id = my_id,1,0) as foo
 ...
 ORDER BY foo DESC;


Good idea! Just tried it out and it works really well.

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



Re: [PHP] Limit query results

2007-05-04 Thread Jim Lucas

Dan Shirah wrote:

 $result = mssql_query($sql) or die(mssql_error());
  // print_r ($result);
You realize that this will print the Resource ID# for the resource pointer, but not the actual 
result set.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Unknown

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



[PHP] Send binary files with gzip encoding disabled

2007-05-04 Thread strawks
Hello,

I'm trying to send a ZIP file generated on the fly in a temporary directory.
The ZIP file is created successfully and I'm using the following code to send 
it to the client :

$filesize=filesize($path);
$mimetype='application/zip';

// Make sure there's not anything else left
ob_clean_all();

// Start sending headers
header(Pragma: public); // required
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain browsers
header(Content-Transfer-Encoding: binary);
header(Content-Description: File Transfer);
header(Content-Type: .$mimetype);
header(Content-Disposition: attachment; filename=\.$name.\; );
header(Content-Length: .$filesize);

[EMAIL PROTECTED]($path,rb); 
while([EMAIL PROTECTED]($fp))
{
set_time_limit(0);
print @fread($fp, 8192);
}
@fclose($fp);

The ob_clean_all() function :
function ob_clean_all () {
$ob_active = ob_get_length () !== false;
while($ob_active) {
ob_end_clean();
$ob_active = ob_get_length () !== false;
}

return true;
}

The problem is that Apache process the output throught gzip and so drop the 
Content-Length header replacing it with a chunked transfer. This should work 
fine but Internet Explorer simply save the raw gzip compressed data instead of 
the ZIP archive. However this works fine with Firefox.

gzip encoding is unecessary since I'm transfering a ZIP archive, so I think 
just disabling it should solve the problem, but I haven't found how to do this.

Any help would be appreciated.

-- 
strawks.


 
-
 Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses.

[PHP] Re: Name Capitalization

2007-05-04 Thread Michelle Konzack
Am 2007-03-21 16:57:36, schrieb Shafiq Rehman:
 Hi,
 
 Some problems are universal and we cannot fix them in computer science. I
 think it's better to educate/guide your visitors about such names that they
 write in correct capitalization

ROTFL  -  In this brandamaged world!

Greetings
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSN LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


[PHP] Re: Name Capitalization

2007-05-04 Thread Michelle Konzack
Am 2007-03-23 21:27:40, schrieb Richard Lynch:
 The solution remains:
 
 Hire a human.
 
 The computer will never get accurate enough.
 
 The exception might be if you are dealing with MILLIONS of names,
 where a filter would pay off.  You'd still need human review and a
 validation process that involved human oversight to a significant
 percentage.
 
 I do not think the OP has millions of names.

Only arround 48000.

The filter should check, whether the inputstring is ONLY CAPITAL
LETTERS or ONLY SMALL LETTERS and then it should act.

I do this too with some input fields (no big text fields) since
$USER are baindamaged in relation to the right capitalization.

Oh, if someone type a name NOT in the database, my system inform
me with an E-Mail.  So I can update the list.

Please note, that I have one list per country which is sometimes
redunant but reduce errors...

Greetings
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSN LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


[PHP] Re: Name Capitalization

2007-05-04 Thread Michelle Konzack
  Can anyone tell me, WHY I get this message plus
  some others from this thread today (2005-05-03)?


Am 2007-03-19 12:22:10, schrieb Leonard Burton:
 HI All,
 
 Does anyone use a library to properly capitalize last names?

Yes me, but it is my own one which I have created
from a (commercial) CD...

 For instance, McDonald needs to remain that way even if it comes in as
 MACDONALD, or macdonald.

I hate USER which some subscribing to something and
do not know anything about capitalization...

 Of course I can write it on my own but would prefer not to reinvent the 
 wheel.

I do not know a free database but you can do something
your own with a telephone number CD... 

It took me arround 5 weesks to get the 27 compressed
650 MByte CD's giving out the First- and Family-Names.

I think, you have do it yourself...

ATTENTION:  You need Country/Language specific lists...
(Someone was talking about this in the thread)


   Anyway, why not reject any $USER input, which has
   only CAPITALS/SMALL LETTERS?

Greetings
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSN LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


[PHP] Re: Problem with timeout

2007-05-04 Thread Emmanuel Raulo-Kumagai

Frank Arensmeier a écrit :

Hello.

I am currently working on a script that parses a given http adress by 
looking for anchor tags, background images and so on - a crawler if you 
like. The downloaded content is temporarily stored on the server (Mac OS 
X Server 10.4.9 with PHP 5) and, when the script is done, the content is 
packed into a ZIP archive. It seems that I am having trouble with my 
Apache timeout setting. Because the script downloads between 250 and 
300MB of html, pdf, css files and so on, it is terminated automatically 
after the specified timeout setting (currently 1200 seconds). Setting 
max execution time to -1 in the script has no effect (which has been 
noticed previously on the php.net manual page).


Is there any other way (with PHP) to come around this problem besides 
setting the time-out in the Apache config to more than 1200 seconds? The 
Apache manual says that the time out value can only be changed within 
the core configuration scope. My initial idea was to set the value in a 
.htaccess file which unfortunately is not allowed. I might also add that 
the script is already optimized for speed so to say.


Hope you get what I mean.

//frank


Hello Frank

Are you really sure you need an Apache-spawned PHP script to do all that
long stuff ? Even if Apache does not give up on your PHP script, the
HTTP client might do so. This is also not a good idea for a site with
several clients because Apache could easily run low on available
sockets, causing a DoS.

I suggest you just spawn a background process from your PHP script,
through some shell command like batch and nohup. The background process
can still be coded in PHP with the CLI interface.
At the end of the long process, you alert the user job was done (e.g.
by mail or by some kind of AJAX mechanism) and let him download the
result.

In the Apache-spawned script:

?php
// This will launch the process in background.
// Be sure to set $job_id.
$cmd_path = /path/to/some/job/dir/job$job_id.sh;
$cmd = fopen( $cmd_path, 'w' );
fwrite(
  $cmd,
  #!/bin/sh\n.
  nohup php -f /path/to/your/scripts/long_process.php someargs\n.
  rm -f $cmd_path );
fclose( $cmd );
shell_exec( batch -f $cmd_path );

// Tell the user the job was scheduled...
?

In long_process.php:

?php
// Do your stuff...

// Send an e-mail to the user or change a persistent server-side
// state so that a script called periodically by the client will let
// her know it was done.
?

You may need to give the right to www-data, or whatever account running
Apache, to create jobs through at/batch.

Regards

--
Emmanuel

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



Re: [PHP] PHP's ldap_sasl_bind tries to authenticate with KRB5CCNAME other than the one provided by mod_auth_kerb

2007-05-04 Thread javier.pb

My platform is basically debian sarge + heimdal gssapi, but I have exactly
the same problem.

I have a way to solve the issue, but it is not valid for any kind of
production site. Just add in your php code this

copy(substr($_SERVER['KRB5CCNAME'],5),/tmp/krb5cc_0);

and you'll get a real bind (you see the ldap ticket with klist). I think
that I must use the uid 0 for the credential cache because my apache master
process is owned by root. If it did start with a different user, you
probably need to change the '_0'.

If you don't expect heavy usage and don't care about  run conditions, you
might use it as is. I might recommend some basic existence checks to avoid
collisions and possible impersonation (In my case, different users have
different persmissions on the ldap tree), but I believe it will not scale in
any sensible manner.

I'm afraid that this is due to the fact that mod-php (and php-ldap) is
loaded during initialization, and looks like the credential cache value is
either frozen or not taken from environment.

I've tried to use putenv and apache_setenv, as well as manually fix $_ENV
with no success, but I'm unsure if any of them have the same effect than
export a shell variable, which is what is actually expect.




-- 
View this message in context: 
http://www.nabble.com/PHP%27s-ldap_sasl_bind-tries-to-authenticate-with-KRB5CCNAME-other-than-the-one-provided-by-mod_auth_kerb-tf3681101.html#a10323750
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] Re: Send binary files with gzip encoding disabled

2007-05-04 Thread Emmanuel Raulo-Kumagai

strawks a écrit :

Hello,

I'm trying to send a ZIP file generated on the fly in a temporary directory.
The ZIP file is created successfully and I'm using the following code to send 
it to the client :

$filesize=filesize($path);
$mimetype='application/zip';

// Make sure there's not anything else left
ob_clean_all();

// Start sending headers
header(Pragma: public); // required
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: private,false); // required for certain browsers
header(Content-Transfer-Encoding: binary);
header(Content-Description: File Transfer);
header(Content-Type: .$mimetype);
header(Content-Disposition: attachment; filename=\.$name.\; );
header(Content-Length: .$filesize);

[EMAIL PROTECTED]($path,rb); 
while([EMAIL PROTECTED]($fp))

{
set_time_limit(0);
print @fread($fp, 8192);
}
@fclose($fp);

The ob_clean_all() function :
function ob_clean_all () {
$ob_active = ob_get_length () !== false;
while($ob_active) {
ob_end_clean();
$ob_active = ob_get_length () !== false;
}

return true;
}

The problem is that Apache process the output throught gzip and so drop the 
Content-Length header replacing it with a chunked transfer. This should work 
fine but Internet Explorer simply save the raw gzip compressed data instead of 
the ZIP archive. However this works fine with Firefox.

gzip encoding is unecessary since I'm transfering a ZIP archive, so I think 
just disabling it should solve the problem, but I haven't found how to do this.

Any help would be appreciated.



Hello,

I have about the same code except that I use application/x-zip-archive
for the content type and it just works.
There's no ob_* stuff in my code also.

'hope that helps you out...

--
Emmanuel

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



Re: [PHP] Re: Name Capitalization

2007-05-04 Thread Paul Novitski

At 5/4/2007 08:10 AM, Michelle Konzack wrote:

Anyway, why not reject any $USER input, which has
   only CAPITALS/SMALL LETTERS?



Because the OP is dealing with an existing dataset of all-caps names 
inherited from another system.


These names are not currently being input by users.  If that were the 
case, prompting users to unstick their shift keys would be possible.


Regards,

Paul
__

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


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



Re: [PHP] Selecting a special row from the database

2007-05-04 Thread Emmanuel Raulo-Kumagai

Edward Kay a écrit :



-Original Message-
From: Fredrik Thunberg [mailto:[EMAIL PROTECTED]
Sent: 04 May 2007 15:31
To: Edward Kay
Cc: php-general@lists.php.net
Subject: Re: [PHP] Selecting a special row from the database

Edward Kay skrev:

-Original Message-
From: Marcelo Wolfgang [mailto:[EMAIL PROTECTED]
Sent: 04 May 2007 14:37
To: php-general@lists.php.net
Subject: [PHP] Selecting a special row from the database


Hi all,

I'm building a news display page for a website, and since the

user has 2

ways to arrive there, I want to know if this is possible:

1) the user arrive at news.php

I will run a query at the db, and get the latest news to be

the main one

  (full display) and display the others news in a list

2) the user arrived from a link to a specific news to news.php?id=10

It should display the news with id = 10 as the main news and get the
latest ones to display in a list of other news

I've so far was able to add a dinamic WHERE to my query ( if I have or
not the id GET parameter ) and if I don't have it, I'm able to display
the latest result as the main news, but when I have an id as a GET
parameter, I have a where clause in my query and it will

return only the

main news and not build up the news list

what I want is to separate the news that the user want to see ( the
id=XX one ) from the others rows, can someone advice me ?

Here is the code I have so far, I hope it serve as a better explanation
than mine!

?
$newsId = $_GET['id'];
if (isset($newsID)){
$whereClause = 'WHERE auto_id ='.$newsId;
} else {
$whereClause = '';
}
mysql_connect(localhost,$user,$pass) or die (mysql_error());
mysql_select_db ($db_table);
$SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;
$news_Query = mysql_query($SQL);
$recordCount = mysql_numrows($news_Query);
mysql_close();
?

TIA
Marcelo Wolfgang


If id is set, query the DB for this news article and put as the first
element in an array. Then perform a second query WHERE ID != id

and append

the results to the array. If id isn't set, just perform the one query
without any where clause.

If you want to do it all in one query, if id is provided use

SELECT... WHERE

ID = id UNION (SELECT...WHERE ID != id ORDER BY id DESC) to get

the ordering

you want. If id isn't set just use SELECT ... ORDER BY id DESC.

I'm not sure if there would be much difference in performance as I still
think the database would perform two queries internally.

Edward


Maybe
SELECT ..., if (id = my_id,1,0) as foo
...
ORDER BY foo DESC;



Good idea! Just tried it out and it works really well.


Hello,

If you're looking for performance, why do you select everything for 
articles that are not in full display ?
Isn't it better if you SELECT * just for the article you want in full 
display and make another query for other titles ?

LIMIT would also help performance.
Cheers

--
Emmanuel

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



[PHP] Loop problem

2007-05-04 Thread Dan Shirah

Okay, I think this is a 1/2 PHP problem and 1/2 Javascript problem.  And I
think my Javascript problem is being caused by my PHP.  Follow?

The code below is a loop of records returned from my query:

1 - If the result is not empty it will loop through the results.
2 - It assigns variables based on columns from the query.
3 - The first column of the row is the ID which is used by the Javascript to
pull up the correct record.
4 - I put in a hidden value to assign all the rows in this loop a
request_type value.
5 - When someone clicks on a record ID it calls the Javascript to alert
the ID and request_type.
6 - If the loop only returns a single record, the alert displays
correctly.  Example: The type is:C The ID is:80
7 - If the loop returns multiple records, the alert does not return the
correct values.

Example: The type is:undefined The ID is:80
  The type is:undefined The ID is:85
  The type is:undefined The ID is:104

Why do I only get undefined if the loop returns more than a single
record???

***The Javascript***

function showAlert(id) {
var type;
type = document.Submit.request_type.value

alert( 'The type is:' + type + 'The ID is:' + id );
}

***The Form***

table align=center border=0 cellpadding=0 cellspacing=0
width=680
?php
if(!empty($result_payments)) {
while ($row_payments = mssql_fetch_array($result_payments)) {
  $id = $row_payments['child_support_id'];
  $case_number = $row_payments['case_number'];
  $payment_amount = $row_payments['payment_amount'];
  $total += $row_payments['payment_amount'];
?

 tr
   td width=21ID:/td
   td width=88?php echo a href='javascript:showAlert($id)'$id/a
?/td
   td width=98Case Number:/td
   td width=252?php echo $case_number; ?/td
   td width=116div align=rightPayment Amount:/div/td
   td width=105div align=right$?php echo
number_format($payment_amount, 2); ?/div/td
   input type=hidden name=request_type value=C
 /tr

?php
   }
}
?
/table


Re: [PHP] Loop problem

2007-05-04 Thread Daniel Brown

   I know you said it's a form but where does the browser realize that?

   Using a hidden value such as that would require a POST or GET action via
a form.  JavaScript wouldn't work for that.  However, you could do something
like this:

snip
SCRIPT LANGUAGE=JavaScript
function showAlert(id,type) {
   alert('The type is:' + type + ' - The ID is:' + id);
}
/SCRIPT
?
while($row_payments = mssql_fetch_array($result_payments)) {
   extract($row_payments);
   $total += $payment_amount;
?
   tr
   td width=21ID:/td
   td width=88a
href=javascript:showAlert('?=$child_support_id;?','C')?=$child_support_id;?/a/td
   td width=98Case Number:/td
   td width=252?=$case_number;?/td
   td width=116div align=rightPayment
Amount:/div/td
   td width=105div
align=right$?=number_format($payment_amount,2);?/div/td
   /tr
?
/snip

   If 'C' isn't a constant, but rather a dynamic value from a column in a
database (named the same as the convention in your example suggests), then
simply modify it as such:
td width=88a
href=javascript:showAlert('?=$child_support_id;?','?=$request_type;?')?=$child_support_id;?/a/td

   That should do it for you.


On 5/4/07, Dan Shirah [EMAIL PROTECTED] wrote:


Okay, I think this is a 1/2 PHP problem and 1/2 Javascript problem.  And I
think my Javascript problem is being caused by my PHP.  Follow?

The code below is a loop of records returned from my query:

1 - If the result is not empty it will loop through the results.
2 - It assigns variables based on columns from the query.
3 - The first column of the row is the ID which is used by the Javascript
to
pull up the correct record.
4 - I put in a hidden value to assign all the rows in this loop a
request_type value.
5 - When someone clicks on a record ID it calls the Javascript to alert
the ID and request_type.
6 - If the loop only returns a single record, the alert displays
correctly.  Example: The type is:C The ID is:80
7 - If the loop returns multiple records, the alert does not return the
correct values.

Example: The type is:undefined The ID is:80
   The type is:undefined The ID is:85
   The type is:undefined The ID is:104

Why do I only get undefined if the loop returns more than a single
record???

***The Javascript***

function showAlert(id) {
var type;
type = document.Submit.request_type.value

alert( 'The type is:' + type + 'The ID is:' + id );
}

***The Form***

table align=center border=0 cellpadding=0 cellspacing=0
width=680
?php
if(!empty($result_payments)) {
while ($row_payments = mssql_fetch_array($result_payments)) {
   $id = $row_payments['child_support_id'];
   $case_number = $row_payments['case_number'];
   $payment_amount = $row_payments['payment_amount'];
   $total += $row_payments['payment_amount'];
?

  tr
td width=21ID:/td
td width=88?php echo a
href='javascript:showAlert($id)'$id/a
?/td
td width=98Case Number:/td
td width=252?php echo $case_number; ?/td
td width=116div align=rightPayment Amount:/div/td
td width=105div align=right$?php echo
number_format($payment_amount, 2); ?/div/td
input type=hidden name=request_type value=C
  /tr

?php
}
}
?
/table


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


RE: [PHP] cURL: multipart/form-data POST request with empty file part

2007-05-04 Thread Brad Fuller
Emmanuel Raulo-Kumagai wrote:
 Sent: Friday, May 04, 2007 8:44 AM
 To: php-general@lists.php.net
 Subject: [PHP] cURL: multipart/form-data POST request with 
 empty file part
 
 Hello
 
 I'm writting a client in PHP for some CMS.
 I need to send an HTTP POST request with a 
 multipart/form-data content.
 One of the parts is a file which must look like the request 
 was issued after submitting a web form with a input 
 type=file ... field left empty, which is *NOT* the same as 
 sending an empty file.
 This means the part should look like this in the request:
 
 -8179530329826\r\n
 Content-Disposition: form-data; name=file; filename=\r\n
 Content-Type: application/octet-stream\r\n \r\n \r\n 
 -8179530329826\r\n
 
 Is there a way to do so with cURL ?

Possibly.  Search the web for CURLOPT_CUSTOMREQUEST.

If cURL won't do what you need, you can always send a custom HTTP POST
request using fsockopen().  Again, search the web for examples.

-B

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



Re: [PHP] Loop problem

2007-05-04 Thread Dan Shirah

Thank you Daniel!!

I didn't do it exactly as you suggested, but you put me in exactly the right
direction!  THANK YOU!

Below is how I have it working if anyone else is interested.

The javascript
function showAlert(id,type) {

alert( 'The type is:' + type + 'The ID is:' + id );
}

The Form
?php
if(!empty($result_payments)) {
while ($row_payments = mssql_fetch_array($result_payments)) {
  $id = $row_payments['child_support_id'];
  $case_number = $row_payments['case_number'];
  $payment_amount = $row_payments['payment_amount'];
  $total += $row_payments['payment_amount'];
?

 tr
   td width=21ID:/td
   td width=88a href=javascript:showAlert('?php echo $id;
?','C')?php echo $id; ?/a/td
   td width=98Case Number:/td
   td width=252?php echo $case_number; ?/td
   td width=116div align=rightPayment Amount:/div/td
   td width=105div align=right$?php echo
number_format($payment_amount, 2); ?/div/td

 /tr
 ?php
}
}
?
thanks again.


On 5/4/07, Daniel Brown [EMAIL PROTECTED] wrote:



I know you said it's a form but where does the browser realize
that?

Using a hidden value such as that would require a POST or GET action
via a form.  JavaScript wouldn't work for that.  However, you could do
something like this:

snip
SCRIPT LANGUAGE=JavaScript
function showAlert(id,type) {
alert('The type is:' + type + ' - The ID is:' + id);
}
/SCRIPT
?
while($row_payments = mssql_fetch_array($result_payments)) {
extract($row_payments);
$total += $payment_amount;
?
tr
td width=21ID:/td
td width=88a
href=javascript:showAlert('?=$child_support_id;?','C')?=$child_support_id;?/a/td

td width=98Case Number:/td
td width=252?=$case_number;?/td
td width=116div align=rightPayment
Amount:/div/td
td width=105div
align=right$?=number_format($payment_amount,2);?/div/td
/tr
?
/snip

If 'C' isn't a constant, but rather a dynamic value from a column in a
database (named the same as the convention in your example suggests), then
simply modify it as such:
td width=88a
href=javascript:showAlert('?=$child_support_id;?','?=$request_type;?')?=$child_support_id;?/a/td

That should do it for you.


On 5/4/07, Dan Shirah [EMAIL PROTECTED] wrote:

 Okay, I think this is a 1/2 PHP problem and 1/2 Javascript problem.  And
 I
 think my Javascript problem is being caused by my PHP.  Follow?

 The code below is a loop of records returned from my query:

 1 - If the result is not empty it will loop through the results.
 2 - It assigns variables based on columns from the query.
 3 - The first column of the row is the ID which is used by the
 Javascript to
 pull up the correct record.
 4 - I put in a hidden value to assign all the rows in this loop a
 request_type value.
 5 - When someone clicks on a record ID it calls the Javascript to
 alert
 the ID and request_type.
 6 - If the loop only returns a single record, the alert displays
 correctly.  Example: The type is:C The ID is:80
 7 - If the loop returns multiple records, the alert does not return
 the
 correct values.

 Example: The type is:undefined The ID is:80
The type is:undefined The ID is:85
The type is:undefined The ID is:104

 Why do I only get undefined if the loop returns more than a single
 record???

 ***The Javascript***

 function showAlert(id) {
 var type;
 type = document.Submit.request_type.value

 alert( 'The type is:' + type + 'The ID is:' + id );
 }

 ***The Form***

 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
 ?php
 if(!empty($result_payments)) {
 while ($row_payments = mssql_fetch_array($result_payments)) {
$id = $row_payments['child_support_id'];
$case_number = $row_payments['case_number'];
$payment_amount = $row_payments['payment_amount'];
$total += $row_payments['payment_amount'];
 ?

   tr
 td width=21ID:/td
 td width=88?php echo a
 href='javascript:showAlert($id)'$id/a
 ?/td
 td width=98Case Number:/td
 td width=252?php echo $case_number; ?/td
 td width=116div align=rightPayment Amount:/div/td
 td width=105div align=right$?php echo
 number_format($payment_amount, 2); ?/div/td
 input type=hidden name=request_type value=C
   /tr

 ?php
 }
 }
 ?
 /table

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


Re: [PHP] Loop problem

2007-05-04 Thread Daniel Brown

   No problem.  I just prefer to use extract() for areas that are only
pulling out a single set of data, or several sets with different variable
names within the array.  Less typing, no reassignments necessary.  Personal
preference, that's all.

On 5/4/07, Dan Shirah [EMAIL PROTECTED] wrote:


Thank you Daniel!!

I didn't do it exactly as you suggested, but you put me in exactly the
right direction!  THANK YOU!

Below is how I have it working if anyone else is interested.

The javascript
function showAlert(id,type) {

 alert( 'The type is:' + type + 'The ID is:' + id );
 }

The Form
?php
if(!empty($result_payments)) {
while ($row_payments = mssql_fetch_array($result_payments)) {
   $id = $row_payments['child_support_id'];
   $case_number = $row_payments['case_number'];
   $payment_amount = $row_payments['payment_amount'];
   $total += $row_payments['payment_amount'];
?

  tr
td width=21ID:/td
td width=88a href=javascript:showAlert('?php echo $id;
?','C')?php echo $id; ?/a/td
td width=98Case Number:/td
td width=252?php echo $case_number; ?/td
td width=116div align=rightPayment Amount:/div/td
td width=105div align=right$?php echo
number_format($payment_amount, 2); ?/div/td

  /tr
  ?php
 }
}
?
thanks again.


On 5/4/07, Daniel Brown [EMAIL PROTECTED] wrote:


 I know you said it's a form but where does the browser realize
 that?

 Using a hidden value such as that would require a POST or GET action
 via a form.  JavaScript wouldn't work for that.  However, you could do
 something like this:

 snip
 SCRIPT LANGUAGE=JavaScript
 function showAlert(id,type) {
 alert('The type is:' + type + ' - The ID is:' + id);
 }
 /SCRIPT
 ?
 while($row_payments = mssql_fetch_array($result_payments)) {
 extract($row_payments);
 $total += $payment_amount;
 ?
 tr
 td width=21ID:/td
 td width=88a
 
href=javascript:showAlert('?=$child_support_id;?','C')?=$child_support_id;?/a/td

 td width=98Case Number:/td
 td width=252?=$case_number;?/td
 td width=116div align=rightPayment
 Amount:/div/td
 td width=105div
 align=right$?=number_format($payment_amount,2);?/div/td
 /tr
 ?
 /snip

 If 'C' isn't a constant, but rather a dynamic value from a column in
 a database (named the same as the convention in your example suggests), then
 simply modify it as such:
 td width=88a
 
href=javascript:showAlert('?=$child_support_id;?','?=$request_type;?')?=$child_support_id;?/a/td

 That should do it for you.


 On 5/4/07, Dan Shirah  [EMAIL PROTECTED] wrote:
 
  Okay, I think this is a 1/2 PHP problem and 1/2 Javascript
  problem.  And I
  think my Javascript problem is being caused by my PHP.  Follow?
 
  The code below is a loop of records returned from my query:
 
  1 - If the result is not empty it will loop through the results.
  2 - It assigns variables based on columns from the query.
  3 - The first column of the row is the ID which is used by the
  Javascript to
  pull up the correct record.
  4 - I put in a hidden value to assign all the rows in this loop a
  request_type value.
  5 - When someone clicks on a record ID it calls the Javascript to
  alert
  the ID and request_type.
  6 - If the loop only returns a single record, the alert displays
  correctly.  Example: The type is:C The ID is:80
  7 - If the loop returns multiple records, the alert does not return
  the
  correct values.
 
  Example: The type is:undefined The ID is:80
 The type is:undefined The ID is:85
 The type is:undefined The ID is:104
 
  Why do I only get undefined if the loop returns more than a single
  record???
 
  ***The Javascript***
 
  function showAlert(id) {
  var type;
  type = document.Submit.request_type.value
 
  alert( 'The type is:' + type + 'The ID is:' + id );
  }
 
  ***The Form***
 
  table align=center border=0 cellpadding=0 cellspacing=0
  width=680
  ?php
  if(!empty($result_payments)) {
  while ($row_payments = mssql_fetch_array($result_payments)) {
 $id = $row_payments['child_support_id'];
 $case_number = $row_payments['case_number'];
 $payment_amount = $row_payments['payment_amount'];
 $total += $row_payments['payment_amount'];
  ?
 
tr
  td width=21ID:/td
  td width=88?php echo a
  href='javascript:showAlert($id)'$id/a
  ?/td
  td width=98Case Number:/td
  td width=252?php echo $case_number; ?/td
  td width=116div align=rightPayment Amount:/div/td
  td width=105div align=right$?php echo
  number_format($payment_amount, 2); ?/div/td
  input type=hidden name=request_type value=C
/tr
 
  ?php
  }
  }
  ?
  /table
 
 --
 Daniel P. Brown
 [office] (570-) 587-7080 Ext. 272
 [mobile] (570-) 766-8107






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


Re: [PHP] Re: Problem with timeout

2007-05-04 Thread Frank Arensmeier

// sorry for posting my answer off list... //

4 maj 2007 kl. 17.35 skrev Emmanuel Raulo-Kumagai:


Frank Arensmeier a écrit :

Hello.
I am currently working on a script that parses a given http adress  
by looking for anchor tags, background images and so on - a  
crawler if you like. The downloaded content is temporarily stored  
on the server (Mac OS X Server 10.4.9 with PHP 5) and, when the  
script is done, the content is packed into a ZIP archive. It seems  
that I am having trouble with my Apache timeout setting. Because  
the script downloads between 250 and 300MB of html, pdf, css files  
and so on, it is terminated automatically after the specified  
timeout setting (currently 1200 seconds). Setting max execution  
time to -1 in the script has no effect (which has been noticed  
previously on the php.net manual page).
Is there any other way (with PHP) to come around this problem  
besides setting the time-out in the Apache config to more than  
1200 seconds? The Apache manual says that the time out value can  
only be changed within the core configuration scope. My initial  
idea was to set the value in a .htaccess file which unfortunately  
is not allowed. I might also add that the script is already  
optimized for speed so to say.

Hope you get what I mean.
//frank


Hello Frank

Are you really sure you need an Apache-spawned PHP script to do all  
that

long stuff ? Even if Apache does not give up on your PHP script, the
HTTP client might do so. This is also not a good idea for a site with
several clients because Apache could easily run low on available
sockets, causing a DoS.

I suggest you just spawn a background process from your PHP script,
through some shell command like batch and nohup. The background  
process

can still be coded in PHP with the CLI interface.


Thank you for sharing your suggestions.

The idea of running the script as a background process seems very  
elegant to me, I have to admit. Since my script is executed only once  
a week, it would be sufficient to set up a simple cron job.  
Modifications to the script are also rather small, since I already  
have e.g. functions for output logging, process locking and so on.



At the end of the long process, you alert the user job was done (e.g.
by mail or by some kind of AJAX mechanism) and let him download the
result.

In the Apache-spawned script:

?php
// This will launch the process in background.
// Be sure to set $job_id.
$cmd_path = /path/to/some/job/dir/job$job_id.sh;
$cmd = fopen( $cmd_path, 'w' );
fwrite(
  $cmd,
  #!/bin/sh\n.
  nohup php -f /path/to/your/scripts/long_process.php someargs\n.
  rm -f $cmd_path );
fclose( $cmd );
shell_exec( batch -f $cmd_path );

// Tell the user the job was scheduled...
?

In long_process.php:

?php
// Do your stuff...

// Send an e-mail to the user or change a persistent server-side
// state so that a script called periodically by the client will let
// her know it was done.
?

You may need to give the right to www-data, or whatever account  
running

Apache, to create jobs through at/batch.

Regards

--
Emmanuel

--
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] Loop problem

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 1:02 pm, Dan Shirah wrote:

  type = document.Submit.request_type.value

If you have only one request_type button, JavaScript can sorta
figure out which one you want here, cuz there's only one.

As soon as you have a whole bunch of them, it's got no idea which one
you want...

The easiest fix I can see would be to give each submit button a unique
name (or id, or both) so that you are looking for something more like:
var name = 'request_type_' + id;
var type = document.Submit[name].value;
or somesuch.

I dunno JS well enough to know that I've done the right thing, but go
that direction.

Maybe even go whole who and use that nifty getElementById function.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: Name Capitalization

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 10:10 am, Michelle Konzack wrote:
Anyway, why not reject any $USER input, which has
only CAPITALS/SMALL LETTERS?

$first_name = 'J.K.';
$last_name = 'Rowling';

$first_name = 'e.e.';
$last_name = 'cummings';

.
.
.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Send binary files with gzip encoding disabled

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 9:56 am, strawks wrote:
 $filesize=filesize($path);
 $mimetype='application/zip';

 // Make sure there's not anything else left
 ob_clean_all();

 // Start sending headers
 header(Pragma: public); // required
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0,
 pre-check=0);
 header(Cache-Control: private,false); // required for certain
 browsers
 header(Content-Transfer-Encoding: binary);
 header(Content-Description: File Transfer);
 header(Content-Type: .$mimetype);
 header(Content-Disposition: attachment; filename=\.$name.\;
 );
 header(Content-Length: .$filesize);

All these headers scare me -- I've found that if you add all these,
sooner or later, you run into some browser that didn't do it right
anyway.

You may want to look at an alternative K.I.S.S. approach (rant):
http://richardlynch.blogspot.com
YMMV

 The problem is that Apache process the output throught gzip and so
 drop the Content-Length header replacing it with a chunked transfer.
 This should work fine but Internet Explorer simply save the raw gzip
 compressed data instead of the ZIP archive. However this works fine
 with Firefox.

 gzip encoding is unecessary since I'm transfering a ZIP archive, so I
 think just disabling it should solve the problem, but I haven't found
 how to do this.

There was a discussion yesterday on php-internals regarding Apache/PHP
forcing the HTTP response to 1.1 even if the browser asked for 1.0.

Part of that discussion was a sub-discussion about how it ought to be
possible for a PHP developer to FORCE the response to be 1.0

If your response is 1.0, there would be no chunking, as I understand it.

So there may be an answer for you buried in that thread, or you may
want to weigh in on a real-world need for this feature.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Drawing all characters using GD

2007-05-04 Thread Richard Lynch


On Fri, May 4, 2007 9:23 am, Seth Price wrote:
 I have enough fonts installed on my machine to draw most of the
 world's UTF-8 characters. But they aren't all in one font file. How
 can I use the resources I have to reliably draw any character using
 imagetttext()?

 For example: Most of the text I want to draw is regular ASCII, many
 words contain Extended ASCII. Then some of it is Korean, Chinese,
 Japanese or Arabic. I don't know when I'll come across what charset.
 I want to draw them all. Is this even possible?

I don't think there is any one giant charset you could have that would
slap all the languages together...

The whole point of a charset is to set up correspondences between
numbers and the letter you see.

So every different charset is just a mapping from a number to a
glpyh (the physical representation of the letter, like a series of
pen-strokes, as I understand it)

And presumably the guys making up UTF-8, UTF-16, and UTF-32 didn't
make these numbers up just for fun, and actually have languages that
NEED 32 bits to represent every letter.

I suppose, in theory, you could take every charset, and create a
UTF-40 which used 40 bits, and use the first byte (8 bits) for an
offset and then you could map your super-charset back to normal
charsets, assuming there are no more than 255 languages to support.

I guess if there's more than 255 languages, you're looking at even
more bits/bytes...

Sounds like a lot of work, though...

Maybe ask over on the i18n PHP mailing list, as they're way more
familiar with this stuff than most users here.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Problem with timeout

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 8:37 am, Frank Arensmeier wrote:
 I am currently working on a script that parses a given http adress by
 looking for anchor tags, background images and so on - a crawler if
 you like. The downloaded content is temporarily stored on the server
 (Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the
 content is packed into a ZIP archive. It seems that I am having
 trouble with my Apache timeout setting. Because the script downloads
 between 250 and 300MB of html, pdf, css files and so on, it is
 terminated automatically after the specified timeout setting
 (currently 1200 seconds). Setting max execution time to -1 in the
 script has no effect (which has been noticed previously on the
 php.net manual page).

You mean 0, not -1, right?...

Cuz 0 means forever and -1 probably doesn't mean anything at all,
unless it means 0x seconds, which is on heck of a long time.

You can often use set_time_limit inside your loop with a reasonable
number this is much longer than any single loop execution should take.

This provides you with as much time as you need to finish, without
wiping out ALL the benefits of the original intent of set_time_limit

 Is there any other way (with PHP) to come around this problem besides
 setting the time-out in the Apache config to more than 1200 seconds?

Wait a minute.

Are you talking about a PHP time limit, or an Apache time limit?!

Cuz we can't really help you much with some Apache time limit thingie...

 The Apache manual says that the time out value can only be changed
 within the core configuration scope. My initial idea was to set the
 value in a .htaccess file which unfortunately is not allowed. I might
 also add that the script is already optimized for speed so to say.

Not allowed as in you can't have .htaccess, or not allowed as in
somebody turned off the ability to change PHP's timeout setting?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



[PHP] A problem with passing $_GET in an url (problem solved)

2007-05-04 Thread Davis Chan
Thank you for everyone's help, both public post and private email. I 
solved the problem, part of it is javascript and part of it is the php 
generated form (actually a html problem)


Now my function is:
function Ask_Confirm() 
{

response = confirm(Are you sure?);
if(response == true)
{
document.forms[1].submit();
}
if(response == false)
{
// Do nothing
}
}


and also I had type=submit instead of type=button for the submit 
button. Fixing both solved the problem. Thanks again.


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



Re: [PHP] Drawing all characters using GD

2007-05-04 Thread Seth Price

Ah, thanks, I didn't notice a i18n mailing list. I'll try there.

Maybe if I had a list of font files, I could test each to work with a  
given string, until I find one which works?

~Seth


On May 4, 2007, at 2:54 PM, Richard Lynch wrote:




On Fri, May 4, 2007 9:23 am, Seth Price wrote:

I have enough fonts installed on my machine to draw most of the
world's UTF-8 characters. But they aren't all in one font file. How
can I use the resources I have to reliably draw any character using
imagetttext()?

For example: Most of the text I want to draw is regular ASCII, many
words contain Extended ASCII. Then some of it is Korean, Chinese,
Japanese or Arabic. I don't know when I'll come across what charset.
I want to draw them all. Is this even possible?


I don't think there is any one giant charset you could have that would
slap all the languages together...

The whole point of a charset is to set up correspondences between
numbers and the letter you see.

So every different charset is just a mapping from a number to a
glpyh (the physical representation of the letter, like a series of
pen-strokes, as I understand it)

And presumably the guys making up UTF-8, UTF-16, and UTF-32 didn't
make these numbers up just for fun, and actually have languages that
NEED 32 bits to represent every letter.

I suppose, in theory, you could take every charset, and create a
UTF-40 which used 40 bits, and use the first byte (8 bits) for an
offset and then you could map your super-charset back to normal
charsets, assuming there are no more than 255 languages to support.

I guess if there's more than 255 languages, you're looking at even
more bits/bytes...

Sounds like a lot of work, though...

Maybe ask over on the i18n PHP mailing list, as they're way more
familiar with this stuff than most users here.

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?





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



Re: [PHP] Problem with timeout

2007-05-04 Thread Frank Arensmeier

4 maj 2007 kl. 21.58 skrev Richard Lynch:


On Fri, May 4, 2007 8:37 am, Frank Arensmeier wrote:

I am currently working on a script that parses a given http adress by
looking for anchor tags, background images and so on - a crawler if
you like. The downloaded content is temporarily stored on the server
(Mac OS X Server 10.4.9 with PHP 5) and, when the script is done, the
content is packed into a ZIP archive. It seems that I am having
trouble with my Apache timeout setting. Because the script downloads
between 250 and 300MB of html, pdf, css files and so on, it is
terminated automatically after the specified timeout setting
(currently 1200 seconds). Setting max execution time to -1 in the
script has no effect (which has been noticed previously on the
php.net manual page).


You mean 0, not -1, right?...


Well, yes. I think I mixed up the function set_time_limit with the  
memory_limit option.



Cuz 0 means forever and -1 probably doesn't mean anything at all,
unless it means 0x seconds, which is on heck of a long time.

You can often use set_time_limit inside your loop with a reasonable
number this is much longer than any single loop execution should take.

This provides you with as much time as you need to finish, without
wiping out ALL the benefits of the original intent of set_time_limit


Is there any other way (with PHP) to come around this problem besides
setting the time-out in the Apache config to more than 1200 seconds?


Wait a minute.

Are you talking about a PHP time limit, or an Apache time limit?!


I was talking about the Apache time limit. As you most certainly  
know, the Apache time limit is superior to the maximal execution  
time set inside a PHP script. Therefore, setting the max execution  
time to 0 (no limit) has no effect if the script reaches the Apache  
time limit specified by the TimeOut directive.


Of course, since this is my own server and I have root access, I  
could set the Apache time limit to a higher value. But, as Emmanuel  
already pointed out ... because Apache could easily run low on  
available sockets, causing a DoS. So I do not feel that this is the  
right way to go.


Cuz we can't really help you much with some Apache time limit  
thingie...


I was afraid of that.




The Apache manual says that the time out value can only be changed
within the core configuration scope. My initial idea was to set the
value in a .htaccess file which unfortunately is not allowed. I might
also add that the script is already optimized for speed so to say.


Not allowed as in you can't have .htaccess, or not allowed as in
somebody turned off the ability to change PHP's timeout setting?


With not allowed I ment that you are not able to set the Apache  
directive timeout in a .htaccess file (at least not with Apache  
1.3) since this directive is only legal within the server core  
configuration.


I still think that the best way to go is to not involve Apache at all  
when running the script. Because the script already has functions for  
output logging etc. it is no big deal to change the code so that it  
can be run from PHP CLI.


//frank


--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?


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



[PHP] Getting multitple select values on PHP side

2007-05-04 Thread Skip Evans

Hey all,

I have a requirement for a select on a form that 
has to be able to get multiple values in the form 
processing PHP side.


You just multiple to the select... tag to be 
able to select multiple values, but on the PHP 
side the $_POST value for the form only has the 
last one selected.


Can PHP do this

Thanks,
Skip

--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240
http://bigskypenguin.com
=-=-=-=-=-=-=-=-=-=
Check out PHPenguin, a lightweight and
versatile PHP/MySQL development framework.
http://phpenguin.bigskypenguin.com/

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



Re: [PHP] Selecting a special row from the database

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 8:36 am, Marcelo Wolfgang wrote:
 I'm building a news display page for a website, and since the user has
 2
 ways to arrive there, I want to know if this is possible:

 1) the user arrive at news.php

 I will run a query at the db, and get the latest news to be the main
 one
   (full display) and display the others news in a list

 2) the user arrived from a link to a specific news to news.php?id=10

 It should display the news with id = 10 as the main news and get the
 latest ones to display in a list of other news

 I've so far was able to add a dinamic WHERE to my query ( if I have or
 not the id GET parameter ) and if I don't have it, I'm able to display
 the latest result as the main news, but when I have an id as a GET
 parameter, I have a where clause in my query and it will return only
 the
 main news and not build up the news list

 what I want is to separate the news that the user want to see ( the
 id=XX one ) from the others rows, can someone advice me ?


 Here is the code I have so far, I hope it serve as a better
 explanation
 than mine!

 ?
 $newsId = $_GET['id'];
 if (isset($newsID)){
   $whereClause = 'WHERE auto_id ='.$newsId;

SQL injection attack alert:
You *really* need to sanitize this input.
http://phpsec.org/

 } else {
   $whereClause = '';
 }
 mysql_connect(localhost,$user,$pass) or die (mysql_error());
 mysql_select_db ($db_table);
 $SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id DESC;

Using select * is usually a bad idea anyway, but you can also add:
$newsId = (int) $newsId;
select *, auto_id = $newsId as requested from ...

This then gives PHP a way to tell if this is a story they ASKED FOR by
id, or just a story, as you have an extra filed called 'requested'

This assumes that you never ever have 0 as an ID in the database, as
the (int) typecast will force it to 0 if you don't have a $newsId, but
you almost for sure won't have a 0 for auto_id, as it's an
auto_increment field that starts at 1 and goes up to over 2 billion.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



RE: [PHP] Selecting a special row from the database

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 9:26 am, Edward Kay wrote:
 what I want is to separate the news that the user want to see ( the
 id=XX one ) from the others rows, can someone advice me ?

 Here is the code I have so far, I hope it serve as a better
 explanation
 than mine!

 ?
 $newsId = $_GET['id'];

/*
 if (isset($newsID)){
  $whereClause = 'WHERE auto_id ='.$newsId;
 } else {
  $whereClause = '';
 }
*/


 mysql_connect(localhost,$user,$pass) or die (mysql_error());
 mysql_select_db ($db_table);
 $SQL = SELECT * FROM tb_noticias $whereClause ORDER BY auto_id
 DESC;

Also, forget the where clause and change your ORDER BY to be:

ORDER BY auto_id = $newsId desc, auto_id desc

This will FIRST check the ID to see if it's the one you want from the
one story, then the rest in id descending format.

And you probably should not use auto_id desc but postdate desc or
whatever date field you are using to date the stories...

Technically speaking, you should NOT rely on the fact that mysql will
be adding 1 to each id to get the next one.

That happens to be how it works, and it's really unlikely to change,
but if you ever get to where you have a humongous site and a zillion
news stories in federated databases, you suddenly have this buglet
where your ID is *not* the thing you wanted to sort by.

And, in theory, the MySQL guys could change the implementation of
auto_increment out from under you, tho that's even less likely than
needing a federated db setup... :-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Getting multitple select values on PHP side

2007-05-04 Thread Richard Lynch


On Fri, May 4, 2007 3:56 pm, Skip Evans wrote:
 Hey all,

 I have a requirement for a select on a form that
 has to be able to get multiple values in the form
 processing PHP side.

 You just multiple to the select... tag to be
 able to select multiple values, but on the PHP
 side the $_POST value for the form only has the
 last one selected.

 Can PHP do this

name=foo[]

I think it's time for you to re-read this:
http://php.net/faq.php
(because the answer to this question is in there, so maybe you've got
more you've missed)

:-)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Getting multitple select values on PHP side

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 3:56 pm, Skip Evans wrote:
 I have a requirement for a select on a form that
 has to be able to get multiple values in the form
 processing PHP side.

 You just multiple to the select... tag to be
 able to select multiple values, but on the PHP
 side the $_POST value for the form only has the
 last one selected.

PS
WARNING:
Most surfers have NO IDEA how to work a MULTIPLE select...

You need instructions right next to it, if it's important that they
pick more than one.

If it's only a nifty feature to choose more than one, let the smart
ones revel in their edumacation and the not-so-swift will never
realize what they are missing.


-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Why does this encoding work in PHP?

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 3:24 am, Arno Kuhl wrote:
 I recently came across a script that was oddly encoded. A bit of
 digging
 revealed it was encoded in octal. What puzzles me is why the php
 interpreter
 is able to understand the script.

 An example (not from the original script)

 require_once ../file.php;
 require_once \56\56\57\146\151\154\145\56\160\150\160;

http://us.php.net/manual/en/language.types.string.php

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Custom session save handler. What's happens really?

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 2:26 am, [EMAIL PROTECTED] wrote:
 i'm using in each script:

 ?
 session_set_save_handler(...); //register my custom function to store
 session
 //into a mysql database

 session_start(); //session.auto_start is set to 0 in php.ini
 register_shutdown(session_write_close);

 $object = unserialize($_SESSION['objectname']);
 //modify the object
 //
 $_SESSION['objectname'] = serialize($object);
 ?

 When are exactly called the write and read function of my custom
 handler?
 Is it at the session_start that read function is called?

Probably.

 or is it at $object = unserialize($_SESSION['objectname'])?

Possibly.

Use http://php.net/error_log with a timestamp and find out...

 Is write function called at session_write_close only?

Almost for sure.

 or any time $_SESSION[] is writted?

That would be HORRIBLE performance, so probably NOT.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: Custom session save handler. What's happens really?

2007-05-04 Thread Richard Lynch


On Fri, May 4, 2007 6:37 am, [EMAIL PROTECTED] wrote:
 Thanks, but I serialize and unserialize the objects and this is not my
 problem...(I known best practices for php5 about object
 serialization).

I think they meant you do *NOT* have to serialize/unserialize, as PHP
is gonna do it for you in the guts of session code.

So basically PHP is gonna serialize your serialized data, and then
unserialize it, and then you unserialized that.

It will work, but it's a bit expensive for a large object, I should
think...

Or maybe not, as once you have it as a big long string, how long can
it take PHP to serialize that?  Feh.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] passing GET via include

2007-05-04 Thread Richard Lynch
On Fri, May 4, 2007 2:22 am, Mark Smith wrote:
 Is there a way to allow the passing of variables to included scripts
 using the GET method, for example includefile.php?name=person; or is
 there another method of including files that allow you to do this. I
 have attempted to do this without success, I just get a message saying
 the file cannot be found.

Well, there's sort of a way to do that.

Don't do anything.  :-)

The variable is already there, waiting for you to use it.

You may want to study up on scope however:
http://us.php.net/manual/en/language.variables.scope.php

If you are in a function, you need to pass $name to that function, or
you need to declare it global  Passing it in is almost always
better.

If you just want the original $_GET data, raw and unfiltered, $_GET is
a superglobal and you can juse it anywhere, any time.  (Ditto for
$_POST and all the others)

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Re: A problem with passing $_GET in an url

2007-05-04 Thread Richard Lynch
On Thu, May 3, 2007 8:15 pm, Davis Chan wrote:
 I also have a question about using this newsgroup, why is messages I
 got
 from using Thunderbird not as update as the digest I got via email?

Because PHP's nntp server has fewer gerbils.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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




Re: [PHP] Getting multitple select values on PHP side

2007-05-04 Thread Paul Novitski

At 5/4/2007 01:56 PM, Skip Evans wrote:
I have a requirement for a select on a form that has to be able to 
get multiple values in the form processing PHP side.


You just multiple to the select... tag to be able to select 
multiple values, but on the PHP side the $_POST value for the form 
only has the last one selected.



I believe the common way to accomplish this is to add [] to the form 
element's name, which persuades PHP into treating it like an array:


select name=nation[] ...

Regards,

Paul
__

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


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



Re: [PHP] Drawing all characters using GD

2007-05-04 Thread Crayon
On Saturday 05 May 2007 04:24, Seth Price wrote:

 Maybe if I had a list of font files, I could test each to work with a
 given string, until I find one which works?

You could try looking for a comprehensive iso-10646 font.

-- 
Crayon

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



RE: [PHP] parse error

2007-05-04 Thread Brad Sumrall
Parse error: parse error, unexpected '}' in
/home/content/c/u/t/cuteirka/html/commonlogin_new.php on line 37

Because I am not starting the brackets anywhere else.
My only php function is between line 37 and 39





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 04, 2007 9:43 PM
To: Brad Sumrall
Subject: Re: [PHP] parse error

}else{
Brad Sumrall wrote:
 Hi folk, I am writing a login in script and get the following:

 Parse error: parse error, unexpected T_ELSE in
 /home/content/c/u/t/cuteirka/html/commonlogin_new.php on line 37

 I am basically pulling this straight out the php for dummies manual.

  

 Can someone kindly point me in the right direction on this one!

  

 Brad

  

  

 1  form action=/phpBB/login.php method=post target=_top

 2  table width=200 cellpadding=4 cellspacing=1 border=0
 class=forumline align=center

 3  tr

 4  th background=images/login_top2.jpg
 height=30 class=thHead nowrap=nowrap/th

 5  /tr

 6  tr

 7  td class=row1table border=0
 cellpadding=3 cellspacing=1 width=100%

 8  tr

 9  td width=11% align=rightdiv
 align=leftspan class=genUsername:/span/div/td

 10 /tr

 11 tr

 12 td align=rightinput type=text
 class=post name=username size=25 maxlength=40 value= //td

 13 /tr

 14 tr

 15 td align=rightdiv
align=leftspan
 class=genPassword/span/div/td

 16 /tr

 17 tr

 18 td align=rightspan class=gen

 19 input type=password class=post name=password size=25
 maxlength=32 /

 20 :/span/td

 21 /tr

 22 tr align=center

 23 td colspan=2span class=genLog
me
 on automatically: 

 24 input type=checkbox name=autologin //span/td

 25 /tr

 26 tr align=center

 27 td colspan=2input type=hidden
 name=redirect value= /input type=submit name=login
 class=mainoption value=Log in //td

 28 /tr

 29 tr align=center

 30 td colspan=2span
class=gensmalla
 href=forgot_password.php class=gensmallI forgot my
 password/a/span/td

 31 /tr

 32 /table

 33 /td

 34

 25   /tr

 36 ?php

 37 {else}

 38 ?

 tr

   td width=207 height=32
background=images/login_top2.jpg
 class=headerlogout align=center

 table width=100%

 tr

 td width=30 height=27/td

 td align=lefta
 href=javascript:logout() class=link1Log out/a/td

 /tr

 /table

 /td

 /tr

 tr  

 td align=center
 class=logincenterbg

 table width=88% border=0 cellspacing=0 cellpadding=0

 tr

 td height=10 align=left
 class=bluetext/td

 /tr

 tr

 td align=left class=link2Welcome
:
 ?php echo $_SESSION[userid] ?/td

 /tr

 tr

 td height=22 align=left
 class=bluetext/td

 /tr

  tr

 td height=20 align=lefta
 class=link1 href=editaccount.phpManage Account/a/td

 /tr

 tr

 td height=20 align=lefta
 class=link1 href=editprofile.phpManage Profile/a/td

 /tr

 /table

 /td

 /tr

 tr

 td align=left valign=topimg
 src=images/login_bottom.jpg width=200 height=8 alt= //td

 /tr 

 /table

 /form


   

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



RE: [PHP] parse error

2007-05-04 Thread Brad Sumrall
I dug deeper and realized I needed to open it correctly.

You were right!

Thank you!

Here is the correct code that works like a charm!

Brad

?php
if(!isset($_SESSION[userid]))
{
?
form action=/phpBB/login.php method=post target=_top
table width=200 cellpadding=4 cellspacing=1 border=0
class=forumline align=center
tr
th background=images/login_top2.jpg height=30
class=thHead nowrap=nowrap/th
/tr
tr
td class=row1table border=0 cellpadding=3
cellspacing=1 width=100%
tr
td width=11% align=rightdiv
align=leftspan class=genUsername:/span/div/td
/tr
tr
td align=rightinput type=text class=post
name=username size=25 maxlength=40 value= //td
/tr
tr
td align=rightdiv align=leftspan
class=genPassword/span/div/td
/tr
tr
td align=rightspan class=gen
input type=password class=post name=password size=25 maxlength=32
/
:/span/td
/tr
tr align=center
td colspan=2span class=genLog me on
automatically: 
input type=checkbox name=autologin //span/td
/tr
tr align=center
td colspan=2input type=hidden name=redirect
value= /input type=submit name=login class=mainoption value=Log
in //td
/tr
tr align=center
td colspan=2span class=gensmalla
href=forgot_password.php class=gensmallI forgot my
password/a/span/td
/tr
/table
/td

/tr
?php
}else{
?
tr
  td width=207 height=32 background=images/login_top2.jpg
class=headerlogout align=center
table width=100%
tr
td width=30 height=27/td
td align=lefta href=javascript:logout()
class=link1Log out/a/td
/tr
/table
/td
/tr
tr
td align=center class=logincenterbg
table width=88% border=0 cellspacing=0 cellpadding=0
tr
td height=10 align=left class=bluetext/td
/tr
tr
td align=left class=link2Welcome : ?php echo
$_SESSION[userid] ?/td
/tr
tr
td height=22 align=left class=bluetext/td
/tr
 tr
td height=20 align=lefta class=link1
href=editaccount.phpManage Account/a/td
/tr
tr
td height=20 align=lefta class=link1
href=editprofile.phpManage Profile/a/td
/tr
/table
/td
/tr
tr
td align=left valign=topimg
src=images/login_bottom.jpg width=200 height=8 alt= //td
/tr   
/table
/form
?php
}
?  

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 04, 2007 9:43 PM
To: Brad Sumrall
Subject: Re: [PHP] parse error

}else{
Brad Sumrall wrote:
 Hi folk, I am writing a login in script and get the following:

 Parse error: parse error, unexpected T_ELSE in
 /home/content/c/u/t/cuteirka/html/commonlogin_new.php on line 37

 I am basically pulling this straight out the php for dummies manual.

  

 Can someone kindly point me in the right direction on this one!

  

 Brad

  

  

 1  form action=/phpBB/login.php method=post target=_top

 2  table width=200 cellpadding=4 cellspacing=1 border=0
 class=forumline align=center

 3  tr

 4  th background=images/login_top2.jpg
 height=30 class=thHead nowrap=nowrap/th

 5  /tr

 6  tr

 7  td class=row1table border=0
 cellpadding=3 cellspacing=1 width=100%

 8  tr

 9  td width=11% align=rightdiv
 align=leftspan class=genUsername:/span/div/td

 10 /tr

 11 tr

 12 td align=rightinput type=text
 class=post name=username size=25 maxlength=40 value= //td

 13 /tr

 14 tr

 15 td align=rightdiv
align=leftspan
 class=genPassword/span/div/td

 16 /tr

 17 tr

 18 td align=rightspan class=gen

 19 input type=password class=post name=password size=25
 maxlength=32 /

 20 :/span/td

 21 /tr

 22 tr align=center

 23   

RE: [PHP] parse error

2007-05-04 Thread Brad Sumrall
Maybe not
The following passes me on without error, but does not actually log me on?
Put in a fake name, and it still passes me on to the index page.
I took this straight off the phpbb help files?

Brad


?php
if(!isset($_SESSION[userid]))
{
?
form action=/phpbb/index.php method=post target=_top
?php
}else{
?
?php echo $_SESSION[userid] ?
/form
?php
}
?




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



[PHP] Newbie Question - Form To Email Needed

2007-05-04 Thread revDAVE
 Hi folks, 

I have a form on page one - and would like to submit to a second page in PHP
that could grab the fields and send it out as an e-mail.

Are there any links that show how do this?


Thanks in advance - Dave


--
Thanks - RevDave
[EMAIL PROTECTED]
[db-lists]

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



[PHP] RE: parse error (close this one)

2007-05-04 Thread Brad Sumrall
Du!

It would have made sense to direct it to /phpbb/login.php

Not

/phpbb/index.php

 

I know, the keyboard and the chair!

 

Brad



Re: [PHP] Newbie Question - Form To Email Needed

2007-05-04 Thread revDAVE
On 5/4/2007 7:29 PM, Brad Sumrall [EMAIL PROTECTED] wrote:

 Where are the fields?


Hi Brad,


Just a basic form with a few fields inside like - name - address etc lie:



form action=sendmail.php method=post
input name=name type=text
input name=email type=text
/form

--
Thanks - RevDave
[EMAIL PROTECTED]
[db-lists]

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



[PHP] Why create_element function always return false?

2007-05-04 Thread Victor
?php
$doc = domxml_new_doc(1.0);
$node = $doc-create_element(para);
$newnode = $doc-append_child($node);
$newnode-set_attribute(align, left);
?

I just run the example that is from php manual. But there is some error

--
Warning: domnode::append_child() expects parameter 1 to be object, null
given in C:\AppServ\www\tutorial\test.php on line 4

Fatal error: Call to a member function set_attribute() on a non-object
in C:\AppServ\www\tutorial\test.php on line 5
--


It is very strangeI found that create_element always return
falsenomatter what I dowhat example I tried...
Not only create_element return false but also create_coment do so...
Why???

I run php 5.2.2 with AppServ . The version of docmxl is 20626 (I just
call domxml_version() ). OS is Windows XP.

Would someone help me ,please?
Thanks a lot.

Victor.

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



Re: [PHP] Newbie Question - Form To Email Needed

2007-05-04 Thread revDAVE
On 5/4/2007 7:40 PM, Brad Sumrall [EMAIL PROTECTED] wrote:

 Once again my friend,
 Where are the fields?
 There physical 411?
 Database?
 Incoming email?
 Out going email?
 Flat file?


Hello Brad, 

I apologize if I not being clear enough, - I was thinking that there would
simply be a basic Web-Page (page 1) with EMPTY input fields ( that are not
tied to a data source at all) on a form so that the user could fill it out -
click the submit button - and it could go to a second page (PHP) -  that can
process the incoming fields and send an email to an email address...


PAGE 1: Just a basic web page form with a few fields inside like - name -
address etc:

form action=sendmail.php method=post
input name=name type=text
input name=email type=text
/form


PAGE 2: ... Some kind of PHP sendmail function...

- this is the way I would do it in ColdFusion ( simply going from page 1 to
page 2 that would send an email e-mail (with no database needed))


cfmail 
to=[EMAIL PROTECTED]
from=somebody
server=mail.domain.com
subject=Some mail

Name is: #form.name#
Email is : #form.email#

Thanks, 
US
/cfmail

Q: is there some kind of mail command like this for PHP?



 
 Brad
 
 -Original Message-
 From: revDAVE [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 04, 2007 10:36 PM
 To: php-general@lists.php.net
 Cc: Brad Sumrall
 Subject: Re: [PHP] Newbie Question - Form To Email Needed
 
 On 5/4/2007 7:29 PM, Brad Sumrall [EMAIL PROTECTED] wrote:
 
 Where are the fields?
 
 
 Hi Brad,
 
 
 Just a basic form with a few fields inside like - name - address etc lie:
 
 
 
 form action=sendmail.php method=post
 input name=name type=text
 input name=email type=text
 /form
 
 --
 Thanks - RevDave
 [EMAIL PROTECTED]
 [db-lists]
 
 
 
 
 
 
 


--
Thanks - RevDave
[EMAIL PROTECTED]
[db-lists]

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