RE: [PHP] 'Code Snippets' you couldn't live without

2004-11-04 Thread Murray @ PlanetThoughtful
Another code snippet I use quite regularly builds a form select list from a
delimited string.

function displayFormSelect($selvals, $selname, $val=''){
$optval = explode(,, $selvals);
$retval = select name='$selname';
foreach ($optval as $key = $value){
$retval .= option value='.$value.';
if ($value == $val)
$retval .=  selected;
$retval .= .$value./option;

}
$retval .= /select;
return $retval; 
}

Basically, I use it like so:

$optstring = 'Option 1,Option 2,Option 3';
$optname = 'frmoptions';
$optsel = 'Option 3';

$formsel = displayFormSelect($optstring, $optname, $optse);

echo $formsel;

The optional third value defines the option that appears 'selected' if
provided.

Looking at it, it would be pretty easy to change this to pass a recordset
array to it etc.

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.

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



Re: [PHP] mysql_connect

2004-11-04 Thread Manoj Kr. Sheoran
Hi Ben ,
$connection = mysql_connect$host,$user,$password);
if(!$connection)
echo echo  mysql_error();
  After checking error msg . I can help you
--Mannoj Kr. Sheoran
   - Original Message -
From: Ben Miller [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Thursday, November 04, 2004 11:52 AM
Subject: [PHP] mysql_connect


 I am having trouble connecting to a database on another server.  I have
the
 following for the connection, but it seems to be overriding the value for
 the $host variable, and replacing it with localhost.  Anyone got any
ideas?

 $host=domain.com;
 $user=username;
 $password=password;
 $database=dbname;
 $connection = mysql_connect($host,$user,$password)
 or die (Couldn't connect to server.);
 $db = mysql_select_db($database,$connection)
 or die (Couldn't select database.);

 --
 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] imap-sort()

2004-11-04 Thread Vahid Ghafarpour

imap-sort function doesn't search correctly for unicode strings, is there
any unicode function with this functionality that support locale??

-- 
Vahid Ghafarpour.
[EMAIL PROTECTED]
http://vahid.ghafarpour.com/

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



Re: [PHP] Lost session variables still confounding me

2004-11-04 Thread Richard Davey
Hello Stuart,

Thursday, November 4, 2004, 9:38:44 AM, you wrote:

SF Page 2:
SF $_SESSION['f1a'] = $_POST['ListingName'];

SF Page 3:
SF if (count($myarray)  5) {
SF $_SESSION['arrayerr'] = you have selected too many
SF industries;
SF header (Location: Page2.php);
SF exit;
SF }

SF If the validation above passes, no problem. But if it
SF doesn't, once it redirects, the session variable , f1a
SF is bye bye.

Unless I'm mistaken - you are redirecting back to Page 2 upon an
error, right? Well according to the code posted, the second you hit
Page 2 again, you are over-writing whatever is in the f1a session
variable with the contents of the $_POST var, which naturally will not
exist, hence you'll blank it out every single time.

Best regards,

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

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



[PHP] xslt fucntions

2004-11-04 Thread lists
hi
wondering if anyone can help me with this one... im running php 4.3.9 on 
windows 98. im tryin to get the xslt functions working. i have follwed 
the instructions here:
http://sniptools.com/vault/sablotron-xslt-php-apache-on-windows-and-a-basic-xslt-tutorial.htm
i still am not getting them working. my specific problems is: when i 
start apache i get a pop error:
Unknown(): Unable to load dynamic library './php_xslt.dll' - One of the 
library files needed to run this application cannot be found
ive searched for solutions but havent come up with anything that works.  
anyone have any advice?
thanks
eoghan

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


[PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
Hi.
I have searched a few of the mailing lists, and have not found an answer.
I am working on a site that is currently running gforge ( 
http://gforge.org/ ). The process that is used to download files from the 
file repository is something like:

Header('Content-disposition: filename='.str_replace('', '', $filename).'');
Header(Content-type: application/binary);
$length = filesize($sys_upload_dir.$group_name.'/'.$filename);
Header(Content-length: $length);
readfile($sys_upload_dir.$group_name.'/'.$filename);
The issue is that readfile writes it to the output buffer before sending it 
to the client. When several people try to download large files at the same 
time (The Ant Download Manager - trys downloading things by opening 20 
connections). 20 x a single 250Meg file rips through physical and swap 
pretty fast and crashes my machine.

Any thoughts on how to turn output buffering off? I have tried, but have 
not been able to get it working properly.


On a similar note, is there a portable way to determine available system 
memory (physical and swap)? Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
	$i = strlen($free);
	$free = str_replace('  ',' ',$free);	
}
$free = str_replace(\n,'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==

Calling shell_exec isn't very portable to other systems.
Thanks in advance.
-Robin
 

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


[PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein
I think I've tried just about everything that I found
googling.  Still no luck. I'm throwing this out again,
with the chance that something missed before maybe
noticed.

Page 1:
//Start the Session - begin Block
@session_start();
form method=POST name=form1 action=Page2.php
input name=ListingName type=text id=ListingName
/

Page 2:
//Start the Session - begin Block
@session_start();
//Set the session variable, input on Page 1
$_SESSION['f1a'] = $_POST['ListingName'];


Page 3:
//ON this page, I check that f1a still exist using an
echo - generally it does unless :

//Start the Session - begin Block
@session_start();
if (count($myarray)  5) {
$_SESSION['arrayerr'] = you have selected too many
industries;
header (Location: Page2.php);
exit;
}
If the validation above passes, no problem. But if it
doesn't, once it redirects, the session variable , f1a
is bye bye.

I've tried passing the session_id, session_name, i've
printed out both to make sure they remain the same. 
I' ve done relative and absolute paths.  

Searching for this problem , it seems I'm not the only
one who has suffered with this issue.  Some was prior
php 4.3 when session_write_close was needed.  I've
thrown that in as well.  

I just don't get it.

Stuart

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



RE: [PHP] Lost session variables still confounding me

2004-11-04 Thread Reinhart Viane
Page 1:
//Start the Session - begin Block
@session_start();
form method=POST name=form1 action=Page2.php
input name=ListingName type=text id=ListingName
/

Is it necesarry to start the session here? Maybe it is if they have to
be logged in or something
Normally I only start the session when I indeed can assign some session
variables in the same page

Page 2:
//Start the Session - begin Block
@session_start();
//Set the session variable, input on Page 1
$_SESSION['f1a'] = $_POST['ListingName'];

//Set the session variable, input on Page 1
session_register('f1a');
$_SESSION['f1a'] = $_POST['ListingName'];


Page 3:
//ON this page, I check that f1a still exist using an
echo - generally it does unless :

//Start the Session - begin Block
@session_start();
if (count($myarray)  5) {
$_SESSION['arrayerr'] = you have selected too many industries;
header (Location: Page2.php); exit; } If the validation above passes,
no problem. But if it doesn't, once it redirects, the session variable
, f1a is bye bye.


Why do you put the error message in a session variable?
Also you will get an error (header already sent) I suppose since you
first send some text and then do a header.
Also if you rederict to page2.php, at the beginning of that page you set
$_SESSION('f1a')= $_POST['ListingName'];
Since there are no POST values (you are coming from page3)
$_SESSION('f1a') will get an empty value...
Maybe this causes the loss...

I dunno if this will help, I'm not that good at php.

Greetings,
Reinhart

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



Re: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Unless I'm mistaken - you are redirecting back to
 Page 2 upon an
 error, right? Well according to the code posted, the
 second you hit
 Page 2 again, you are over-writing whatever is in
 the f1a session
 variable with the contents of the $_POST var, which
 naturally will not
 exist, hence you'll blank it out every single time.
 
Your not mistaken.  That is what's happening.  I just
don't know how to fix it .

Stuart

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



Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Richard Davey
Hello Stuart,

Thursday, November 4, 2004, 10:02:53 AM, you wrote:

SF Your not mistaken. That is what's happening. I just don't know how
SF to fix it .

Before setting the session value in Page 2, check for the existence of
the $_POST value first.

if (isset($_POST['var']))
{
   $_SESSION['var'] = $_POST['var'];
}

When you now redirect to Page 2 upon an error, it'll skip this block
because the $_POST var won't exist.

Best regards,

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

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



RE: [PHP] Lost session variables still confounding me

2004-11-04 Thread Reinhart Viane
Why not, on page 2:

//Set the session variable, input on Page 1
If ($_POST['ListingName']) {
$_SESSION['f1a'] = $_POST['ListingName'];
}

If there is a POST value, it will be used, else $_SESSION['f1a'] will
keep it's value.

-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: donderdag 4 november 2004 11:03
To: Richard Davey; [EMAIL PROTECTED]
Subject: Re: [PHP] Lost session variables still confounding me



--- Richard Davey [EMAIL PROTECTED] wrote:

 Unless I'm mistaken - you are redirecting back to
 Page 2 upon an
 error, right? Well according to the code posted, the
 second you hit
 Page 2 again, you are over-writing whatever is in
 the f1a session
 variable with the contents of the $_POST var, which
 naturally will not
 exist, hence you'll blank it out every single time.
 
Your not mistaken.  That is what's happening.  I just
don't know how to fix it .

Stuart

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

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



RE: [PHP] Lost session variables still confounding me

2004-11-04 Thread Reinhart Viane
Also, it seems my messages are posted slower then the ones of Richard...
So I have given the same answer as he did for the second time. My
apoligizes.

Greetings,
Reinhart

-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: donderdag 4 november 2004 11:03
To: Richard Davey; [EMAIL PROTECTED]
Subject: Re: [PHP] Lost session variables still confounding me



--- Richard Davey [EMAIL PROTECTED] wrote:

 Unless I'm mistaken - you are redirecting back to
 Page 2 upon an
 error, right? Well according to the code posted, the
 second you hit
 Page 2 again, you are over-writing whatever is in
 the f1a session
 variable with the contents of the $_POST var, which
 naturally will not
 exist, hence you'll blank it out every single time.
 
Your not mistaken.  That is what's happening.  I just
don't know how to fix it .

Stuart

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

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



Re: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Before setting the session value in Page 2, check
 for the existence of
 the $_POST value first.
 
 if (isset($_POST['var']))
 {
$_SESSION['var'] = $_POST['var'];
 }
 
 When you now redirect to Page 2 upon an error, it'll
 skip this block
 because the $_POST var won't exist.
 

I'm a bit confused, this fixes the problem ? 

Stuart

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



Re: [PHP] Pagination need help1)

2004-11-04 Thread Sebastiano Cascione
Use 2 queries.

1) SELECT * FROM cars WHERE ... ORDER BY... ;
1) SELECT * FROM cars WHERE ... ORDER BY... LIMIT $record_x_page OFFSET 
$page;

With the firsth query print pages numbers at the bottom of the html 
page.
With the second one print the records list.
Every time you click on the page number printed at the bottom you have to pass 
the searchterms (by get with urlencode()) to the 2 queries and the $page 
parameter.

Sebastiano



Alle 05:22, giovedì 4 novembre 2004, Scott McWhite ha scritto:
 Hi,



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



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



 Here is some of the code:

 $searchterm=$_POST['searchterm'];

 $searchterm1=$_POST['searchterm1'];

 $searchterm2=$_POST['searchterm2'];



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



 Thank you.

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



Re: [PHP] Pagination need help

2004-11-04 Thread Mike
on 11/3/04 11:22 PM, Scott McWhite at [EMAIL PROTECTED] wrote:

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

Scott,

I followed this tutorial and it helped me accomplish what you are trying to
do.

http://www.phpfreaks.com/tutorials/43/0.php

Good luck.





++
Mike Yrabedra 
[EMAIL PROTECTED] 
Your Mac Intelligence Resource
++
W: http://www.macagent.com/
E: [EMAIL PROTECTED]

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Reinhart Viane [EMAIL PROTECTED] wrote:

 Suppose Richard means:
 
 If (isset($_POST['ListingName'])) {
 $_SESSION['f1a'] = $_POST['ListingName'];
 }


Right, I've tried all three variations , none of
which, I'm sorry to report, have helped.

The variable is alive with any of the code including
the one I had originally.  It seems to do a reset
though when it's redirected.  I've even tried:

Page3:

if (count($LurkerIndustry)  5) {
$_SESSION['arrayerr'] = you have selected too many
industries;
$_SESSION['f1a'] = $_POST['ListingName'];
header (Location: TestMulti2.php);
exit;
}

Thinking that by sending the variable back to page 2
it would hold. The error variable takes.

Stuart

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



Re[4]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Richard Davey
Hello Stuart,

Thursday, November 4, 2004, 10:20:04 AM, you wrote:

 if (isset($_POST['var']))
 {
$_SESSION['var'] = $_POST['var'];
 }
 
 When you now redirect to Page 2 upon an error, it'll
 skip this block
 because the $_POST var won't exist.

SF I'm a bit confused, this fixes the problem ? 

If the problem is the session value always being reset, then yes, it
will.

Best regards,

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

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



Re[4]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Richard Davey
Hello Stuart,

Thursday, November 4, 2004, 10:55:42 AM, you wrote:

SF The variable is alive with any of the code including the one I had
SF originally. It seems to do a reset though when it's redirected.

SF $_SESSION['f1a'] = $_POST['ListingName'];

This won't have any effect if you don't actually post the form to Page
3, again it's just resetting the session f1a value to null.

Try sticking this on Page 2 (ensure you have a session_start() at the
top of the page and that you replace the 'var' text below with the
correct ones.

if (isset($_POST['var']))
{
   echo 'POST value found, setting the session var now';
   $_SESSION['var'] = $_POST['var'];
}
else
{
echo 'No POST value found, dumping session contents';
print_r($_SESSION);
}

Run it - make it error - what does it end up saying?

Best regards,

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

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



RE: Re[2]: [PHP] Lost session variables still confounding me

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



On 04 November 2004 10:20, Stuart Felenstein wrote:

 --- Richard Davey [EMAIL PROTECTED] wrote:
 
  Before setting the session value in Page 2, check
  for the existence of
  the $_POST value first.
  
  if (isset($_POST['var']))
  {
 $_SESSION['var'] = $_POST['var'];
  }
  
  When you now redirect to Page 2 upon an error, it'll skip this block
  because the $_POST var won't exist.
  
 
 I'm a bit confused, this fixes the problem ?

Of course it does

Well, it's *a* possible fix -- depends on whether it meets your exact
requirements.

Just follow the data flow to see what's going on:

Page 1:

  the value inserted by the user into form field ListingName is sent, when
the Submit button is clicked, to...

Page 2:

  here you copy the value set by the user, and presented to you script in
$_POST['ListingName'], into $_SESSION['f1a']

Page 3:

  if your validity test fails (count($myarray)5), then you redirect back
to...

Page 2:

  here, once again, you attempt to copy $_POST['ListingValue'] into
$_SESSION['f1a'] -- but, because, this time, you haven't got here from the
form, $_POST will be *empty*, and so $_POST['ListingName'] will equate to
NULL (and this access will probably generate a NOTICE, which you would see
if you had full error_reporting turned on), so NULL gets assigned into
$_SESSION['f1a'], and hey presto! it's gone.  (Incidentally, this access to
an undefined index of $_POST will probably generate a NOTICE, which you
would see if you had full error_reporting turned on.)

By testing $_POST['ListingName'] to see if it's isset(), you won't attempt
to assign the bogus NULL into $_SESSION['f1a'], and your problem goes away.

The only fly in the ointment with this is if your form can be submitted in
such a way that $_POST['ListingName'] can legitimately be !isset().  My
personal preference here is to set a flag in the session to say your
redirecting backwards on error, and then test it before attempting to grab
$_POST values (and clear it!).  I'd also be very defensive about coding the
redirect, and always include a session_write_close() and the SID -- probably
in the majority of cases they're not necessary, but at least the code won't
fall over if it's ever used somewhere where they are needed.  So I'd have
something like:

Page 2:

   if (isset($_SESSION['_error_flag']):
  unset $_SESSION['_error_flag'];
  // if subsequent logic needs it, I might set a local error flag here
  // other error actions
   else:
  // ok, should be processing a form submission
  $_SESSION['f1a'] = $_POST['ListingName'];
  // etc...
   endif;

Page 3:

   if (count($myarray)  5):
  $_SESSION['arrayerr'] = you have selected too many industries;
  session_write_close();
  header (Location: Page2.php?.SID);
  exit;
   endif;

Hope this helps.

Cheers!

Mike

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

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Reinhart Viane [EMAIL PROTECTED] wrote:

 So, if I understand correct, even with the isset
 code on the second page
 $_SESSION['f1a'] is set to empty?
 That's strange.
 Still I wonder why you are inputting the error
 messages and the redirect
 in a session variable.
 
Yes, the isset is not working.  It probably isn't
necessary anyone since I've got a validate / required
field set.

I'm not sending the redirect in a session variable. 
Only the error message.  That is the way I know how to
do it.  

Stuart

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



RE: Re[2]: [PHP] Lost session variables still confounding me

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



On 04 November 2004 10:56, Stuart Felenstein wrote:

 --- Reinhart Viane [EMAIL PROTECTED] wrote:
 
  Suppose Richard means:
  
  If (isset($_POST['ListingName'])) {
  $_SESSION['f1a'] = $_POST['ListingName'];
  }
 
 
 Right, I've tried all three variations , none of
 which, I'm sorry to report, have helped.
 
 The variable is alive with any of the code including
 the one I had originally.  It seems to do a reset
 though when it's redirected.  I've even tried:
 
 Page3:
 
 if (count($LurkerIndustry)  5) {
 $_SESSION['arrayerr'] = you have selected too many industries;
 $_SESSION['f1a'] = $_POST['ListingName'];
 header (Location: TestMulti2.php);
 exit;
 }

Well, that's even worse -- because page3 can *never* be reached as the
result of submitting a form, its $_POST[] will *always* be empty -- so this
assignment is also bound to set $_SESSION['f1a'] to NULL.

You seem to have a very hazy view of the flow of your data from one script
to the next.  I really do recommend sitting down with a printout of your
code and a balnk sheet of paper and a pen, and manually working through as
if you were the PHP processor, and recording all the data flows and setting
and unsetting of variables.  It can be a real eye-opener about where values
are going and being used, and can really help solidify your understanding of
the data flow both within scripts and from one script to the next.  Many's
the time I've had a lightbulb moment as I've recorded values flowing into a
place I'd have sworn they couldn't get (or not into a place they should!).
It's tedious and long-winded, but the reward can absolutely be worth it.

Cheers!

Mike

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

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



RE: [PHP] 'Code Snippets' you couldn't live without

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



On 03 November 2004 19:40, Pablo Gosse wrote:

 [snip]Klaus Reimer wrote:
  Murray @ PlanetThoughtful wrote:
   function asl($val){
   function mfr($rset){
  
  This may be ok for private projects but otherwise I don't think
  it's a good idea to create shorthand functions. Other developers
  (and especially new developers beginning to work on the project) are
  getting confused. They must first learn what this functions are
  doing. The names of these functions are not really helpful in
  understanding what's going on.[/snip]
 
 I'm with Klaus on this one.

Me too (tm)!  This is a job for a good editor, with automatic name
completion or abbreviation expansion.  This gives you the convenience of
shortcuts when coding, together with the full standard names when reading
the source code at a later date!

Cheers!

Mike

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

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:

  Page3:
  
  if (count($LurkerIndustry)  5) {
  $_SESSION['arrayerr'] = you have selected too
 many industries;
  $_SESSION['f1a'] = $_POST['ListingName'];
  header (Location: TestMulti2.php);
  exit;
  }
 
 Well, that's even worse -- because page3 can *never*
 be reached as the
 result of submitting a form, its $_POST[] will
 *always* be empty -- so this
 assignment is also bound to set $_SESSION['f1a'] to
 NULL.
 
Mike, I'll heed your advice, since you haven't let me
down before :).  But the variable lasts , I echo it on
every page, including page6 where it's transacted into
the database.  I'm not sure why you say that

Stuart

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



Re: [PHP] RE: [PHP-WIN] Cannot load the mysql library

2004-11-04 Thread zerof
Jordi Canals wrote:
Hi,
On Thu, 4 Nov 2004 01:12:40 +1000, Murray @ PlanetThoughtful
[EMAIL PROTECTED] wrote:
When I open the page, I receive the message: PHP Startup: Unable to load
dynamic library './ext/php/_mysql.dll'  Can't find the specified module.
I
don't know if this is the exact message, because the original is in
Portuguese: ()  No foi possvel encontrar o mdulo especificado.
It's probably a little obvious, but just to make sure: did you restart IIS
after copying the dll and uncommenting the line in the ini file?
Looks like you have bad info in the PHP.INI file ... as the message
normally will be:
Unable to load dymaic library c:\php\ext\php_mysql.dll.
Check for this entries in your PHP.INI, I write the correct values
(Suposing you've installed php in c:\php ...
extension_dir = c:\php\ext\
extension=php_mysql.dll
Hope this helps,
Regards,
Jordi.

D uma olhada em: http://www.educar.pro.br/
Provavelmente, voce encontrar a soluo.
Caso precise de ajuda  s pedir que lhe forneo graciosamente.
-
zerof
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: Re[4]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Richard Davey [EMAIL PROTECTED] wrote:

 Try sticking this on Page 2 (ensure you have a
 session_start() at the
 top of the page and that you replace the 'var' text
 below with the
 correct ones.
 
 if (isset($_POST['var']))
 {
echo 'POST value found, setting the session var
 now';
$_SESSION['var'] = $_POST['var'];
 }
 else
 {
 echo 'No POST value found, dumping session
 contents';
 print_r($_SESSION);
 }
 
 Run it - make it error - what does it end up saying?
 

Before the redirect:

POST value found, setting the session var now


After the redirect: 

No POST value found, dumping session contentsArray (
[xx_user_xxx] = username [xx_id_xxx] = 47
[xx_level_xxx] = BasicUser [f1a] = [WAVT_TestMulti2]
= [f1b] = [f1c] = [f1d] = [f1e] = [f1g] =
[inder] = you have selected too many industries )

Stuart

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



RE: Re[2]: [PHP] Lost session variables still confounding me

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



On 04 November 2004 11:37, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
   Page3:
   
   if (count($LurkerIndustry)  5) {
   $_SESSION['arrayerr'] = you have selected too many industries;
   $_SESSION['f1a'] = $_POST['ListingName'];
   header (Location: TestMulti2.php);
   exit;
   }
  
  Well, that's even worse -- because page3 can *never* be reached as
  the result of submitting a form, its $_POST[] will
  *always* be empty -- so this
  assignment is also bound to set $_SESSION['f1a'] to NULL.
  
 Mike, I'll heed your advice, since you haven't let me
 down before :).  But the variable lasts , I echo it on
 every page, including page6 where it's transacted into
 the database.  I'm not sure why you say that

Well, I would expect it to persist in your success route, since you're not
doing any destructive assignments.  However, I'm talking about your failure
route here, and with this extra assignment in place, every time that test
fails you are 100% guaranteed to destroy the value of $_SESSION['f1a']
before redirecting.

Cheers!

Mike

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

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



RE: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Ford, Mike [EMAIL PROTECTED] wrote:
 Page 3:
 
if (count($myarray)  5):
   $_SESSION['arrayerr'] = you have selected too
 many industries;
   session_write_close();
   header (Location: Page2.php?.SID);
   exit;
endif;
 
 Hope this helps.

Mike, once again you've come through.  This worked!
But , let me ask, can it have anything to do with the
endif ? I asked becasue I tried the
session_write_close and the SID before with no
success.  Now that it's working , the only thing
different is the endif; .

Stuart

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Klaus Reimer
Robin Getz wrote:
The issue is that readfile writes it to the output buffer before sending 
it to the client. 
Are you sure you HAVE output buffering? What does ob_get_level() return? 
If it returns 0 then you don't have output buffering.

My theory (and it's only a theory) is, that readfile may not be the 
optimal function for this task. Maybe it's implemented to read the whole 
file into memory and then output the data, don't know.

If this theory is true, you may try fpassthru(). The name of this 
function sounds like the file is just passed through which sounds like 
the task you want to perform :-)

The example on php.net of this function is exactly matching your task:
?php
// open the file in a binary mode
$name = .\public\dev\img\ok.png;
$fp = fopen($name, 'rb');
// send the right headers
header(Content-Type: image/png);
header(Content-Length:  . filesize($name));
// dump the picture and stop the script
fpassthru($fp);
exit;
?
--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Jason Wong
On Thursday 04 November 2004 12:08, Stuart Felenstein wrote:
 --- Ford, Mike [EMAIL PROTECTED] wrote:
  Page 3:
 
 if (count($myarray)  5):
$_SESSION['arrayerr'] = you have selected too
  many industries;
session_write_close();
header (Location: Page2.php?.SID);
exit;
 endif;
 
  Hope this helps.

 Mike, once again you've come through.  This worked!
 But , let me ask, can it have anything to do with the
 endif ? I asked becasue I tried the
 session_write_close and the SID before with no
 success.  Now that it's working , the only thing
 different is the endif; .

Are you saying that before you did not have the line endif;? AFAICS that 
would result in a parse error. Maybe what you had before was:

if (count($myarray)  5)
   $_SESSION['arrayerr'] = you have selected too many industries;
   session_write_close();
   header (Location: Page2.php?.SID);
   exit;

And yes that has a totally different behaviour to the code with the endif; 
construct.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Consultation, n.:
 Medical term meaning to share the wealth.
*/

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



RE: Re[2]: [PHP] Lost session variables still confounding me

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



On 04 November 2004 12:08, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
  Page 3:
  
 if (count($myarray)  5):
$_SESSION['arrayerr'] = you have selected too many industries;
session_write_close();
header (Location: Page2.php?.SID);
exit;
 endif;
  
  Hope this helps.
 
 Mike, once again you've come through.  This worked!
 But , let me ask, can it have anything to do with the
 endif ? I asked becasue I tried the
 session_write_close and the SID before with no
 success.  Now that it's working , the only thing
 different is the endif; .

Doubt it -- that's just me using PHP's alternative syntax for control
structures; in fact, if the rest of your script uses {} control-structure
delimiters, you should really use them in the above instead of : and endif,
since it's strongly advised not to mix the two forms.  I just much prefer
the :-endif form and sometimes write it without thinking when it might be
more appropriate to use the {} form.


Cheers!

Mike

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

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



RE: [PHP] 'Code Snippets' you couldn't live without

2004-11-04 Thread Murray @ PlanetThoughtful
 Me too (tm)!  This is a job for a good editor, with automatic name
 completion or abbreviation expansion.  This gives you the convenience of
 shortcuts when coding, together with the full standard names when reading
 the source code at a later date!

I think we've missed the point of my original question. Not that a
discussion of good coding principles isn't welcome, but at the same time,
there can be valid (if subjective) reasons for using shorthand functions in
the way I mentioned in my original post.

My valid reason is that I have RSI. To help alleviate that, I have a small
handful of functions I commonly use many times over defined in a way that
means less keystrokes. Across the scope of a project, that can mean
significantly less typing, and marginally less discomfort. My hands thank me
every time I use these shorthand functions.

That having been said, and purist principles aside for the moment, I doubt
there's an intermediate to advanced coder on this list who isn't comfortable
with exploring include files to find out what a function does or how a class
operates. I doubt half-a-dozen shorthand functions in that include file
would place a measurable strain on the readability or maintainability of a
project. 

Yes, I'm sure we can all generate extreme examples of code rendered utterly
turgid and obscure by random and wholesale shorthand transformation. But
let's be honest, you can make any suggestion or process seem ridiculous by
rendering it in the extreme.

The core PHP language is not without it's own shorthand approaches. Witness
the ternary operator. At a glance, it's probably not obvious what it's doing
when first viewed by someone new to PHP. Also witness the deprecation of
variables such as $HTTP_GET_VARS in favour of $_GET etc. Or the .=
concatenation assignment operator as a shorthand to $var = $var . ' added
string.' Or the echo shorthand of ?=$var?.

My point being, the most purist coder is almost certainly using shorthand
methods built into the language. To suggest that these shorthand methods
should never be extended, when approached sensibly and for good reasons,
seems not only regressive, but also somewhat blind to the reality of the
language itself.

Of course, I realize this is a difficult position to defend. I understand
that, in theory, using shorthand functions in this way is 'wrong.' But,
after all, life is about compromise. Sometimes we get to choose the
compromises we make, sometimes we don't. More power to those who struggle
against compromise in this issue. You are a beacon of sanity and reason to
us all.

Back to the intent rather than the form of my original question: what are
the code snippets you can't live without?

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.

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



Re: Re[2]: [PHP] Lost session variables still confounding me

2004-11-04 Thread Stuart Felenstein

--- Jason Wong [EMAIL PROTECTED] wrote:

 Maybe what you had before was:
 
 if (count($myarray)  5)
$_SESSION['arrayerr'] = you have selected
 too many industries;
session_write_close();
header (Location: Page2.php?.SID);
exit;
 
 And yes that has a totally different behaviour to
 the code with the endif; 
 construct.
 
Yep, that is what I had.  So, no parse error, but did
not work  right either.

Stuart

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



[PHP] what am i doing wrong..??

2004-11-04 Thread Aalee
Hi there please have a look the code below...I dont know wht am doing wrong
here...
This code is suppose to show the number of jokes in a mysql database and
allows user to add a joke when the user clicks addjoke link. And when the
joke is added, it suppose to say that Joke inserted, Thank you and list
all the jokes below this line. So far am able to view all the jokes and take
the user to add joke page. But the problem is when the user clicks insert
joke button, it does not display the message Joke inserted, Thank you and
the jokes are not listed. Infact it does not give any error aswell, it just
stays on the add joke form page. I checked the database and no joke is
added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache
1.3.31. MySQL ver 4.0.20a on winXP pro SP1.
Recently i started using registre_globals OFF and all these probs strted
coming up. This code was working fine with globals ON. But my hosting has it
off. So need to do so. I was able to fix all the other issues came coz of
this global thing in this code. But stuck on the issue i just mentioned. Any
help would be GREATLY appreciated.

?php
if (isset($_GET['addjoke'])){
?
form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form


?php
 }
else { // start main else statement
if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,test) ;
 mysql_select_db(jokes,$db);
 $query = mysql_query(INSERT INTO jokes SET
 JokeText = '.$_POST['jokeText'].' ,
 JokeDate = CURDATE() );
 echo  Joke inserted, Thank you BRBR;
 echo mysql_error();
}
$color1 = #66CCFF;
$color2 = #66CC99;
$row_count = 1;

// -- Following lines list the jokes in the
database 
echo bH3 These are the jokes we have got so far/H3/B;
$db = mysql_connect(localhost,homesite,test)  or die(mysql_error());
mysql_select_db(jokes,$db);
$sql = SELECT id, JokeText, JokeDate from jokes;
$query = mysql_query($sql);
echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
echo /table;

$current_url = $_SERVER['PHP_SELF'];
echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);


} // end main else statement
?

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



Re: [PHP] what am i doing wrong..??

2004-11-04 Thread bbonkosk
Echo out your queries!
$query = insert into joke values('',.$_POST['joke_text'].,'date');
--- echo $query;
$result= mysql_query($query);

This will tell you what is going on, perhaps some of the information is not set?  You 
can even copy and paste the output to run against your mysql backend on the command 
line to see if additional information/errors are present.

-B

- Original Message -
From: Aalee [EMAIL PROTECTED]
Date: Thursday, November 4, 2004 7:54 am
Subject: [PHP] what am i doing wrong..??

 Hi there please have a look the code below...I dont know wht am 
 doing wrong
 here...
 This code is suppose to show the number of jokes in a mysql 
 database and
 allows user to add a joke when the user clicks addjoke link. And 
 when the
 joke is added, it suppose to say that Joke inserted, Thank you 
 and list
 all the jokes below this line. So far am able to view all the 
 jokes and take
 the user to add joke page. But the problem is when the user clicks 
 insertjoke button, it does not display the message Joke inserted, 
 Thank you and
 the jokes are not listed. Infact it does not give any error 
 aswell, it just
 stays on the add joke form page. I checked the database and no 
 joke is
 added. Working on PHP ver 4.3.8 with register_globals turned OFF 
 and Apache
 1.3.31. MySQL ver 4.0.20a on winXP pro SP1.
 Recently i started using registre_globals OFF and all these probs 
 strtedcoming up. This code was working fine with globals ON. But 
 my hosting has it
 off. So need to do so. I was able to fix all the other issues came 
 coz of
 this global thing in this code. But stuck on the issue i just 
 mentioned. Any
 help would be GREATLY appreciated.
 
 ?php
 if (isset($_GET['addjoke'])){
 ?
 form name=form1 method=post action=?php 
 $_SERVER['PHP_SELF'] ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
 /form
 
 
 ?php
 }
 else { // start main else statement
 if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,test) ;
 mysql_select_db(jokes,$db);
 $query = mysql_query(INSERT INTO jokes SET
 JokeText = '.$_POST['jokeText'].' ,
 JokeDate = CURDATE() );
 echo  Joke inserted, Thank you BRBR;
 echo mysql_error();
 }
 $color1 = #66CCFF;
 $color2 = #66CC99;
 $row_count = 1;
 
 // -- Following lines list the jokes in the
 database 
 echo bH3 These are the jokes we have got so far/H3/B;
 $db = mysql_connect(localhost,homesite,test)  or 
 die(mysql_error());mysql_select_db(jokes,$db);
 $sql = SELECT id, JokeText, JokeDate from jokes;
 $query = mysql_query($sql);
 echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
 while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
 echo /table;
 
 $current_url = $_SERVER['PHP_SELF'];
 echo(P .Add a Joke!/P);
 
 
 } // end main else statement
 ?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



