Re: [PHP] substr?

2008-06-20 Thread Jason Pruim

I'l post where ever I want in my own thread Master Brown :P

Maybe just to confuse people even more, I should rot_13 this e-mail :P
On Jun 20, 2008, at 2:21 PM, Daniel Brown wrote:


   Don't top post!  >:-o

On Fri, Jun 20, 2008 at 7:44 AM, Jason Pruim <[EMAIL PROTECTED]>  
wrote:

One of theses days I will ;)


   There's only one 's' in 'these'.


It was also posted before 8 AM on a friday a week ago :P Slow to  
respond much? :P





But when you know a tool that will work and it's a simple little  
form that's
only going to be used by a few people occasionally until this  
business takes

off and I need to upgrade stuff... explode() works just fine :P


   Prune, on a serious note, don't ever settle for that, because that
means you're going to be coding that at least twice.  Always do a
better job than you need to do.


I'm working on it... :) Still at the point of "Program it and get it  
working so the boss will authorize you to work on it, and then  
reprogram later to be better".


I'll look more into substr to increase my knowledge though :)



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



Re: [PHP] substr?

2008-06-20 Thread tedd

At 2:21 PM -0400 6/20/08, Daniel Brown wrote:

On Fri, Jun 20, 2008 at 7:44 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:

 One of theses days I will ;)


There's only one 's' in 'these'.


Grammar police alert!


Always do a better job than you need to do.



I agree with that -- however -- if you do, you'll always stay where you are.

You never get into management until you find a way to screw-up consistently.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] substr?

2008-06-20 Thread Daniel Brown
Don't top post!  >:-o

On Fri, Jun 20, 2008 at 7:44 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> One of theses days I will ;)

There's only one 's' in 'these'.

> But when you know a tool that will work and it's a simple little form that's
> only going to be used by a few people occasionally until this business takes
> off and I need to upgrade stuff... explode() works just fine :P

Prune, on a serious note, don't ever settle for that, because that
means you're going to be coding that at least twice.  Always do a
better job than you need to do.

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] substr?

2008-06-20 Thread Jason Pruim

One of theses days I will ;)

But when you know a tool that will work and it's a simple little form  
that's only going to be used by a few people occasionally until this  
business takes off and I need to upgrade stuff... explode() works just  
fine :P



On Jun 19, 2008, at 6:18 PM, Philip Thompson wrote:


RTFM: http://www.php.net/strrpos Hehe =D

"Find position of last occurrence of a char in a string"

This avoids the extension containing multiple '.'s.

~Phil

On Jun 19, 2008, at 1:02 PM, Jason Pruim wrote:


Know what I found that works most reliably though?

$filenameExploded = explode(".", $filename);

that way, if I have a file like this:  
filename.todaysdate.todaystime.extension I don't end up with the  
extension being: .todaysdate.todaystime.extension :) Unless I was  
using the substr() command wrong.



On Jun 19, 2008, at 1:53 PM, Philip Thompson wrote:


Does that get a different result than mine?

~Phil


On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:


Try this:

echo substr($filename,(strrpos($filename,'.') +  
1),strlen($filename))."\n";

?>



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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






"Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me..." ~S. Johnson



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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] substr?

2008-06-19 Thread Philip Thompson

RTFM: http://www.php.net/strrpos Hehe =D

"Find position of last occurrence of a char in a string"

This avoids the extension containing multiple '.'s.

~Phil

On Jun 19, 2008, at 1:02 PM, Jason Pruim wrote:


Know what I found that works most reliably though?

$filenameExploded = explode(".", $filename);

that way, if I have a file like this:  
filename.todaysdate.todaystime.extension I don't end up with the  
extension being: .todaysdate.todaystime.extension :) Unless I was  
using the substr() command wrong.



On Jun 19, 2008, at 1:53 PM, Philip Thompson wrote:


Does that get a different result than mine?

~Phil


On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:


 Try this:

echo substr($filename,(strrpos($filename,'.') +  
1),strlen($filename))."\n";

?>



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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]






"Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me..." ~S. Johnson



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



Re: [PHP] substr?

2008-06-19 Thread Daniel Brown
On Thu, Jun 19, 2008 at 1:53 PM, Philip Thompson <[EMAIL PROTECTED]> wrote:
> Does that get a different result than mine?

Sorry, Phil, I hadn't even been paying much attention to the
thread, and saw that it just kept going, so I sent in a suggestion.
Both of our things do the exact same thing, but you're is shorter and
you said it quicker.  ;-P

-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] substr?

2008-06-19 Thread Jason Pruim

Know what I found that works most reliably though?

$filenameExploded = explode(".", $filename);

that way, if I have a file like this:  
filename.todaysdate.todaystime.extension I don't end up with the  
extension being: .todaysdate.todaystime.extension :) Unless I was  
using the substr() command wrong.



On Jun 19, 2008, at 1:53 PM, Philip Thompson wrote:


Does that get a different result than mine?

~Phil


On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:


  Try this:

echo substr($filename,(strrpos($filename,'.') +  
1),strlen($filename))."\n";

?>



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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
[EMAIL PROTECTED]





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



Re: [PHP] substr?

2008-06-19 Thread Philip Thompson

Does that get a different result than mine?

~Phil


On Jun 19, 2008, at 10:44 AM, Daniel Brown wrote:


   Try this:

echo substr($filename,(strrpos($filename,'.') +  
1),strlen($filename))."\n";

?>



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



Re: [PHP] substr?

2008-06-19 Thread Daniel Brown
Try this:





-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] substr?

2008-06-19 Thread Philip Thompson

On Jun 17, 2008, at 8:01 AM, Dan Shirah wrote:


The code I'm having issues with is this:

  $filename = $_FILES['userfile']['name']; // Get the name of  
the file

(including file extension).
  $ext = substr($filename, strpos($filename,'.'),
strlen($filename)-1); // Get the extension from the filename.

All I want to do is grab the file extension and verify that it is  
a .zip or
a .pdf etc. file. This is working for small files (under a few  
megs) but for
some reason it fails when I get bigger. I have increased the  
allowed memory

size to 50 MB's I'm testing with a 44 MB file right now.



I'm not an expert on pulling in and reading files, but if all you  
want is
the last three characters of a file name, couldn't you just do  
something

like:

$extension = substr($filename, -3);


What about file extensions that are not 3 characters in length? This  
should be updated to:




Sorry, I know this doesn't contribute to the original problem, but it  
does address another... ;)


~Philip



if ($extension = "pdf" || $extension = "zip") {
 echo "The file is a PDF or ZIP.";
} else {
 echo "Incorrect file type.";
}

??

Or maybe you are saying you want it to perform this check while the  
user is

attempting to upload the file and not after it has been uploaded?


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



Re: [PHP] substr?

2008-06-19 Thread Peter Ford

Jim Lucas wrote:

Peter Ford wrote:

Frank Arensmeier wrote:


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how 
it is now...
What I am doing is coding a upload form where people could be 
uploading .zip files in excess of 200 MB... Yes I know that is 
large, but it's for a print shop and they get HUGE files to print 
from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of the 
file (including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is a 
.zip or a .pdf etc. file. This is working for small files (under a 
few megs) but for some reason it fails when I get bigger. I have 
increased the allowed memory size to 50 MB's I'm testing with a 44 
MB file right now.
When it fails, it says the file type is not allowed even though it 
is listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some 
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?





I am somewhat surprised that all code suggestions are rather 
complicated in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo "No file has been uploaded";
} else {

$allowed_extensions = array( "zip", "pdf", "ai", "html" );
$file_info = pathinfo( $_FILES['userfile']['name'] );

if ( in_array( strtolower( $file_info['extension'] ), 
$allowed_extensions ) ) {

echo "File has a valid extension";
} else {
// do something else
}
}

// frank




Two points here:
Firstyl, as someone has already indicated, the file will be uploaded 
before the PHP script runs, so the end user will have to wait for his 
junk to get through the internet before (s)he is told it is junk. Is 
that what you want?


Secondly, using the file extension to determine file type is a very 
poor idea and open to abuse. If you have the file (which you do, 'cos 
it's been uploaded before your script runs) then you should do a bit 
more checking before accepting it. The Unix/Linux "file" command can 
help here. Not perfect, but still...
You could also Virus-scan the file before accepting it. All depends on 
whether your customer is prepared to wait while you clear his upload.


Cheers
Pete



I think that you have the wrong person here.  That was a different 
thread/person talking about preventing DoS'ing attacks.  Not Jason.




D'oh! I'm sure I responded to the other thread.

I'm a bit young for 'Senior moments' yet...

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] substr?

2008-06-18 Thread Jim Lucas

Peter Ford wrote:

Frank Arensmeier wrote:


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how it 
is now...
What I am doing is coding a upload form where people could be 
uploading .zip files in excess of 200 MB... Yes I know that is 
large, but it's for a print shop and they get HUGE files to print from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of the 
file (including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is a 
.zip or a .pdf etc. file. This is working for small files (under a 
few megs) but for some reason it fails when I get bigger. I have 
increased the allowed memory size to 50 MB's I'm testing with a 44 
MB file right now.
When it fails, it says the file type is not allowed even though it 
is listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some 
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?





I am somewhat surprised that all code suggestions are rather 
complicated in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo "No file has been uploaded";
} else {

$allowed_extensions = array( "zip", "pdf", "ai", "html" );
$file_info = pathinfo( $_FILES['userfile']['name'] );

if ( in_array( strtolower( $file_info['extension'] ), 
$allowed_extensions ) ) {

echo "File has a valid extension";
} else {
// do something else
}
}

// frank




Two points here:
Firstyl, as someone has already indicated, the file will be uploaded 
before the PHP script runs, so the end user will have to wait for his 
junk to get through the internet before (s)he is told it is junk. Is 
that what you want?


Secondly, using the file extension to determine file type is a very poor 
idea and open to abuse. If you have the file (which you do, 'cos it's 
been uploaded before your script runs) then you should do a bit more 
checking before accepting it. The Unix/Linux "file" command can help 
here. Not perfect, but still...
You could also Virus-scan the file before accepting it. All depends on 
whether your customer is prepared to wait while you clear his upload.


Cheers
Pete



I think that you have the wrong person here.  That was a different thread/person 
talking about preventing DoS'ing attacks.  Not Jason.


--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] substr?

2008-06-18 Thread Peter Ford

Frank Arensmeier wrote:


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how it 
is now...
What I am doing is coding a upload form where people could be 
uploading .zip files in excess of 200 MB... Yes I know that is large, 
but it's for a print shop and they get HUGE files to print from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of the 
file (including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is a 
.zip or a .pdf etc. file. This is working for small files (under a 
few megs) but for some reason it fails when I get bigger. I have 
increased the allowed memory size to 50 MB's I'm testing with a 44 MB 
file right now.
When it fails, it says the file type is not allowed even though it is 
listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some 
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?





I am somewhat surprised that all code suggestions are rather complicated 
in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo "No file has been uploaded";
} else {

$allowed_extensions = array( "zip", "pdf", "ai", "html" );
$file_info = pathinfo( $_FILES['userfile']['name'] );

if ( in_array( strtolower( $file_info['extension'] ), 
$allowed_extensions ) ) {

echo "File has a valid extension";
} else {
// do something else
}
}

// frank




Two points here:
Firstyl, as someone has already indicated, the file will be uploaded before the 
PHP script runs, so the end user will have to wait for his junk to get through 
the internet before (s)he is told it is junk. Is that what you want?


Secondly, using the file extension to determine file type is a very poor idea 
and open to abuse. If you have the file (which you do, 'cos it's been uploaded 
before your script runs) then you should do a bit more checking before accepting 
it. The Unix/Linux "file" command can help here. Not perfect, but still...
You could also Virus-scan the file before accepting it. All depends on whether 
your customer is prepared to wait while you clear his upload.


Cheers
Pete

--
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] substr?

2008-06-18 Thread Frank Arensmeier


17 jun 2008 kl. 22.14 skrev Jim Lucas:


Jason Pruim wrote:

Hi everyone,
I am attempting to adopt some code to work more reliably then how  
it is now...
What I am doing is coding a upload form where people could be  
uploading .zip files in excess of 200 MB... Yes I know that is  
large, but it's for a print shop and they get HUGE files to print  
from.

The code I'm having issues with is this:
$filename = $_FILES['userfile']['name']; // Get the name of  
the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen 
($filename)-1); // Get the extension from the filename.
All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under  
a few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.
When it fails, it says the file type is not allowed even though it  
is listed in the file type array.
Hopefully I have given you enough to go on to at least ask me some  
questions :)

--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


Looking at what I think you are trying to do, how about this?





I am somewhat surprised that all code suggestions are rather  
complicated in my opinion. What is wrong with 'pathinfo'?


if ( !isset( $_FILES['userfile']['name'] ) ) {
echo "No file has been uploaded";
} else {

$allowed_extensions = array( "zip", "pdf", "ai", "html" );
$file_info = pathinfo( $_FILES['userfile']['name'] );

	if ( in_array( strtolower( $file_info['extension'] ),  
$allowed_extensions ) ) {

echo "File has a valid extension";
} else {
// do something else
}
}

// frank


--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


--
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] substr?

2008-06-17 Thread Jim Lucas

Jason Pruim wrote:

Hi everyone,

I am attempting to adopt some code to work more reliably then how it is 
now...


What I am doing is coding a upload form where people could be uploading 
.zip files in excess of 200 MB... Yes I know that is large, but it's for 
a print shop and they get HUGE files to print from.


The code I'm having issues with is this:

$filename = $_FILES['userfile']['name']; // Get the name of the file 
(including file extension).
$ext = substr($filename, strpos($filename,'.'), 
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is a .zip 
or a .pdf etc. file. This is working for small files (under a few megs) 
but for some reason it fails when I get bigger. I have increased the 
allowed memory size to 50 MB's I'm testing with a 44 MB file right now.


When it fails, it says the file type is not allowed even though it is 
listed in the file type array.


Hopefully I have given you enough to go on to at least ask me some 
questions :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]






Looking at what I think you are trying to do, how about this?



--
Jim Lucas

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

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] substr?

2008-06-17 Thread Daniel Brown
On Tue, Jun 17, 2008 at 8:39 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I am attempting to adopt some code to work more reliably then how it is
> now...
>
> What I am doing is coding a upload form where people could be uploading .zip
> files in excess of 200 MB... Yes I know that is large, but it's for a print
> shop and they get HUGE files to print from.
[snip!]

Tweak this to meet your needs.  All .htaccess settings are
PHP_INI_ALL or PHP_INI_PERDIR in modern PHP's.

# In your .htaccess
php_flag max_execution_time 300
php_flag max_input_time 300
php_flag memory_limit 64M
php_flag post_max_size 256M
php_flag upload_max_filesize 256M




-- 

Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] substr?

2008-06-17 Thread tedd

At 9:01 AM -0400 6/17/08, Dan Shirah wrote:

 >

 The code I'm having issues with is this:

$filename = $_FILES['userfile']['name']; // Get the name of the file
 (including file extension).
$ext = substr($filename, strpos($filename,'.'),
 strlen($filename)-1); // Get the extension from the filename.

 All I want to do is grab the file extension and verify that it is a .zip or
 a .pdf etc. file. This is working for small files (under a few megs) but for
 some reason it fails when I get bigger. I have increased the allowed memory
 size to 50 MB's I'm testing with a 44 MB file right now.



I'm not an expert on pulling in and reading files, but if all you want is
the last three characters of a file name, couldn't you just do something
like:

$extension = substr($filename, -3);

if ($extension = "pdf" || $extension = "zip") {
  echo "The file is a PDF or ZIP.";
} else {
  echo "Incorrect file type.";
}

??

Or maybe you are saying you want it to perform this check while the user is
attempting to upload the file and not after it has been uploaded?



if ($extension == "pdf" || $extension == "zip")


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] substr?

2008-06-17 Thread Stut

On 17 Jun 2008, at 14:04, Jason Pruim wrote:

On Jun 17, 2008, at 9:01 AM, Dan Shirah wrote:

The code I'm having issues with is this:

  $filename = $_FILES['userfile']['name']; // Get the name of  
the file (including file extension).
  $ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under  
a few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.


I'm not an expert on pulling in and reading files, but if all you  
want is the last three characters of a file name, couldn't you just  
do something like:


$extension = substr($filename, -3);

if ($extension = "pdf" || $extension = "zip") {
 echo "The file is a PDF or ZIP.";
} else {
 echo "Incorrect file type.";
}

??

Or maybe you are saying you want it to perform this check while the  
user is attempting to upload the file and not after it has been  
uploaded?


I am looking to use this as a simple test prior to the upload  
beginning... IE, if it's not a .zip file, don't try and upload 250MB  
files :)


That code will not be executed until the file has been uploaded. Such  
is the nature of the beast.


If you really need to do this your best bet is to use a client-side  
uploader.


-Stut

--
http://stut.net/

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



Re: [PHP] substr?

2008-06-17 Thread Stut

On 17 Jun 2008, at 14:05, Jason Pruim wrote:

On Jun 17, 2008, at 8:46 AM, Stut wrote:

On 17 Jun 2008, at 13:39, Jason Pruim wrote:
I am attempting to adopt some code to work more reliably then how  
it is now...


What I am doing is coding a upload form where people could be  
uploading .zip files in excess of 200 MB... Yes I know that is  
large, but it's for a print shop and they get HUGE files to print  
from.


The code I'm having issues with is this:

	$filename = $_FILES['userfile']['name']; // Get the name of the  
file (including file extension).
	$ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under  
a few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.


When it fails, it says the file type is not allowed even though it  
is listed in the file type array.


Hopefully I have given you enough to go on to at least ask me some  
questions :)


Sounds like you haven't increased upload_max_filesize in php.ini.  
If you actually look at what's in $_FILES['userfile'] you'll see  
most of it's empty. I suggest you add some more error checking  
rather than assuming everything worked ok.


Hey Stut,

I'm looking into that now, i just increased the php.ini  
upload_max_filesize to 250M and tried uploading a 44MB file and it  
failed... I'll try and add some more error checking, but I'm really  
leaning towards the problem being in the code I posted... But  
please, prove me wrong! :)


Did you restart the web server after changing it? Are you sure you're  
editing the right php.ini?


There's nothing wrong with our code that I can see. On an efficiency  
note you don't need the last parameter to substr - if it's omitted it  
defaults to the remaining test.


I would suggest doing a var_dump on $_FILES['userfile'] before the  
code you've posted to check it contains the right stuff. If not then  
it's the upload that's failing and nothing in your code.


-Stut

--
http://stut.net/

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



Re: [PHP] substr?

2008-06-17 Thread Dan Shirah
Jason,

If you don't expressly need it to run server side, you could always use a
simple little javascript check if you want.

*

function checkFileType() {
  // for mac/linux, else assume windows
  if (navigator.appVersion.indexOf('Mac') != -1 ||
navigator.appVersion.indexOf('Linux') != -1)
 var fileSplit = '/';
  else
 var fileSplit = '\\';

  var fileTypes = new Array('.zip', '.ZIP', '.jpg', '.JPG'); // valid
filetypes
  var fileName  = document.getElementById('UploadFile').value; //
current value in your file upload box
  var extension = fileName.substr(fileName.lastIndexOf('.'),
fileName.length);
  var valid = 0;

  for(var i in fileTypes) {
 if(fileTypes[i] == extension) {
valid = 1;
break;
 }
  }

  if(valid == 1)
  alert("The file to be uploaded is a PDF or ZIP file!");
  else
  alert("Invalid file type!");   *
*}*
**


Re: [PHP] substr?

2008-06-17 Thread Jason Pruim


On Jun 17, 2008, at 8:46 AM, Stut wrote:


On 17 Jun 2008, at 13:39, Jason Pruim wrote:
I am attempting to adopt some code to work more reliably then how  
it is now...


What I am doing is coding a upload form where people could be  
uploading .zip files in excess of 200 MB... Yes I know that is  
large, but it's for a print shop and they get HUGE files to print  
from.


The code I'm having issues with is this:

	$filename = $_FILES['userfile']['name']; // Get the name of the  
file (including file extension).
	$ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under  
a few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.


When it fails, it says the file type is not allowed even though it  
is listed in the file type array.


Hopefully I have given you enough to go on to at least ask me some  
questions :)


Sounds like you haven't increased upload_max_filesize in php.ini. If  
you actually look at what's in $_FILES['userfile'] you'll see most  
of it's empty. I suggest you add some more error checking rather  
than assuming everything worked ok.


Hey Stut,

I'm looking into that now, i just increased the php.ini  
upload_max_filesize to 250M and tried uploading a 44MB file and it  
failed... I'll try and add some more error checking, but I'm really  
leaning towards the problem being in the code I posted... But please,  
prove me wrong! :)




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] substr?

2008-06-17 Thread Jason Pruim


On Jun 17, 2008, at 9:01 AM, Dan Shirah wrote:


The code I'm having issues with is this:

   $filename = $_FILES['userfile']['name']; // Get the name of  
the file (including file extension).
   $ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under a  
few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.


I'm not an expert on pulling in and reading files, but if all you  
want is the last three characters of a file name, couldn't you just  
do something like:


$extension = substr($filename, -3);

if ($extension = "pdf" || $extension = "zip") {
  echo "The file is a PDF or ZIP.";
} else {
  echo "Incorrect file type.";
}