[PHP] how to create pdf file.

2004-11-04 Thread Roman Duriancik
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows 
(it dependence by mysql export) in php code.
How can i do it ?
Thank you

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


RE: [PHP] how to create pdf file.

2004-11-04 Thread Jay Blanchard
[snip]
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows

(it dependence by mysql export) in php code.
How can i do it ?
[/snip]

http://www.php.net/pdf
http://www.fpdf.org

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



Re: [PHP] how to create pdf file.

2004-11-04 Thread John Nichel
Roman Duriancik wrote:
Please help me with this problem.
I need create pdf file who contains table with 4-5 columns and many rows 
(it dependence by mysql export) in php code.
How can i do it ?
Thank you

roman
You can either read the manual, or pay one of us to write it for you.
http://us4.php.net/pdf
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Shorthand functions (was: Code Snippets' you couldn't live without)

2004-11-04 Thread Klaus Reimer
Murray @ PlanetThoughtful wrote:
with exploring include files to find out what a function does or how a class
operates. I doubt half-a-dozen shorthand functions in that include file
would place a measurable strain on the readability or maintainability of a
project. 
I disagree on that. The problem here is not that the functions are 
short. The problem is, that their names gives absolutely no clue about 
what they are doing. mfr() can be mysql_free_result() but it also can be 
mysql_fetch_row(). So it's not only unreadable, it's also error-prone. 
Sure, it's possible to look up what this function is doing. But is it 
necessary? Everybody (even coders not knowing the mysql functions) can 
understand what mysql_free_result() is doing, without decyphering it 
first.