??

Or maybe you are saying you want it to perform this check while the  
user is attempting to upload the file and not after it has been  
uploaded?


I am looking to use this as a simple test prior to the upload  
beginning... IE, if it's not a .zip file, don't try and upload 250MB  
files :)




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] substr?

2008-06-17 Thread Dan Shirah
>
> The code I'm having issues with is this:
>
>$filename = $_FILES['userfile']['name']; // Get the name of the file
> (including file extension).
>$ext = substr($filename, strpos($filename,'.'),
> strlen($filename)-1); // Get the extension from the filename.
>
> All I want to do is grab the file extension and verify that it is a .zip or
> a .pdf etc. file. This is working for small files (under a few megs) but for
> some reason it fails when I get bigger. I have increased the allowed memory
> size to 50 MB's I'm testing with a 44 MB file right now.


I'm not an expert on pulling in and reading files, but if all you want is
the last three characters of a file name, couldn't you just do something
like:

$extension = substr($filename, -3);

if ($extension = "pdf" || $extension = "zip") {
  echo "The file is a PDF or ZIP.";
} else {
  echo "Incorrect file type.";
}

??

Or maybe you are saying you want it to perform this check while the user is
attempting to upload the file and not after it has been uploaded?


Re: [PHP] substr?

2008-06-17 Thread Stut

On 17 Jun 2008, at 13:39, Jason Pruim wrote:
I am attempting to adopt some code to work more reliably then how it  
is now...


What I am doing is coding a upload form where people could be  
uploading .zip files in excess of 200 MB... Yes I know that is  
large, but it's for a print shop and they get HUGE files to print  
from.


The code I'm having issues with is this:

	$filename = $_FILES['userfile']['name']; // Get the name of the  
file (including file extension).
	$ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under a  
few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44  
MB file right now.


When it fails, it says the file type is not allowed even though it  
is listed in the file type array.


Hopefully I have given you enough to go on to at least ask me some  
questions :)


Sounds like you haven't increased upload_max_filesize in php.ini. If  
you actually look at what's in $_FILES['userfile'] you'll see most of  
it's empty. I suggest you add some more error checking rather than  
assuming everything worked ok.


-Stut

--
http://stut.net/

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



[PHP] substr?

2008-06-17 Thread Jason Pruim

Hi everyone,

I am attempting to adopt some code to work more reliably then how it  
is now...


What I am doing is coding a upload form where people could be  
uploading .zip files in excess of 200 MB... Yes I know that is large,  
but it's for a print shop and they get HUGE files to print from.


The code I'm having issues with is this:

	$filename = $_FILES['userfile']['name']; // Get the name of the file  
(including file extension).
	$ext = substr($filename, strpos($filename,'.'),  
strlen($filename)-1); // Get the extension from the filename.


All I want to do is grab the file extension and verify that it is  
a .zip or a .pdf etc. file. This is working for small files (under a  
few megs) but for some reason it fails when I get bigger. I have  
increased the allowed memory size to 50 MB's I'm testing with a 44 MB  
file right now.


When it fails, it says the file type is not allowed even though it is  
listed in the file type array.


Hopefully I have given you enough to go on to at least ask me some  
questions :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 21:46:18 +0700
"Peter Lauri" <[EMAIL PROTECTED]> wrote:

>   function is_utf8_start($b) {
>   return (($b & 0x80) == 0) || ($b & 0x40);
>   }
> [/snip]
> 
> :) I think I will go with the mb_substr function, it works for me :)

Yeah, I guess that's the right thing to do. Otherwise, in a year you
won't remember what the cryptic masking is all about.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



RE: [PHP] substr and UTF-8

2006-08-30 Thread Peter Lauri
[snip]
Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the "start" of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b & 0x80) == 0) || ($b & 0x40);
  }
[/snip]

:) I think I will go with the mb_substr function, it works for me :)

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 10:08:36 -0400
Michael B Allen <[EMAIL PROTECTED]> wrote:

> On Wed, 30 Aug 2006 18:34:20 +0700
> "Peter Lauri" <[EMAIL PROTECTED]> wrote:
> 
> > Hi group,
> > 
> > I want to limit the number of characters that are shown in a script. The
> > characters happen to be Thai, and the page is encoded in UTF-8. Everything
> > works, except when I want to cut the text (just take start of string).
> > 
> > I do:
> > 
> > echo substr($thaistring, 0, 30);
> > 
> > The beginning of the string works fine, but the last character does mostly
> > "break". How can I determine the start and end of a character.
> 
> The last byte of a UTF-8 character does not have bit 8 set whereas all
> preceeding bytes do.

Actually this is false. I don't know what I was thinking. The high bit
will be set in all bytes of a UTF-8 byte sequence. If it's not it's an
ASCII character.

The bytes are actually layed out as follows [1]:

U- ___ U-007F:  0xxx
U-0080 ___ U-07FF:  110x 10xx
U-0800 ___ U-:  1110 10xx 10xx
U-0001 ___ U-001F:  0xxx 10xx 10xx 10xx

So there's no way to tell the last byte of a UTF-8 byte sequence but you
can tell if it's the first byt looking at bits 7 and 8. Specifically,
if bit 8 is not on, the character is ASCII and thus the "start" of a
new character. Otherwise, if bit 7 is on it's the start of a new UTF-8
byte sequence.

  function is_utf8_start($b) {
  return (($b & 0x80) == 0) || ($b & 0x40);
  }

Mike

[1] http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Michael B Allen
On Wed, 30 Aug 2006 18:34:20 +0700
"Peter Lauri" <[EMAIL PROTECTED]> wrote:

> Hi group,
> 
> I want to limit the number of characters that are shown in a script. The
> characters happen to be Thai, and the page is encoded in UTF-8. Everything
> works, except when I want to cut the text (just take start of string).
> 
> I do:
> 
> echo substr($thaistring, 0, 30);
> 
> The beginning of the string works fine, but the last character does mostly
> "break". How can I determine the start and end of a character.

The last byte of a UTF-8 character does not have bit 8 set whereas all
preceeding bytes do.

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

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



Re: [PHP] substr and UTF-8

2006-08-30 Thread Jochem Maas
Peter Lauri wrote:
> Hi group,
> 
> I want to limit the number of characters that are shown in a script. The
> characters happen to be Thai, and the page is encoded in UTF-8. Everything
> works, except when I want to cut the text (just take start of string).
> 
> I do:
> 
> echo substr($thaistring, 0, 30);
> 
> The beginning of the string works fine, but the last character does mostly
> "break". How can I determine the start and end of a character.

become familiar with (and install) the mb_string extension

> 
> I hope the problem is clear enough, is it? :)
> 
> Best regards,
> Peter Lauri
> 
> www.lauri.se - personal web site
> www.dwsasia.com - company web site
> 

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



[PHP] substr and UTF-8

2006-08-30 Thread Peter Lauri
Hi group,

I want to limit the number of characters that are shown in a script. The
characters happen to be Thai, and the page is encoded in UTF-8. Everything
works, except when I want to cut the text (just take start of string).

I do:

echo substr($thaistring, 0, 30);

The beginning of the string works fine, but the last character does mostly
"break". How can I determine the start and end of a character.