But I agree that many PHP functions are named too long. But this is 
because they are non-OO functions living without namespaces. So if you 
don't use OO (where you may write something short like $res-free() you 
have to live with that, I fear. Or write shorthand functions, nobody can 
keep you from doing so. I just said, that it is problematic for more 
professional projects where new programmers may begin to work on at any 
time).

And I agree that there are even some very short function names in PHP 
like nl2br(). This looks like a bad naming, but it is not really. nl 
is a well known shorthand for newline. 2 makes clear that it converts 
something. And br is named after the HTML-Tag. So this function name 
GIVES some clues about what it is doing. But for newcomers it may not be 
clear at the beginning what this function is doing. But after a quick 
lookup the newcomer can remember the meaning very well. And I think this 
is different with functions like mfr() and asl() which gives no clue 
about their meaning.


when first viewed by someone new to PHP. Also witness the deprecation of
variables such as $HTTP_GET_VARS in favour of $_GET etc. 
$_GET and $_POST are well named. It's clear what they are doing. Thank 
god their were not named $_HGV and $_HPV.


Or the .=
concatenation assignment operator as a shorthand to $var = $var . ' added
string.' 
$a .= $b is not a shorthand of $a = $a . $b. The result is the same 
but the internal processing is totally different. $a .= $b is a lot 
faster then $a = $a . $b because $b is directly appended to $a. The 
second form constructs a completely new string and overwrites the old 
value of $a. At least this is the case if no optimizer is used. Maybe 
optimizeres are transforming the second form into the first form, don't 
know.

So you can't compare this to a shorthand function. It was not introduced 
because coders are to lazy to write the long form. It was introduced 
because it is absolutely intuitive to do so if the language already has 
something like +=. But I can't tell if these operators were introduced 
into the C programming language (or wherever it appeared first) because 
lazy coders. ;-)


Back to the intent rather than the form of my original question: what are
the code snippets you can't live without?
I already posted some. But this thread is interesting, too. So I changed 
the subject ;-)

--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


[PHP] Sessions and threading

2004-11-04 Thread Devraj Mukherjee
Hi everyone,
I am attempting to write an implementation of Prevayler 
(http://sourceforge,net/projects/prevayler), which has originally been 
written for Java and provides a prevalance layer for storing objects 
using incremental log files and taking snapshots of in fixed time intervals.

It seems the Java guys are widely using the implementation even for web 
applications. There are many advantages to using the system, backups and 
restores are very easy and reliable and it is very efficient for small 
sized projects, as the Prevayler guys claim about 9000 times faster than 
Oracle ;-)

I have near worked out everything that has to be done, I think I am 
going to try and write it as a PEAR module for it to be available to 
everyone. I am stuck with a few concepts and I thought I might float the 
ideas here to get some feedback before I start scripting.

The first part of the problem is that I need to be able to at all times 
maintain a readable set of objects in memory, I am planning to achieve 
that using session variables, but I hear that session variables can 
become very inefficient, how true is that?

The other issue is running a thread that enable in some time interval to 
write snapshots from the log files that are being generated. Is it 
possible to have part of the script alive in some sort of a thread even 
after the script is dead. For example with the use of the sesssion variable.

Any feedback is very welcome.
Kind regards,
Devraj
--
--
Devraj Mukherjee, Eternity Technologies Pty. Ltd. Australia
Host: Debian (Sarge) 3.1 Kernel 2.4.27-1-686 / GCC version 3.3.5
Target: LPD7A400 (ARM9) LogicPD eval. board / ARM GCC 3.3 GlibC 2.3.2
LAMP environment specs. Apache: 2.0.52 PHP: 5 MySQL: 4.0.21
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Sessions and threading

2004-11-04 Thread Greg Donald
On Fri, 05 Nov 2004 00:26:24 +1100, Devraj Mukherjee
[EMAIL PROTECTED] wrote:
 The first part of the problem is that I need to be able to at all times
 maintain a readable set of objects in memory, I am planning to achieve
 that using session variables, but I hear that session variables can
 become very inefficient, how true is that?

If you store huge variable names then it will be slower than if you
store small ones.  Same with the session variable values.

PHP sessions variables are stored as a semi-colon delimited string of
text, with other appropriate seperation characters and descriptions of
the variables included.  I minimize my session variable names to a
single character and document them somewhere for future reference.  I
make sure and store minimum values for each variable, for example the
integer 1 instead of the string 'true' or 'yes', things like that add
up.  Sessions are as efficient as you make them.

Also, PHP doesn't have threads.  You can use some of the execution
functions to simulate them to some extent however: 
http://www.php.net/manual/en/ref.exec.php


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

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



Re: [PHP] Sessions and threading