I hope the problem is clear enough, is it? :)

Best regards,
Peter Lauri

www.lauri.se - personal web site
www.dwsasia.com - company web site

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



Re: [PHP] Substr by words

2005-10-29 Thread Richard Lynch
On Sat, October 29, 2005 6:36 am, Danny wrote:
>  I need to extract 50 words more or less from a description field. How
> can i
> do that?. Substr, cuts the words. Is there any other way to that,
> without
> using and array? I mean and implemented function in PHP 4.x
>  I´ve been googling around, but wordwrap, and substr is driving me
> mad...

Keep in mind that the "pipe" between your database and PHP is a rather
small narrow expensive opening.

Sucking down your ENTIRE description field to throw away all but 50
characters may not be the best use of limited resources.

[This is all MOOT if you have no dreams of your site being "big" some
day.]

You therefore may want to consider something like:

select substring(description, 1, instr(description, ' ', 50)) as
description_50, substring(description, instr(description, ' ', 50), 1)
as more from ...

$description_50 will be 50 chars, more or less
$more will tell you if there was "more" or not

You will only be getting ~50 characters squeezed through that narrow
expensive db <-> PHP pipeline.

I believe that in MOST PHP/database applications this is going to be a
better performing solution, and it's somewhat "cleaner" aesthetically
than shoveling a bunch of data around that you're going to discard
anyway.

* instr may or may not be the right function in your database.  I
always forget the name of this one and have to look it up.

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

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



[PHP] Substr by words

2005-10-29 Thread Danny
Hi,
 I need to extract 50 words more or less from a description field. How can i
do that?. Substr, cuts the words. Is there any other way to that, without
using and array? I mean and implemented function in PHP 4.x
 I´ve been googling around, but wordwrap, and substr is driving me mad...
 Thanks in advance
Best Regards

--
dpc


Re: [PHP] Substr

2004-10-25 Thread M. Sokolewicz
split() uses the POSIX regular expressions engine, and thus also uses 
regular expressions. The loading of this engine is a massive overhead 
when dealing with simple splitting of a string. To do basic things like 
this it's a lot faster to use explode().

- Tul
Francisco M. Marzoa Alonso wrote:
You can also use split function if you do not know about regular 
expressions and do not want to learn:


$string = "pid_1_date_2004_10_25";
$regs = split ("_", $string );
print_r ($regs);
?>
I think its autoexplicative.
Shaun wrote:
Hi,
I have a string as follows: pid_1_date_2004_10_25
pid tells me the Project_ID and date tells me the date(!). I need to 
extract this information from the string so to get the date I need 
everything after 'date_' as follows:

substr(strstr($key, 'date_'), 4)
However, to get the Project ID I need to extract everything after 
'pid_' and everything before 'date_'. Can someone help me with this 
please as PHP doesn't seem to provide a function for extracting 
information from a string that occurs before the 'needle'?
 

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


RE: [PHP] Substr

2004-10-25 Thread Graham Cossey
What about using explode()?

$array = explode('_', 'pid_1_date_2004_10_25');
$pid = $array[1];
$yr = $array[3];
$mn = $array[4];
$dy = $array[5];

Graham

> -Original Message-
> From: Shaun [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2004 14:00
> To: [EMAIL PROTECTED]
> Subject: [PHP] Substr
> 
> 
> Hi,
> 
> I have a string as follows: pid_1_date_2004_10_25
> 
> pid tells me the Project_ID and date tells me the date(!). I need 
> to extract 
> this information from the string so to get the date I need 
> everything after 
> 'date_' as follows:
> 
> substr(strstr($key, 'date_'), 4)
> 
> However, to get the Project ID I need to extract everything after 
> 'pid_' and 
> everything before 'date_'. Can someone help me with this please as PHP 
> doesn't seem to provide a function for extracting information 
> from a string 
> that occurs before the 'needle'? 
> 
> -- 
> 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] Substr

2004-10-25 Thread Francisco M. Marzoa Alonso
You can also use split function if you do not know about regular 
expressions and do not want to learn:


$string = "pid_1_date_2004_10_25";
$regs = split ("_", $string );
print_r ($regs);
?>
I think its autoexplicative.
Shaun wrote:
Hi,
I have a string as follows: pid_1_date_2004_10_25
pid tells me the Project_ID and date tells me the date(!). I need to extract 
this information from the string so to get the date I need everything after 
'date_' as follows:

substr(strstr($key, 'date_'), 4)
However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'? 

 

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


Re: [PHP] Substr

2004-10-25 Thread Francisco M. Marzoa Alonso
Use regular expresions:

$string = "pid_1_date_2004_10_25";
preg_match ( '/^pid_(.*?)_date_(.*?)$/', $string, $regs );
print_r ($regs);
?>
Shaun wrote:
Hi,
I have a string as follows: pid_1_date_2004_10_25
pid tells me the Project_ID and date tells me the date(!). I need to extract 
this information from the string so to get the date I need everything after 
'date_' as follows:

substr(strstr($key, 'date_'), 4)
However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'? 

 

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


Re: [PHP] Substr

2004-10-25 Thread raditha dissanayake
Shaun wrote:
However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'?

yes it doe. look under regular expressions.

 


--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Substr

2004-10-25 Thread Shaun
Hi,

I have a string as follows: pid_1_date_2004_10_25

pid tells me the Project_ID and date tells me the date(!). I need to extract 
this information from the string so to get the date I need everything after 
'date_' as follows:

substr(strstr($key, 'date_'), 4)

However, to get the Project ID I need to extract everything after 'pid_' and 
everything before 'date_'. Can someone help me with this please as PHP 
doesn't seem to provide a function for extracting information from a string 
that occurs before the 'needle'? 

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



[PHP] substr == SOLVED (was "Re: [PHP] substrings")

2004-04-25 Thread David T-G
Richard, et al --

...and then Richard Harb said...
% 
% $color = '#aabbcc';
% 
% if (strlen($color) == 7) {
%echo ' r: ' . substr($color, 1, 2);
[snip]

D'oh!  I knew it should be substr but I could never find it!  I was up to
page 1098 or such and muddling through all of the PCRE doc when I gave up
and asked for help :-)


Thanks & HAND

:-D
-- 
David T-G
[EMAIL PROTECTED]
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] substr ?

2003-08-17 Thread John W. Holmes
John Taylor-Johnston wrote:

Sorry, scrap that:

if (substr_count($mystring,"¶") >0)

John Taylor-Johnston wrote:


How can I find out if $mystring includes the character "¶"?
Thought substr would do it?
J
strpos() would be better...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


Re: [PHP] substr ?

2003-08-16 Thread John Taylor-Johnston
Sorry, scrap that:

if (substr_count($mystring,"¶") >0)

John Taylor-Johnston wrote:

> How can I find out if $mystring includes the character "¶"?
> Thought substr would do it?
> J

--
John Taylor-Johnston
-
"If it's not open-source, it's Murphy's Law."

  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
  http://compcanlit.ca/
  819-569-2064



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



[PHP] substr ?

2003-08-16 Thread John Taylor-Johnston
How can I find out if $mystring includes the character "¶"?
Thought substr would do it?
J


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



Re: [PHP] substr() on part an ereg() capture