2004-11-04 Thread Klaus Reimer
Devraj Mukherjee wrote:
The first part of the problem is that I need to be able to at all times 
maintain a readable set of objects in memory, I am planning to achieve 
that using session variables, but I hear that session variables can 
become very inefficient, how true is that?
Very true. In Java (with Tomcat for example) you have a real session 
scope and application scope where you can put objects and directly 
access them. These objects are hold in memory and they are REAL objects 
between the requests. In PHP it's different. If a HTTP request is 
finished then the session (with all data including objects) is 
serialized and stored on the harddisk (or database or whatever the 
session backend is). On the next HTTP request the session is loaded from 
harddisk and unserialized. So new objects are created and filled with 
data from the harddisk at every request.

It would be REALLY REALLY cool to have an application-server-like thingy 
in PHP. But as far as I know there is none. Correct me if I'm wrong.


The other issue is running a thread that enable in some time interval to 
write snapshots from the log files that are being generated. Is it 
possible to have part of the script alive in some sort of a thread even 
after the script is dead. For example with the use of the sesssion 
variable.
You can write a command line PHP script and run it as a separate daemon 
or call it from the crontab.

--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


[PHP] ezpublish question -- take 2

2004-11-04 Thread Daniel Guerrier
Has anyone used the latest version of ezpublish?

How did you learn how to use it?  Do you recommend
getting the book?



__ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 

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



[PHP] help in php script

2004-11-04 Thread Deepak Dhake
I have a following PHP file TimeRotateImage.php which prints an image
?php
$curr_time = (localtime());
if ($curr_time[2] = 6 and $curr_time[2] = 17) {
  PRINT IMAGE_1;
}
else {
  PRINT IMAGE_2;
}
?
I want to use this script in another file to display the image. the tag 
should be
img src=TimeRotateImage.php

But i am not getting any output if i follow the above procedure. Can you 
tell me how to do it? I have to have the script TimeRotateImage.php 
which calculates which image to print accoring to local time and i want 
to embed the file name in html tag to print it on screen.

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


Re: [PHP] help in php script

2004-11-04 Thread Klaus Reimer
Deepak Dhake wrote:
But i am not getting any output if i follow the above procedure. Can you 
tell me how to do it? I have to have the script TimeRotateImage.php 
which calculates which image to print accoring to local time and i want 
to embed the file name in html tag to print it on screen.
It's not clear what your PRINT macros are doing. Maybe you forgot to 
send the content-type-header? Or maybe there is a script error which is 
not displayed when you call the page inside a image tag. Call the script 
directly in your browser to see what's going on. If it outputs binary 
data then everything is working but you forgot the content-type header.

--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] ezpublish question -- take 2

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 07:12:12 -0800 (PST), Daniel Guerrier
[EMAIL PROTECTED] wrote:
 Has anyone used the latest version of ezpublish?

No I haven't.

 How did you learn how to use it?

I'd read the (free) online docs first:
http://www.ez.no/ez_publish/documentation

It's a CMS system, it can't be _that_ difficult to learn to run. 
Since it's a 'system' you probably don't have to know much about PHP
to use it.

 Do you recommend
 getting the book?

Not unless the docs were insufficient.

Why not download it, install it and find out all these answers for
yourself?  It's is dual-licensed and all.  :)  Did you need some help
with installing it perhaps?


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

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



[PHP] pdf_stringwidth

2004-11-04 Thread blackwater dev
I am using pdf_stringwidth and only passing in the first two
parameters yet I recently updated to php 4.3.9 and it now want all 4. 
According to the manual, these where required with 5...why does 4.3.9
want them?

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



Re: [PHP] Lost session variables still confounding me

2004-11-04 Thread Daniel Kullik
Stuart Felenstein wrote:
--- Jason Wong [EMAIL PROTECTED] wrote:

Maybe what you had before was:
   if (count($myarray)  5)
  $_SESSION['arrayerr'] = you have selected
too many industries;
  session_write_close();
  header (Location: Page2.php?.SID);
  exit;
And yes that has a totally different behaviour to
the code with the endif; 
construct.

Yep, that is what I had.  So, no parse error, but did
not work  right either.
Stuart
So you just forgot some curly-braces then.
You'd write either
[code]
if (count($myarray)  5) {
$_SESSION['arrayerr'] = you have selected too many industries;
session_write_close();
header (Location: Page2.php?.SID);
exit;
}
[/code]
or
[code]
if (count($myarray)  5):
$_SESSION['arrayerr'] = you have selected too many industries;
session_write_close();
header (Location: Page2.php?.SID);
exit;
endif;
[/code]
HTH, Daniel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Very wierd issue with pdf's and rotating images

2004-11-04 Thread Brent Clements
I have tried this with pretty much every pdf library available to use with PHP and all 
have the same results.

1. I create a new pdf.
2. I rotate a jpeg using gd's imagerotate 
3. I output the jpeg to a new pdf page
4. I then output the pdf to the browser and/or to a file.

When I view the pdf, the image that was embedded in the pdf page has a large black 
rectangular area taking up the first 1/4 of the image.

If I do not rotate the image, there is no large black rectangular area.

Anybody has an idea what's going on?

Thanks,
Brent



Re: [PHP] help in php script

2004-11-04 Thread Deepak Dhake
PRINT is nothing but...
TimeRotateImage.php
?php
$curr_time = (localtime());
if ($curr_time[2] = 6 and $curr_time[2] = 17) {
   print img src='image1.jpg';
 }
else {
   print img src='image2.jpg';
 }
?
this script (something like this) should be called from another script like,
?PHP
print img src='TimeRotateImage.php';
?
did you get what i am saying? please let me know if you have some solution.
thanks
Klaus Reimer wrote:
Deepak Dhake wrote:
But i am not getting any output if i follow the above procedure. Can 
you tell me how to do it? I have to have the script 
TimeRotateImage.php which calculates which image to print accoring to 
local time and i want to embed the file name in html tag to print it 
on screen.

It's not clear what your PRINT macros are doing. Maybe you forgot to 
send the content-type-header? Or maybe there is a script error which 
is not displayed when you call the page inside a image tag. Call the 
script directly in your browser to see what's going on. If it outputs 
binary data then everything is working but you forgot the content-type 
header.

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


Re: [PHP] help in php script

2004-11-04 Thread Klaus Reimer
Deepak Dhake wrote:
?PHP
print img src='TimeRotateImage.php';
?
did you get what i am saying? please let me know if you have some solution.
thanks
No. I must admit, It don't understand it. Let me try: You have a script 
a.php which outputs this static content:

img src=b.php
b.php outputs the static content img src=c.jpeg
This can't work. You browser tries to download an image with the name 
'img src=c.jpeg'. I think THAT's your problem and the reason why I 
did not understand you problem. If you use a PHP script inside an img 
src attribute then this PHP-Script must output an image. Complete with 
content-type header and the image as binary data in the body.

Or another solution for a.php:
html
 body
  img src=?php include('b.php')? /
 /body
/html
but I don't see the sense here. You can just do all this in one script:
?php
$curr_time = (localtime());
if ($curr_time[2] = 6 and $curr_time[2] = 17) {
  $img = 'a.jpg';
}
else {
  $img = 'b.jpg';
}
?
html
 body
  img src=?=$img? /
 /body
/html
If I still misunderstood your problem then maybe your description was 
not detailed enough.

--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] help in php script

2004-11-04 Thread Klaus Reimer
Klaus Reimer wrote:
This can't work. You browser tries to download an image with the name 
'img src=c.jpeg'. 
Ah, I'm talking nonsense. I meant the browser tries to DISPLAY an image 
with the CONTENT 'img src=c.jpeg'. The browser can't do this. 
That's why you don't see anything.

--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


RE: [PHP] what am i doing wrong..??

2004-11-04 Thread Jack . van . Zanen
?php $_SERVER['PHP_SELF'] ? somehow keeps the $_GET variables. If you
change this to the real script name it seems to work

JACK

-Original Message-
From: Aalee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 1:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] what am i doing wrong..??


Hi there please have a look the code below...I dont know wht am doing wrong
here... This code is suppose to show the number of jokes in a mysql database
and allows user to add a joke when the user clicks addjoke link. And when
the joke is added, it suppose to say that Joke inserted, Thank you and
list all the jokes below this line. So far am able to view all the jokes and
take the user to add joke page. But the problem is when the user clicks
insert joke button, it does not display the message Joke inserted, Thank
you and the jokes are not listed. Infact it does not give any error aswell,
it just stays on the add joke form page. I checked the database and no joke
is added. Working on PHP ver 4.3.8 with register_globals turned OFF and
Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using
registre_globals OFF and all these probs strted coming up. This code was
working fine with globals ON. But my hosting has it off. So need to do so. I
was able to fix all the other issues came coz of this global thing in this
code. But stuck on the issue i just mentioned. Any help would be GREATLY
appreciated.

?php
if (isset($_GET['addjoke'])){
?
form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form


?php
 }
else { // start main else statement
if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,test) ;
mysql_select_db(jokes,$db);  $query = mysql_query(INSERT INTO jokes SET
JokeText = '.$_POST['jokeText'].' ,  JokeDate = CURDATE() );  echo  Joke
inserted, Thank you BRBR;  echo mysql_error(); } $color1 = #66CCFF;
$color2 = #66CC99; $row_count = 1;

// -- Following lines list the jokes in the
database 
echo bH3 These are the jokes we have got so far/H3/B; $db =
mysql_connect(localhost,homesite,test)  or die(mysql_error());
mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from
jokes; $query = mysql_query($sql); echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
echo /table;

$current_url = $_SERVER['PHP_SELF'];
echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);


} // end main else statement
?

-- 
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] what am i doing wrong..??

2004-11-04 Thread M. Sokolewicz
well ofcourse it keeps the get variables as you put it. PHP_SELF is 
the path and arguments that php was called with. use phpinfo(); to find 
out which variables hold the real path, make sure to add some random 
get variables when calling that script so you see the difference

Jack Van Zanen wrote:
?php $_SERVER['PHP_SELF'] ? somehow keeps the $_GET variables. If you
change this to the real script name it seems to work
JACK
-Original Message-
From: Aalee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 1:54 PM
To: [EMAIL PROTECTED]
Subject: [PHP] what am i doing wrong..??

Hi there please have a look the code below...I dont know wht am doing wrong
here... This code is suppose to show the number of jokes in a mysql database
and allows user to add a joke when the user clicks addjoke link. And when
the joke is added, it suppose to say that Joke inserted, Thank you and
list all the jokes below this line. So far am able to view all the jokes and
take the user to add joke page. But the problem is when the user clicks
insert joke button, it does not display the message Joke inserted, Thank
you and the jokes are not listed. Infact it does not give any error aswell,
it just stays on the add joke form page. I checked the database and no joke
is added. Working on PHP ver 4.3.8 with register_globals turned OFF and
Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using
registre_globals OFF and all these probs strted coming up. This code was
working fine with globals ON. But my hosting has it off. So need to do so. I
was able to fix all the other issues came coz of this global thing in this
code. But stuck on the issue i just mentioned. Any help would be GREATLY
appreciated.
?php
if (isset($_GET['addjoke'])){
?
form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ?
  Type your joke :br
  textarea name=jokeText id=jokeText/textarea
   br
  input name=insert type=submit id=submit value=Insert Joke
/form
?php
 }
else { // start main else statement
if(isset ($_POST['insert'])) {
 $db = mysql_connect(localhost,homesite,test) ;
mysql_select_db(jokes,$db);  $query = mysql_query(INSERT INTO jokes SET
JokeText = '.$_POST['jokeText'].' ,  JokeDate = CURDATE() );  echo  Joke
inserted, Thank you BRBR;  echo mysql_error(); } $color1 = #66CCFF;
$color2 = #66CC99; $row_count = 1;
// -- Following lines list the jokes in the
database 
echo bH3 These are the jokes we have got so far/H3/B; $db =
mysql_connect(localhost,homesite,test)  or die(mysql_error());
mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from
jokes; $query = mysql_query($sql); echo table border=1
   tr
tdbIDb/td
  tdbJoke Textb/td
  tdbJoke Dateb/td/tr;
while ($myrow = mysql_fetch_array($query))
 {
 $row_color = ($row_count % 2) ? $color1 : $color2;
  echotr bgcolor = $row_color.
  td. $myrow[id]./td.
  td. $myrow[JokeText]. /td.
  td. $myrow[JokeDate]./td/tr;
  $row_count++;
 }
echo /table;
$current_url = $_SERVER['PHP_SELF'];
echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P);
} // end main else statement
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
Klaus Reimer [EMAIL PROTECTED] wrote:
If this theory is true, you may try fpassthru().
replaced:
  readfile($name);
with:
  $fp = fopen($name, 'rb');
  fpassthru($fp);
and now I don't loose 250 Meg of memory every time I download a 250Meg 
file. If someone wants to add this to the  readfile() php manual - great.

Thanks
Robin 

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


[PHP] Determining system resources

2004-11-04 Thread Robin Getz
I have been unable to find a php function to determine available system
memory (physical and swap)?
Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
i = strlen($free);
free = str_replace('  ',' ',$free); 
}
$free = str_replace(\n,'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==
Does anyone have any ideas that could be used on all OSes? i.e. Without 
shell_exec()?

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


Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Greg Donald
On Thu, 04 Nov 2004 08:22:18 -0800, Robin Getz
[EMAIL PROTECTED] wrote:
 and now I don't loose 250 Meg of memory every time I download a 250Meg
 file. If someone wants to add this to the  readfile() php manual - great.

Anyone can post user comments in the manual.  Give it a shot.


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

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



Re: [PHP] Determining system resources

2004-11-04 Thread Greg Donald
On Thu, 04 Nov 2004 08:25:19 -0800, Robin Getz
[EMAIL PROTECTED] wrote:
 I have been unable to find a php function to determine available system
 memory (physical and swap)?

 php -r system('free -m');
 total   used   free sharedbuffers cached
Mem:   249246  2  0  4 86
-/+ buffers/cache:154 94
Swap:  486 12473

The system has to support whatever memory command you use.

*nix: free
windoze: mem


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

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



[PHP] settin mine type while saving files

2004-11-04 Thread Merlin
Hi there,
I am creating pdf files inside my application and do save them to the server 
file system. Now I have sent some of the emails by the system via email and 
found that the mine type is not set. So the pdf file apears in the attachement, 
but one has to select the application from a list to display it.
Is there a way to save the mime type with the file, so windows does know how to 
handle that file?

Thanx for any help on that,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Zip Codes

2004-11-04 Thread bb9876
Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?

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



RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
Do you mean other than asking them, like using their IP address?

Warren Vail

-Original Message-
From: bb9876 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:00 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Zip Codes


Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?

-- 
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] Zip Codes

2004-11-04 Thread Jay Blanchard
[snip]
Is there any way to use PHP to determine the zip code someone is
visiting
from, assuming they are all from the US?
[/snip]

You would have to determine their IP, which, some being dynamically
assigned at log on, would not necessarily indicate the users location.
Then you would have to be able to map the IP to a zip code. The short
answer is no.

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



Re: [PHP] Zip Codes

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 08:59:50 -0800, bb9876 [EMAIL PROTECTED] wrote:
 Is there any way to use PHP to determine the zip code someone is visiting
 from, assuming they are all from the US?

http://www.usps.com/webtools/


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

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



Re: [PHP] Zip Codes

2004-11-04 Thread John Nichel
bb9876 wrote:
Is there any way to use PHP to determine the zip code someone is visiting
from, assuming they are all from the US?
Outside of asking the visitor for it, no.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: settin mine type while saving files

2004-11-04 Thread M. Sokolewicz
Merlin wrote:
Hi there,
I am creating pdf files inside my application and do save them to the 
server file system. Now I have sent some of the emails by the system via 
email and found that the mine type is not set. So the pdf file apears in 
the attachement, but one has to select the application from a list to 
display it.
Is there a way to save the mime type with the file, so windows does know 
how to handle that file?

Thanx for any help on that,
Merlin
add a correct content-type header in the attachment headers of the email
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Zip Codes

2004-11-04 Thread Jason Wong
On Thursday 04 November 2004 16:59, bb9876 wrote:
 Is there any way to use PHP to determine the zip code someone is visiting
 from, assuming they are all from the US?

Something like this should work:

-- start
form action=?php echo $_SERVER['PHP_SELF'];  ? method=POST
Please input zipcode input type=text name=zipcode value=
input type=submit name=submit value=Enter
/form

?php
  if (!empty($_POST['zipcode'])) {
echo Whoa! your zipcode is {$_POST['zipcode']};
  }
?
-- end

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Thinking you know something is a sure way to blind yourself.
  -- Frank Herbert, Chapterhouse: Dune
*/

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



Re: [PHP] Zip Codes

2004-11-04 Thread bb9876
Okay, I run a movie news site and wanted to use it to make it even quicker
for users to find movie times in their area whether they were logged in or
not, but that's the way it goes.

Thanks fo rthe replies.


John Nichel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 bb9876 wrote:
  Is there any way to use PHP to determine the zip code someone is
visiting
  from, assuming they are all from the US?
 

 Outside of asking the visitor for it, no.

 -- 
 John C. Nichel
 ÜberGeek
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]

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



Re: [PHP] Determining system resources

2004-11-04 Thread Francisco M. Marzoa Alonso
Greetings Robin,
As far as you cannot lock another processes in the system, so this will 
not give you the security that the resources will not change -and 
probably they'll do it- while you're trying to download that file.

Best regards,
Robin Getz wrote:
I have been unable to find a php function to determine available system
memory (physical and swap)?
Right now I am using something like:
=
# ensure there is enough free memory for the download
$free = shell_exec('free -b'); $i=0; while ( $i != strlen($free) ) {
i = strlen($free);
free = str_replace('  ',' ',$free);   
}
$free = str_replace(\n,'',$free);
$freeArray = explode(' ',$free);
$total_free = $freeArray[9] + $freeArray[18];
==

Does anyone have any ideas that could be used on all OSes? i.e. 
Without shell_exec()?

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


Re: [PHP] Zip Codes