2003-03-26 Thread Justin French
A that makes more sense!!  Am trying everyone's suggestions now...

Justin French


on 27/03/03 3:32 AM, Marek Kilimajer ([EMAIL PROTECTED]) wrote:

> Forgot to mention this is to be run after
> eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", " href=\"\\1://\\2\\3\" {$t}\">\\1://\\2\\3", $str);
> as it only replaces long strings within  tags
> 
> 
> Marek Kilimajer wrote:
> 
>> $str = preg_replace('|(]*>[^<]{55})[^<]+()|','$1...$2', $str);
>> 
>> Justin French wrote:
>> 
>>> Hi, I have this ereg to turn URLs into links:
>>> 
>>> eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", ">> href=\"\\1://\\2\\3\" {$t}\">\\1://\\2\\3", $str);
>>> 
>>> ... found it in the manual i think, or maybe on weberdev.com examples
>>> 
>>> 
>>> Anyhoo, it places the whole link in between the  and ,
>>> which is
>>> fine for short links, but on longer links (in my case, around 60+
>>> chars), it
>>> messes with my table or CSS layout.
>>> 
>>> So, I'd like to subtr() the 2nd capture part down to 55 chars or
>>> something
>>> IF it's longer than 60, and append a ... to it.
>>> 
>>> ANY ideas on how this is done?  Or is this beyond regexp??
>>> 
>>> 
>>> TIA
>>> 
>>> Justin
>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 


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



Re: [PHP] substr() on part an ereg() capture

2003-03-26 Thread Marek Kilimajer
Forgot to mention this is to be run after
eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "\\1://\\2\\3", $str);
as it only replaces long strings within  tags
Marek Kilimajer wrote:

$str = preg_replace('|(]*>[^<]{55})[^<]+()|','$1...$2', $str);

Justin French wrote:

Hi, I have this ereg to turn URLs into links:

eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "\\1://\\2\\3", $str);
... found it in the manual i think, or maybe on weberdev.com examples

Anyhoo, it places the whole link in between the  and , 
which is
fine for short links, but on longer links (in my case, around 60+ 
chars), it
messes with my table or CSS layout.

So, I'd like to subtr() the 2nd capture part down to 55 chars or 
something
IF it's longer than 60, and append a ... to it.

ANY ideas on how this is done?  Or is this beyond regexp??

TIA

Justin

 





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


Re: [PHP] substr() on part an ereg() capture

2003-03-25 Thread Marek Kilimajer
$str = preg_replace('|(]*>[^<]{55})[^<]+()|','$1...$2', $str);

Justin French wrote:

Hi, I have this ereg to turn URLs into links:

eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "\\1://\\2\\3", $str);
... found it in the manual i think, or maybe on weberdev.com examples

Anyhoo, it places the whole link in between the  and , which is
fine for short links, but on longer links (in my case, around 60+ chars), it
messes with my table or CSS layout.
So, I'd like to subtr() the 2nd capture part down to 55 chars or something
IF it's longer than 60, and append a ... to it.
ANY ideas on how this is done?  Or is this beyond regexp??

TIA

Justin

 



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


RE: [PHP] substr() on part an ereg() capture

2003-03-25 Thread Boaz Yahav
Looks like this one :
http://examples.weberdev.com/get_example.php3?count=1567
so if someone manages to get this done, i would appreciate it if he can
add a comment.

thanks

berber

-Original Message-
From: Justin French [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 25, 2003 3:24 PM
To: php
Subject: [PHP] substr() on part an ereg() capture


Hi, I have this ereg to turn URLs into links:

eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "\\1://\\2\\3", $str);

... found it in the manual i think, or maybe on weberdev.com examples


Anyhoo, it places the whole link in between the  and , which
is fine for short links, but on longer links (in my case, around 60+
chars), it messes with my table or CSS layout.

So, I'd like to subtr() the 2nd capture part down to 55 chars or
something IF it's longer than 60, and append a ... to it.

ANY ideas on how this is done?  Or is this beyond regexp??


TIA

Justin


-- 
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] substr() on part an ereg() capture

2003-03-25 Thread skate
couldn't you just do substr( $blah, 0, 55)

or something similar?

(i'm crap with syntax, so that's just off my head...)


-skate-
fatcuban.com


- Original Message -
From: "Justin French" <[EMAIL PROTECTED]>
To: "php" <[EMAIL PROTECTED]>
Sent: Tuesday, March 25, 2003 1:24 PM
Subject: [PHP] substr() on part an ereg() capture


> Hi, I have this ereg to turn URLs into links:
>
> eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", " href=\"\\1://\\2\\3\" {$t}\">\\1://\\2\\3", $str);
>
> ... found it in the manual i think, or maybe on weberdev.com examples
>
>
> Anyhoo, it places the whole link in between the  and , which is
> fine for short links, but on longer links (in my case, around 60+ chars),
it
> messes with my table or CSS layout.
>
> So, I'd like to subtr() the 2nd capture part down to 55 chars or something
> IF it's longer than 60, and append a ... to it.
>
> ANY ideas on how this is done?  Or is this beyond regexp??
>
>
> TIA
>
> Justin
>
>
> --
> 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] substr() on part an ereg() capture

2003-03-25 Thread Justin French
Hi, I have this ereg to turn URLs into links:

eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", "\\1://\\2\\3", $str);

... found it in the manual i think, or maybe on weberdev.com examples


Anyhoo, it places the whole link in between the  and , which is
fine for short links, but on longer links (in my case, around 60+ chars), it
messes with my table or CSS layout.

So, I'd like to subtr() the 2nd capture part down to 55 chars or something
IF it's longer than 60, and append a ... to it.

ANY ideas on how this is done?  Or is this beyond regexp??


TIA

Justin


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



RE: [PHP] substr() help

2003-02-07 Thread Van Andel, Robbert
Try this

$temp = fgets($fp,4096);
$line = substr($temp,0,10);


Robbert van Andel 