2004-11-04 Thread Matthew Weier O'Phinney
* Bb9876 [EMAIL PROTECTED]:
 John Nichel [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  bb9876 wrote:
   Is there any way to use PHP to determine the zip code someone is
   visiting
   from, assuming they are all from the US?
  
 
  Outside of asking the visitor for it, no.
 
 Okay, I run a movie news site and wanted to use it to make it even
 quicker for users to find movie times in their area whether they were
 logged in or not, but that's the way it goes.

Well, you *could* have a form that displays asking for their zip code;
on submission, it sets a cookie with their zip code, and this allows
them to see their personalized movie times on subsequent visits. (You
could even hide the zipcode form if the cookie is set)

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

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



Re: [PHP] Zip Codes

2004-11-04 Thread bb9876
Thanks for the sarcasm, it definitely helps.

Why is it that when people ask a question there is always someone that has a
smartass answer?

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thursday 04 November 2004 16:59, bb9876 wrote:
  Is there any way to use PHP to determine the zip code someone is
visiting
  from, assuming they are all from the US?

 Something like this should work:

 -- start
 form action=?php echo $_SERVER['PHP_SELF'];  ? method=POST
 Please input zipcode input type=text name=zipcode value=
 input type=submit name=submit value=Enter
 /form

 ?php
   if (!empty($_POST['zipcode'])) {
 echo Whoa! your zipcode is {$_POST['zipcode']};
   }
 ?
 -- end

 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Thinking you know something is a sure way to blind yourself.
   -- Frank Herbert, Chapterhouse: Dune
 */

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



RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
One thing I might be tempted to try would be to execute a trace route
utility and analyze the output, but it is very cryptic;

http://www.traceroute.org/
http://www.tracert.com/cgi-bin/trace.pl

HOSTLOSS  RCVD SENTBEST AVG
WORST
er1.sfo1.speakeasy.net0%20   20   25.70   30.68
89.13
220.ge-0-1-0.cr2.sfo1.speakeasy.net   0%20   20   24.02   26.56
58.23
ge-4-0-440.ipcolo1.SanJose1.Level3.net0%20   20   24.38   25.28
27.09
ae-1-56.bbr2.SanJose1.Level3.net  0%20   20   24.26   31.00
97.58
so-3-0-0.mp1.SanFrancisco1.Level3.net 0%20   20   25.49   28.89
49.58
so-10-0.ipcolo1.SanFranciso1.Level3.net   0%20   20   25.17   25.81
26.73
gw-level3-sfo.internap.com0%20   20   27.32   28.12
29.58
border4.ge3-0-bbnet2.sfo.pnap.net 0%20   20   27.11   28.24
28.93
??? 100% 0   200.000.00
0.00

If you can figure out how to make sense of this, you might be able to find
the point that a system is connected to the internet, by tracing back to a
visitors current IP address.

If you come up with something useful, keep the list informed.

Warren Vail


-Original Message-
From: John Nichel [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:22 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Zip Codes


bb9876 wrote:
 Is there any way to use PHP to determine the zip code someone is 
 visiting from, assuming they are all from the US?
 

Outside of asking the visitor for it, no.

-- 
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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

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



Re: [PHP] Re: PHP Crypt on MacOSX

2004-11-04 Thread Kris
Galen P.Zink wrote:
Kris,
I doubt there's no way to do this under OS X. Maybe by default, you 
have a curve ball to deal with. But considering the kernel is open 
source, you could make this OS do anything... literally :)
That is how I feel as well.  Being a long-time *nix/BSD user.. I have 
heard it before and never believe it cant be done.  I remember back on 
the C64, they said the computer would not support a 9600BAUD modem, then 
one day I am plugging one into my cartridge port and getting blazing 
speeds (LOL This was in the eighties obviously)...

A second problem, and why I want to create some PHP to mimic crypt() 
unix style passwords without actually using crypt() is due to the fact 
that this box is not my box and so the option of modifying the OS is 
currently not an option.  Consider this thread dead unless someone else 
has a solution.  Thanks for thinking it through.  Your time has been 
greatly appreciated.

A side note; I am amazed that no one else on this list can or is jumping 
into this discussion about using PHP to mimic PHP's crypt() function in 
order to create unix style MD5 passwords.  I know it has been done 
before, and can be done probably many different ways.  The idea of using 
system() or exec() to call MD5 is an option I will be looking into, 
however, I know there must be another option.  I have considered 
rewriting my own version of crypt() to not use libmcrypt but the 
information on the C-like Zend language used to write your own embedded 
PHP functions is a bit vague in regards to me getting over the learning 
curve.  My other option is to just move this to another server and then 
my existing crypt() based code will resume functioning as expected.

I dont except a reply from Rasmus or Zeev, as they are extremely busy 
guys, however, I won't stop them if they are interested in this thread.

Help me Obi Won, you are my only hope. LOL
Take Care,
Kris
[EMAIL PROTECTED]
Where is your PHP package coming from? If you've already been using 
the http://entropy.ch binary, maybe you should try compiling your own. 
Or get (and either compile yourself or just install binaries) it via 
fink (http://fink.sf.net/) which often gives you different options for 
libraries to use and such during install. Or any number of other 
options. I wonder if there is some build option or something setup in 
the configuration process that affects this. I seriously wonder how 
libmcrypt could have this sort of limitation under OS X, but I am not 
that type of programmer.

I would encourage you to play with this and post your results to the 
php-general list as well as letting me know how it goes.

-Galen
On Nov 3, 2004, at 2:31 PM, Kris wrote:
Galen,
Thank you for the response.  I understand where you are coming from; 
your use of MD5 hash.  In short, my goal is to recreate crypt()'s 
method of creating unix style passwords without using PHP's 
built-in crypt() function... (as seen in /etc/shadow on a *nix 
server, ie. $1$sed$blaaah instead of standard MD5 hash which 
does not use $1$$ to store a seed.)

Ultimately, my problem exists related to the server I am using, where 
the server's PHP crypt (using libmcrypt) returns with the fact that
CRYPT_MD5 = 0 .

In researching, I have been told that this is a limitation of Mac OS 
X, that there is no way to have libmcrypt support both DES and MD5 
on this OS.. but I know there must be a way because it is easy to 
have a FreeBSD server use both DES and MD5.

I had an old BSD box online for years.. where old account passwords 
in /etc/shadow were encrypted via two character salt DES.  One day, I 
made a simple change to the box's config and then any new accounts 
created would use MD5.  The coolest part is that any old passwords 
in DES could remain DES, and BSD's libmcrypt could determine if a 
passwd in /etc/shadow was DES or MD5 and handle accordingly.  
Obviously, this kept me from having to call clients and change their 
password so as to re-encrypt their respective /etc/shadow entry into 
MD5.

I hope this email better explains my situation.   I'll check out man 
md5 on the Mac box and see what I can figure out.  In the meantime, 
if this email helps to generate any ideas which may be helpful in my 
current quest, your input would be most appreciated.

Thanks again,
Kris
Galen P.Zink wrote:
Kris,
I'm not quite sure what you mean here. When I work with md5, I 
always have considered it to work like this:

string - md5 = hash
On any system, the md5 binary, md5 php function, and MySQL md5 (in 
most cases - though in certain situations you could have problems if 
you have a field of the wrong type or length) all work exactly alike.

This is how I have always thought of md5 and considered it to be 
standard and I've never had a problem with it. I've made dozens of 
web and other php/mysql applications.

There have never been seeds or anything else involved in my 
experiences. I do know that in some cases a salt is setup on 
certain unix 

Re: [PHP] Determining system resources

2004-11-04 Thread Robin Getz
Francisco M. Marzoa Alonso [EMAIL PROTECTED] wrote:
As far as you cannot lock another processes in the system, so this will 
not give you the security that the resources will not change -and probably 
they'll do it- while you're trying to download that file.
Yes, I understand, but not to know even if you are in the right order of 
magnitude, is kind of scary isn't it?

For example on my system, I have 1 Gig of physical memory, and 3Gig of 
swap. If I end up with only 512k free - something is very wrong, and I 
should disallow functions I know that eat up memory. There is a low 
probability that multiple connections will pass the test, and then consume 
the memory, so yes this is not 100% coverage.

Maybe what I am seeing is actually a bug in the way that readfile() handles 
low memory situations. If there is not enough memory for internal functions 
to run, they should error, not crash your system.

I assume that the way the converstation is moved is that there is not a way 
to see what free system memory is, without calling a command line function 
(free or mem).

-Robin 

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


RE: [PHP] Zip Codes

2004-11-04 Thread Vail, Warren
Because for some of us, that part of our body is the smartest thing we have
going, and the rest of us is not engaged in the question.

Warren Vail

-Original Message-
From: bb9876 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 9:41 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Zip Codes


Thanks for the sarcasm, it definitely helps.

Why is it that when people ask a question there is always someone that has a
smartass answer?

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Thursday 04 November 2004 16:59, bb9876 wrote:
  Is there any way to use PHP to determine the zip code someone is
visiting
  from, assuming they are all from the US?

 Something like this should work:

 -- start
 form action=?php echo $_SERVER['PHP_SELF'];  ? method=POST 
 Please input zipcode input type=text name=zipcode value= 
 input type=submit name=submit value=Enter /form

 ?php
   if (!empty($_POST['zipcode'])) {
 echo Whoa! your zipcode is {$_POST['zipcode']};
   }
 ?
 -- end

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Thinking you know something is a sure way to blind yourself.
   -- Frank Herbert, Chapterhouse: Dune
 */

-- 
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] Zip Codes

2004-11-04 Thread Matthew Sims
 Thanks for the sarcasm, it definitely helps.

 Why is it that when people ask a question there is always someone that has
 a smartass answer?


It keeps us on our toes. Someone's gotta do it.

-- 
--Matthew Sims
--http://killermookie.org

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



[PHP] Re: Advice on imagecreatefromsrc_type

2004-11-04 Thread Daniel Lahey
I find it hard to believe that your choice of browser affects the 
operation of
PHP.
Where is this report?
I may have been mistaken about the report:  Windows versions of PHP 
prior to PHP 4.3.0 do not support accessing remote files via this 
function, even if allow_url_fopen is enabled.  (Found at 
http://us2.php.net/manual/en/function.imagecreatefromjpeg.php)  The 
server is running Linux, so it's not Windows PHP, it's the client (IE).

I find it hard to believe, too.  The error is (as I recall) call to 
undefined function () in source at line with no function name 
given, just the empty parentheses.  It doesn't happen in Firefox, 
Mozilla, or Netscape.

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


RE: [PHP] Zip Codes

2004-11-04 Thread Jay Blanchard
[snip]
 Thanks for the sarcasm, it definitely helps.

 Why is it that when people ask a question there is always someone that
has
 a smartass answer?


It keeps us on our toes. Someone's gotta do it.
[/snip]

It would be a terrible thing to arrive one day, open the list, and see
that everyone had been civil...no sarcasm, no witjust business. BTW
thanks for the heads up on that USPS API

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



RE: [PHP] Zip Codes

2004-11-04 Thread Brian V Bonini
On Thu, 2004-11-04 at 12:47, Vail, Warren wrote:

 If you can figure out how to make sense of this, you might be able to find
 the point that a system is connected to the internet, by tracing back to a
 visitors current IP address.

Which may get you close but either way would probably be more indicative
of the service providers location then the actual user and even
narrowing it down to a single city does not mean you have only a single
zip code to deal with.

-- 

s/:-[(/]/:-)/g


BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org
aGEhIGJldCB5b3UgdGhpbmsgeW91IHByZXR0eSBzbGljayBmb3IgZmlndXJpbmcgb3V0I
GhvdyB0byBkZWNvZGUgdGhpcy4gVG9vIGJhZCBpdCBoYXMgbm8gc2VjcmV0IGluZm8gaW
4gaXQgaGV5Pwo=

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



Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Curt Zirzow
* Thus wrote Robin Getz:
 Klaus Reimer [EMAIL PROTECTED] wrote:
 If this theory is true, you may try fpassthru().
 
 replaced:
   readfile($name);
 with:
   $fp = fopen($name, 'rb');
   fpassthru($fp);

The only difference between readfile() and fpassthru() is what
parameters you pass it.

Something else is the problem, what version of php are you running?


Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Re: Advice on imagecreatefromsrc_type

2004-11-04 Thread Jason Wong
On Thursday 04 November 2004 18:33, Daniel Lahey wrote:

 I find it hard to believe, too.  The error is (as I recall) call to
 undefined function () in source at line with no function name
 given, just the empty parentheses.  It doesn't happen in Firefox,
 Mozilla, or Netscape.

Post some *concise* code that illustrates your problem.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Why not go out on a limb?  Isn't that where the fruit is?
*/

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



[PHP] How to display a 'please wait' message whilst processing?

2004-11-04 Thread Graham Cossey

On a number of sites a message and/or graphic is displayed asking you to
wait or be patient whilst some processing is being performed to compose the
next page.

How are these done within PHP scripts?
Could output buffering be used for this purpose?
For example is it possible to do something like:

?php
// Nothing is output until end of this script :(
ob_start();

echo Please wait...;

ob_flush();

//Processing to build report
sleep(10);

ob_end_flush();
?

Should I be aware of anything that could trip me up on this?

Any help or pointers much appreciated.

Graham

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



[PHP] Strange query

2004-11-04 Thread Ryan A
Hi,
I am running this query from my script:

  $query = select gallery_url,description from members limit
.$limit[0].,.$limit[1];

the first time: limit 0,15
and the second time: limit 16,30


the problem is the first time I am getting 15 rows returned (as expected)
the second query of
select gallery_url,description from members limit 16,30
is returning 17 rows!!

I've even tried it within phpmyadmin and its giving me 17 rowswhat am I
missing here?

Thanks,
Ryan

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



RE: [PHP] Strange query

2004-11-04 Thread Jay Blanchard
[snip]
  $query = select gallery_url,description from members limit
.$limit[0].,.$limit[1];

the first time: limit 0,15
and the second time: limit 16,30
[/snip]

from http://www.mysql.com/select

The LIMIT clause can be used to constrain the number of rows returned
by the SELECT statement. LIMIT takes one or two numeric arguments, which
must be integer constants. With two arguments, the first argument
specifies the offset of the first row to return, and the second
specifies the maximum number of rows to return. The offset of the
initial row is 0 (not 1): 

My guess is that you have 32 rows in the table, you started at 16 and
asked for 30 records. You got back 17, which is all that was left

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



RE: [PHP] Strange query

2004-11-04 Thread Vail, Warren
The second limit parameter is the actual number of rows to limit to, and in
most situations this is usually the same number (i.e. 0,15; 15,15; 30,15;
etc).  It is too bad this clause is not supported by some of the other
databases I have had to use, it makes a convenient way of paging where the
second paging parameter specifies the page size in terms of rows to retrieve
(first parameter is the starting row number starting with zero).

Warren Vail


-Original Message-
From: Ryan A [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 11:49 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Strange query


Hi,
I am running this query from my script:

  $query = select gallery_url,description from members limit
.$limit[0].,.$limit[1];

the first time: limit 0,15
and the second time: limit 16,30


the problem is the first time I am getting 15 rows returned (as expected)
the second query of select gallery_url,description from members limit 16,30
is returning 17 rows!!

I've even tried it within phpmyadmin and its giving me 17 rowswhat am I
missing here?

Thanks,
Ryan

-- 
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] Strange query

2004-11-04 Thread Ryan A
Hey,

 the second
 specifies the maximum number of rows to return.

Thats where my problem was...thanks. I forget the Limit parameters, i for
some reason though the second parameter was till which record to return...

Loud and clear sign telling me to get some sleep (i guess)
 :-)

Thanks,
Ryan

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



Re: [PHP] Strange query

2004-11-04 Thread Greg Donald
On Thu, 4 Nov 2004 13:02:19 -0700, Vail, Warren [EMAIL PROTECTED] wrote:
 It is too bad this clause is not supported by some of the other
 databases I have had to use

I think calling a limit a limit and an offset an offset is a good thing.


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

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



[PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
I have a field that is an actual Mysql Text column,
aka like a blob.  I'm wondering if doing a standard
validation that checks for characters outside of the
alphanumeric range is enough.  I'm imagining some
users will cut and paste from a Word or PDF doc into
the field. I've done it myself and no weird characters
are showing up.

Any thoughts ?

Stuart

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
Any thoughts ?
[/snip]

I thought I'd have lunch today, but I didn't.

Is it a 'text' data type, or 'BLOB', (you said, actual Mysql Text
column, aka like a blob) because the distinction is needed.

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Vail, Warren
Assuming that the pasting is done into a textarea/textarea on an html
form, I believe the Textarea will limit the past to just text characters.


I suppose this could be dependent on the browser.  

I don't know of any html input control that would allow blob (binary)
values.

I also don't know if MySQL will police things input to a text column to make
sure they are valid ascii text characters.

Warren Vail


-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 04, 2004 12:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Question: Validation on a text field


I have a field that is an actual Mysql Text column,
aka like a blob.  I'm wondering if doing a standard
validation that checks for characters outside of the alphanumeric range is
enough.  I'm imagining some users will cut and paste from a Word or PDF doc
into the field. I've done it myself and no weird characters are showing up.

Any thoughts ?

Stuart

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

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
It's a mysql text field.

Stuart
--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 [snip]
 Any thoughts ?
 [/snip]
 
 I thought I'd have lunch today, but I didn't.
 
 Is it a 'text' data type, or 'BLOB', (you said,
 actual Mysql Text
 column, aka like a blob) because the distinction is
 needed.
 
 --
 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] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein

--- Vail, Warren [EMAIL PROTECTED] wrote:

 I also don't know if MySQL will police things input
 to a text column to make
 sure they are valid ascii text characters.
 
No Mysql won't do it.  PHP validation would have to be
involved.

Stuart

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
It's a mysql text field.
[/snip]

You can use htmlentities() on the information placed into the field

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
May I ask why you are suggesting this function ?

Stuart
--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 [snip]
 It's a mysql text field.
 [/snip]
 
 You can use htmlentities() on the information placed
 into the field
 
 --
 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] Re: VOTE TODAY

2004-11-04 Thread Michael Lauzon
6Mb, that's no fair, the highest we have in Canada is 4Mb; although
supposedly there is a 5Mb service somewhere...well there is 7Mb
service but you'll be paying out of your @$$ for it.




On Thu, 4 Nov 2004 04:09:50 +0100, Michelle Konzack
[EMAIL PROTECTED] wrote:
 Am 2004-11-02 18:36:08, schrieb Michael Lauzon:
  I am also Canadian, so don't waste my bandwidth either...Chris
  bandwidth is cheap in Canada!
 
 
 ...and cheaper in France at free.fr
 
 30 Euros for ADSL 6MBit/512kBit
 
 Greetings
 Michelle
 
 --
 Linux-User #280138 with the Linux Counter, http://counter.li.org/
 Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
 0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)
 
 
 


-- 
Michael Lauzon

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



RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Jay Blanchard
[snip]
May I ask why you are suggesting this function ?

 You can use htmlentities() on the information placed
[/snip]

Because it will convert things like quotes into their HTML counterparts
before you place them into the table. If you are reading it back out to
a web interface they get properly displayed without any manipulation.
http://www.php.net/htmlentities explains a little more in depth. It is
one step towards preventing SQL injection and possible other hack
attacks.

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



Re: [PHP] Zip Codes

2004-11-04 Thread Dusty Bin
Brian V Bonini wrote:
On Thu, 2004-11-04 at 12:47, Vail, Warren wrote:

If you can figure out how to make sense of this, you might be able to find
the point that a system is connected to the internet, by tracing back to a
visitors current IP address.

Which may get you close but either way would probably be more indicative
of the service providers location then the actual user and even
narrowing it down to a single city does not mean you have only a single
zip code to deal with.
not to mention DHCP!!!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question: Validation on a text field

2004-11-04 Thread Ben Ramsey
Jay Blanchard wrote:
[snip]
May I ask why you are suggesting this function ?
You can use htmlentities() on the information placed
[/snip]
Because it will convert things like quotes into their HTML counterparts
before you place them into the table. If you are reading it back out to
a web interface they get properly displayed without any manipulation.
http://www.php.net/htmlentities explains a little more in depth. It is
one step towards preventing SQL injection and possible other hack
attacks.
You should also use mysql_real_escape_string() on the data from the client.
http://www.php.net/mysql_real_escape_string
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Robin Getz
Curt Zirzow [EMAIL PROTECTED] wrote:
 replaced:
   readfile($name);
 with:
   $fp = fopen($name, 'rb');
   fpassthru($fp);
The only difference between readfile() and fpassthru() is what parameters 
you pass it.

Something else is the problem, what version of php are you running?
I am using php 4.2.2
OK - I lied.
The same problem exists with fpassthru (now that I have let it run a little 
longer) I now have 5 sleeping httpd processes on my system that are 
consuming 200Meg each.

Any thoughts? 

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


RE: [PHP] Question: Validation on a text field

2004-11-04 Thread Stuart Felenstein
--- Jay Blanchard
[EMAIL PROTECTED] wrote:

 [snip]
 May I ask why you are suggesting this function ?
 
  You can use htmlentities() on the information
 placed
 [/snip]
 
 Because it will convert things like quotes into
 their HTML counterparts
 before you place them into the table.

I'm still a bit fuzzy on how to write it out.

So if field is labelled f5
Then I'm doing a $_SESSION['f5'] = $_POST['MyText'];
then I think it would be 
$f5 = htmlentities($f5, ENT_QUOTES);

insert $f5 into database ?

Thanks
Stuart

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



[PHP] Is there any 'strict' and 'warnings' like packages inside PHP ?

2004-11-04 Thread Exile
Hi list, 

Is there any package like 'strict' or 'warnings' in PHP, like Perl ?

Thanks in advise,
Exile

Re: [PHP] Downloading Large (100M+) Files

2004-11-04 Thread Klaus Reimer
Robin Getz wrote:
The same problem exists with fpassthru (now that I have let it run a 
little longer) I now have 5 sleeping httpd processes on my system that 
are consuming 200Meg each.
Any thoughts?
Ok, so much for the theory. What about the output buffering? Have you 
checked if you have output buffering enabled? What das ob_get_level() 
return?

If it's activated but you can't find where it is activated then this may 
help to disable it in your script:

while (ob_get_level()) ob_end_flush();
--
Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


  1   2   >