-Original Message-
From: Paul Reilly [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 9:06 AM
To: [EMAIL PROTECTED]
Subject: [PHP] substr() help


working on a peice of code that should be pretty easy, but for some reason I
am not getting any results.

I want the first 10 characters of each line from the file I am reading and
am using this code:
$temp = str_replace("\n", "", fgets($fp, 4096));
$line = substr ($temp, 0, 5);

when I test for temp I get 30 responses - which is correct, but when I test
for $line I get Zero responses.  Did I make a mistake in my code

Paul Reilly
[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




[PHP] substr() help

2003-02-07 Thread Paul Reilly
working on a peice of code that should be pretty easy, but for some reason I
am not getting any results.

I want the first 10 characters of each line from the file I am reading and
am using this code:
$temp = str_replace("\n", "", fgets($fp, 4096));
$line = substr ($temp, 0, 5);

when I test for temp I get 30 responses - which is correct, but when I test
for $line I get Zero responses.  Did I make a mistake in my code

Paul Reilly
[EMAIL PROTECTED]




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




Re: [PHP] substr?

2002-06-18 Thread Chris Knipe

> When working with Boolean expressions in this way, deMorgan's laws often
come in handy; these state that:
>
>  !a AND !bis the same as !(a OR b)
>  !a OR !b is the same as !(a AND b)
>
> Hope this helps!!

I don't know who this deMorgan dude is, but that rule is being written down
in red on a piece of paper that's getting stuck to the bottom of my screen.
It makes perfect sense, and I can start to see where the whole "maths" thing
comes into programming now... It's actually not only a case of logic, but
very much based on maths as well (which I'm afraid isn't something I'm good
at)...

Needless to say, this helped me quite a bit... I'll try and implement it
wisely :-)

--
me



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




RE: [PHP] substr?

2002-06-18 Thread Ford, Mike [LSS]

> -Original Message-
> From: Chris Knipe [mailto:[EMAIL PROTECTED]]
> Sent: 17 June 2002 09:28
> 
> Is this right?  It seems to me that substr is working in reverse?
> 
> $string = "1234567890"; // Always numerical, always 10 chars.
> if (!substr($string, 0, -7) == "083") {
>   echo "not 083\n";
> } else {
>   // Exists here.
>   echo "is 083\n";
> }
> 
> Due to the reverse if, shouldn't it exit not 083?

But you haven't inverted the if, just the substr; the above is the same as:

  if ( (!substr($string, 0, -7)) == "083") {

which doesn't actually make a lot of sense!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, 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] substr?

2002-06-18 Thread Ford, Mike [LSS]

> -Original Message-
> From: Lazor, Ed [mailto:[EMAIL PROTECTED]]
> Sent: 17 June 2002 21:24
> To: 'Chris Knipe'; [EMAIL PROTECTED]
> Subject: RE: [PHP] substr?
> 
> 
> Here's another way of writing that code that may be easier to 
> work with:
> 
> $TestValues = array("072", "073", "082", "083", "084");
> $NumC = $substr($_POST['NumC'], 0, 3);
> if (in_array($NumC, $TestValues))
>   $FormError = "True";

And here's another:

  switch substr($_POST'NumC'], 0, 3):
  case '072':
  case '073':
  case '082':
  case '083':
  case '084':
// acceptable -- do anything appropriate here
// (even nothing, if that's what you want!)
break;
  default:
// not acceptable
$FormError = "True";
  endswitch;

Incidentally, why are you setting the variable $FormError to the string "True", rather 
than the Boolean TRUE?  You may have a perfectly ggod reason, but it looks odd to my 
eyes.  If a Boolean would be acceptable, you could also write it like this:

  $NumC = substr($_POST'NumC'], 0, 3);
  $FormError = $NumC!='072' && $NumC!='073'
   && $NumC!='082' && $NumC!='083' && $NumC!='084';

or:

  $FormError = !in_array(substr($_POST'NumC'], 0, 3),
 array('072', '073', '082', '083', '084'));

> > -Original Message-
> > From: Chris Knipe [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 17, 2002 12:19 PM
> > 
> > So what's the difference between
> >  if (!(($blah == blah) OR ($ab == ab))) {
> > and
> >  if ((!$blah == blah) OR (!$ab == ab)) {

Well, as you've written it, a hell of a lot!!  I assume you meant the second version 
to be:

   if (!($blah == blah) OR !($ab == ab)) {

> > Shouldn't they both do the same?  And if so, why didn't they 
> > in this case??

No, they absolutely shouldn't.  Think about it: the first ORs the two comparisons, and 
then takes the NOT of that; the second NOTs both comparisoons, then does the OR.  It's 
the same sort of reason why

   $x = -1 * -2;

is not the same as

   $x = -(1 * 2);

When working with Boolean expressions in this way, deMorgan's laws often come in 
handy; these state that:

 !a AND !bis the same as !(a OR b)
 !a OR !b is the same as !(a AND b)

Hope this helps!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, 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] substr....what does this mean? (newbie)

2002-05-21 Thread Scott Hurring

-1 is the index of the char number you want to examine.
http://www.php.net/manual/en/function.substr.php

So that code is checking the last char of the string
to see if its ".", if it is, it returns everything *except*
the ".".

Please consult the online manual in the future... 
it wants to be your friend.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -Original Message-
> From: r [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 22, 2002 2:51 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] substrwhat does this mean? (newbie)
> 
> 
> Hi ppl,
> Can you tell me what does this mean?
> 
> if (substr($text, -1) == ".")
> {$test = substr($text, 0, -1);}
> 
> I know the if part searches the $text from the starting for the "."
> I am just confused about what the second and third arguement 
> does in the
> substr. (Second line)
> 
> I know that this is an easy question for you PHP guys out there,
>  and I know i will get an answer,
>  so I thank you all in advance.
> 
> Cheers
> -Ryan A.
> 
> 
> -- 
> 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] substr....what does this mean? (newbie)

2002-05-21 Thread r

Hi ppl,
Can you tell me what does this mean?

if (substr($text, -1) == ".")
{$test = substr($text, 0, -1);}

I know the if part searches the $text from the starting for the "."
I am just confused about what the second and third arguement does in the
substr. (Second line)

I know that this is an easy question for you PHP guys out there,
 and I know i will get an answer,
 so I thank you all in advance.

Cheers
-Ryan A.


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




[PHP] Substr + Text + HTML - Problem

2002-02-25 Thread Sascha Ragtschaa

Hi,

I still have one problem, which seems to be not solveable in a easy and
smooth way:

I have a text file like this:

$text="This is a html extended textwhich needs to be cut after 100
chars";

Than I do a substring to limit it to only 100 words (teaser-format):

$teaser_1=substr($text, 0, 100);
$teaser_2="...[click here for more]";

The Output of $teaser_1 will sometimes be like this:
"This is a html extended textwhich needs to be cut after 100 chars is displayed as http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Substr and HTML tags - Problem...

2002-02-25 Thread Jon Haworth

> Personally when I'm doing teasers I strip all HTML from the content 
> before using substr:
> 
> $teaser = strip_tags($content);
> $teaser = substr($teaser, 0, 100);
> $teaser .= '...'; // Nice touch to have a '...' on the end :)
> 

You don't have a handy way to check that your substr() doesn't cut off
half-way through a word, do you?

I'm up against this issue myself at the moment and it's a PITA to sort out -
I keep getting things like "Fnord fnord fnord fnord fnord fno", where the
last "fnord" is missing its "rd".

It's bound to be a case of stepping back through the string until a space is
encountered, and then keeping everything to the left of that, but I haven't
worked out an elegant way to do it yet :-)


Cheers
Jon


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




AW: [PHP] Substr and HTML tags - Problem...

2002-02-25 Thread Sascha Ragtschaa

Thanks, found a way - the PHP function wordwrap does it just perfect
(recognizes the tags, too) ...

Sometimes it's just good to browse a little bit through PHP.net (*g*)

Sascha Ragtschaa




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




Re: [PHP] Substr and HTML tags - Problem...

2002-02-25 Thread Simon Willison

Sascha Ragtschaa wrote

>I need to limit a teaser-text via substr($teaser,0,100). The Problem I now
>have is, if the last 4 string chars are a html tag like  and this tag
>will be cut by the substr to something like that: webpage...
>
>How can I avoid that the html tags are cut by the substr function? Is there
>a way to make the function know, that it has to leave html tags uncut??
>
Personally when I'm doing teasers I strip all HTML from the content 
before using substr:

$teaser = strip_tags($content);
$teaser = substr($teaser, 0, 100);
$teaser .= '...'; // Nice touch to have a '...' on the end :)

I can't think of a way of keeping HTML tags but ensuring you don't cut 
off half way through one - I suppose you could do it by scanning along 
the string character by character keeping track ofwhether or not you 
have encountered a < without a matching >, then if you get to the end 
and you are half way through a tag running back to the start of the tag 
and deleting from there.


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




[PHP] Substr and HTML tags - Problem...

2002-02-25 Thread Sascha Ragtschaa

Hi,

I got a small problem:

I need to limit a teaser-text via substr($teaser,0,100). The Problem I now
have is, if the last 4 string chars are a html tag like  and this tag
will be cut by the substr to something like that: http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] substr trim functions..

2001-12-14 Thread jimtronic


There are no shortage of ways to do this.

// Using explode() ...

echo array_pop(explode(" ",$full_name));

// Using split() ...

echo array_pop(split(" ",$full_name));

// Using stristr() 

while($haystack = stristr($haystack," ")) {
$haystack = substr($haystack,1);
$last_word = $haystack;
}
echo "$last_word";

Plus all the preg_match and regular expression functions...

http://php.net/explode
http://php.net/split
http://php.net/stristr

jim

>I trying to convert some full names to last names only like:
>-get the subtext from the end until the space
>
>"joe blue" -> "blue"
>"bill western" - "western"
>
>Looked around at php.net docs but im not sure...
>
>Thanks
>
>Andras
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
Jim Musil
-
Multimedia Programmer
Nettmedia
-
212-629-0004
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] substr trim functions..

2001-12-14 Thread Nicolas Costes


$pos=strpso($line," ");
$last=substr($line, $pos, strlen($line));

http://www.php.net/manual/en/function.substr.php
http://www.php.net/manual/en/function.strpos.php
http://www.php.net/manual/en/function.strlen.php

@+++

Le Vendredi 14 Décembre 2001 17:11, Andras Kende a écrit :
> I trying to convert some full names to last names only like:
> -get the subtext from the end until the space
>
> "joe blue" -> "blue"
> "bill western" - "western"
>
> Looked around at php.net docs but im not sure...
>
> Thanks
>
> Andras

-- 
 ( * >Nicolas Costes,
 //\\  IUT de La Roche / Yon
( \/ ) [EMAIL PROTECTED]
 < <  http://luxregina.free.fr

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] substr trim functions..

2001-12-14 Thread Andras Kende

I trying to convert some full names to last names only like:
-get the subtext from the end until the space

"joe blue" -> "blue"
"bill western" - "western"

Looked around at php.net docs but im not sure... 

Thanks

Andras




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] substr() in MySQL SELECT?

2001-09-19 Thread Tom Churm

hi, don:

thanks a lot for the tip. and thanks even more for echoing the poor tone
i used in my post--i will try to avoid writing such posts in the future.
after looking at the documentation (many connection problems today), i
was able to write this, like i wanted:

SELECT User, SendDate FROM $table_name 
WHERE (Answer=0)&&( abs((SUBSTRING(SendDate, 1, 2)) - $NowDay) > 7 )

thanks again,

tom

Don Read wrote:
> 
> On 19-Sep-2001 Tom Churm wrote:
> > hi,
> >
> > could someone please tell me why this doesn't work?  i thought that
> > string functions could be used in select statements?  i dunno...
> >
> > SELECT User, SendDate FROM my_form
> > WHERE substr(SendDate, 0, 2)=19;
> >
> > and i've tried the damn thing with brackets around all different parts.
> >
> 
> Try to figure out the damn difference between PHP substr() & SQL SUBSTRING().
> 
> > thanks much,
> >
> 
> your welcome,
> --
> Don Read   [EMAIL PROTECTED]
> -- It's always darkest before the dawn. So if you are going to
>steal the neighbor's newspaper, that's the time to do it.

-- 
Tom Churm . Pixelpark AG. . . . . . . . . . . . . . . . . . .
Online Developer E-Marketing
Rotherstrasse 8 . 10245 Berlin . Germany
phone: + 49 30 5058 -1696 . fax: -1756

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] substr() in MySQL SELECT?

2001-09-19 Thread Don Read


On 19-Sep-2001 Tom Churm wrote:
> hi,
> 
> could someone please tell me why this doesn't work?  i thought that
> string functions could be used in select statements?  i dunno...
> 
> SELECT User, SendDate FROM my_form 
> WHERE substr(SendDate, 0, 2)=19;
> 
> and i've tried the damn thing with brackets around all different parts.
> 

Try to figure out the damn difference between PHP substr() & SQL SUBSTRING().

> thanks much,
> 

your welcome,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] substr() in MySQL SELECT?

2001-09-19 Thread Tom Churm

hi,

could someone please tell me why this doesn't work?  i thought that
string functions could be used in select statements?  i dunno...

SELECT User, SendDate FROM my_form 
WHERE substr(SendDate, 0, 2)=19;

and i've tried the damn thing with brackets around all different parts.

thanks much,

tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] substr question...

2001-07-27 Thread Ryan Fischer

You wrote:
> I am trying to receive file names but can't quite figure out the
proper > substr to do it:
>
> jeff.dat
> jeffrey.dat
> chris.dat
> tom.dat
>
> I want to receive the name to the left of the .dat
>
> Jeff

$file = array("jeff.dat", "jeffrey.dat", "chris.dat", "tom.dat");
for($i=0; $i\n";
}

HTH!  :)

--
 -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] substr question...

2001-07-26 Thread Jeff Lewis

RE: [PHP] substr question...I suppose that $tmpmember=substr($entry, 0,-4); will do 
the same? :)

Jeff
  - Original Message - 
  From: Boget, Chris 
  To: 'Jeff Lewis' ; [EMAIL PROTECTED] 
  Sent: Thursday, July 26, 2001 3:54 PM
  Subject: RE: [PHP] substr question...


  > I am trying to receive file names but can't quite figure out 
  > the proper substr to do it: 
  > jeff.dat 
  > jeffrey.dat 
  > chris.dat 
  > tom.dat 
  > I want to receive the name to the left of the .dat 

  $fileName = eregi_replace( "\.dat", "", $fullFileName ); 

  Chris 




RE: [PHP] substr question...

2001-07-26 Thread Boget, Chris

> I am trying to receive file names but can't quite figure out 
> the proper substr to do it:
> jeff.dat
> jeffrey.dat
> chris.dat
> tom.dat
> I want to receive the name to the left of the .dat

$fileName = eregi_replace( "\.dat", "", $fullFileName );

Chris



Re: [PHP] substr question...

2001-07-26 Thread Unni

try

$filename=explode(".", names);
echo $filename[0]

Jeff Lewis wrote:

> I am trying to receive file names but can't quite figure out the proper substr to do 
>it:
> 
> jeff.dat
> jeffrey.dat
> chris.dat
> tom.dat
> 
> I want to receive the name to the left of the .dat
> 
> Jeff
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] substr question...

2001-07-26 Thread Jeff Lewis

I am trying to receive file names but can't quite figure out the proper substr to do 
it:

jeff.dat
jeffrey.dat
chris.dat
tom.dat

I want to receive the name to the left of the .dat

Jeff