[PHP] String Length ??

2004-03-22 Thread gordon stewart

Hi there

I'm new to PHP (as some may know)...

ive spotted / Found the answers to 2-3 problems
tonight - By looking through the PHP documentation..
but this problem is perplexing..


Ok - Ive got a FORM - Which basically, I put lots of
text into it (For testing purposes, I go to news
websites  copy entire articles).

The PHP script chops up the paragraphs - into one long
line of text (one line per paragraph..),  its in an
array $text.

Ok - I loop through the array,  all the text is how
it should be - displaying properly..

PROBLEM :-

Now - All I want to know - Is how long each line is -
(eg number of characters - Ive already removed
double-spaces  its now single-spacing (if any)..)

EG - Is a line 34 characters long, 127, 945 ? 

Ive looked through the PHP 'Functions'  the PHP
'documentation' for length (couldnt find anything..
??)

Ive found this command :-

http://nz2.php.net/strlen

Which seems perfectly fine...

Ive got this code (without the === signs)

===
foreach ($text as $color) {
   echo SAF '$color' - ;
echo B.strlen($color)./BBR\n;
}
===

the SAF is only for my reference - See it on the
screen..


QUESTION :-

Is this the right code to use ? to find the length of
each line ? ($color)   - No worries - Ive just copied
code from the web..)

PROBLEM :-

It looks fine - EXCEPT when I see a 3-line paragraph -
 the PHP code is telling me its over 1,200 characters
long..

(assuming  80 characters per line, 100 AT MAXIMUM) -
thats only 240 -300 characters... 

If the paragraph were 1200 characters - That would
need 8-10 lines of text...

So - Im asking here (see above)... - If Ive got the
correct code / Command...


Thanks for the help...

G


__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



Re: [PHP] String Length ??

2004-03-22 Thread gordon stewart

--- Filip de Waard [EMAIL PROTECTED] wrote:
 strlen() is the correct function to use here. Use it
 like:
 
 echo strlen($_POST['input_name']);

Thanks...

 Where $_POST['input_name'] should be replaced by the
 variable you want 
 to check. strlen() is always right, but it counts
 the actual charactars 
 of the string (which may differ from those who are
 shown in the 
 browser, please look at the HTML source instead).

Ok - Will do... 

 Secondly, please use lowercase for HTML tags and use
 br / instead of 
 BR...

Hmm - why br / ???

Is that PHP code - or HTML code ? - Ive seen it around
a few places - But havnt bothered to ask (till now)

- Or is there a 'hidden' process that PHP
 uses the  /  for ??

- Ok - Off to look at HTML source, then off to bed...

Thanks

G


__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



[PHP] Thanks : Re: [PHP] String Length ??

2004-03-22 Thread gordon stewart

--- Filip de Waard [EMAIL PROTECTED] wrote:
 strlen() is the correct function to use here. Use it
 like:
 
 echo strlen($_POST['input_name']);
 
 Where $_POST['input_name'] should be replaced by the
 variable you want 
 to check. strlen() is always right, but it counts
 the actual charactars 
 of the string (which may differ from those who are
 shown in the 
 browser, please look at the HTML source instead).

Thanks - Yep - Lots of spaces in  my output...

Ive added a small regex  its got rid of the lines :)

$pattern = /\s+/i;
$replacement =  ;
$texta= preg_replace($pattern, $replacement, $texta);

G



__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



[PHP] Apache - PHP Load-n-Go ?

2004-03-20 Thread gordon stewart

Hi there

About 12 months ago, - (on an old PC), I ran Apache, 
installed PHP.. (I dont remember any hastles at the
time..)

Anyway, I havnt used PHP much - (didnt need to..)

- I have a new PC now -  loaded Apache onto it (a
test server, before I upload to main 24/7
website/server)

Its 3:30 a.m. on Sunday now -  all Friday night  Sat
Night - Ive been trying to instal PHP  make it Go

However, - Its not..

CURRENT SITUATION :-

Ive installed a new PHP (on my Win 98 system)..
 when I go into http://localhost/index.php - it asks
me what I'll like to do with it...

- I say to open in I.E. - However its as of c:\etc..
etc.. etc\index.php 

It wont open it in the actual browser / website...

SUGGEST

Can anyone suggest a Beginners guide - Step-by-step
guide to installing PHP with Apache ?

PS

When I run PHP via a DOS PROMPT - I can put php -v 
it tells me the version number  etc (its in the PATH
statement)...


Thankyou

G


=
New Zealand Online Communities Group.
[EMAIL PROTECTED]  or http://nzocg.kwister.com/
Spam free communities

__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



[PHP] PS : [PHP] Apache - PHP Load-n-Go ? : FIXED

2004-03-20 Thread gordon stewart

Sorry for the new thread - I deleted my old email
(thread ID)...

http://marc.theaimsgroup.com/?l=php-generalm=107979353616896w=2

Basically : FIXED


I went to the website :-   on the 3rd-4th screen :-

http://www.webmasterstop.com/tutorials/apache-php-mysql-installation3.shtml

I found MY answer..

I didnt have the ScriptAlias /php/ c:/php/  set up
correctly..

The 3 lines I needed (without the dashes) are :-

===
ScriptAlias /php/ c:/php/

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

Action application/x-httpd-php /php/php.exe 
===

I went to my localhost  now I've got PHP going...

G


__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



[PHP] This Group....

2004-03-20 Thread gordon stewart

Hi there

Got PHP going :)

- ok - Is this the correct group to ask ? 
Or can anyone suggest another group / forum for newbie
how-to questions..

BASICALLY :- Ive been programming in HTML / CGI (Perl)
for several years,  have only 'briefly' done PHP..

- At work, Someone wants one of my CGI scripts to
convert to PHP... 

Ive only discovered this forum a few hours ago - 
have for the last 2 days/nights been trying to figure
out how to get PHP going / running (on my home
server)..
(its Sunday Morning here)...

Anyways,

Can someone point me in the right direction to some
tutorials (  *EXAMPLES* ) to do the following
functions (or point mer to an appropriate forum - see
above)..

:- Open a file  insert into an array/variable. (im
trying to figure that one out now - get file-open
errors)..

( close / flock etc... - not sure if flocking is on
PHP ?)

:- turn a variable (split it) into an array..

:- Loop through an array -  display a line IF it
matches another variable etc..

I think those 3 things are good starting points - I
think I'll learn fast - But just need pointers to the
usage / PHP commands - That I know I can do in Perl..


Thanks

G


__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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



[PHP] Getting values

2002-04-09 Thread Gordon Stewart

http://kwister.dns2go.com/php/4.php?action=tablesdatabase=mysqltable=user

http://kwister.dns2go.com/php/4.txt

Hi - I'm online for next few hours (I'll upload to a non PHP server when i
go offline)

basically ive had help,  fixed my script to show 4 rows of 17 columns each
(Instead of 1 row of 1000 columns ;-)

Now - Ive tried the mysql_fetch_field()   the mysql_field_seek(). commands

http://www.php.net/manual/en/function.mysql-fetch-field.php

However in the example - the person KNOWS the names of the columns  eg...

blob: $meta-blob
max_length:   $meta-max_length
multiple_key: $meta-multiple_key
name: $meta-name


BUT - How do i 'retrieve' thevalues of the table if I DONT know the name of
each column..

Eg.. If i want to see Column 7,  Row 5, - the value is 3.

Column 3 row 2 = Fred etc...

How can i do this ?

G.




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




[PHP] Re: cookie sharing between asp and php

2002-04-09 Thread Gordon Stewart


Scott St. John [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I have developed a security application for our intranet that handles a
 user login.  It writes values to a cookie and uses that to verify them on
 the intranet sites until the sessions expire.

 Since we have not totally moved over to PHP I have some ASP applications I
 need to protect as well.
 Q1-I feel dump for asking this, but ASP can't read the PHP cookies,
 correct?

 My current solution might be to pass a variable from the php page to the
 asp page and have it write it's own set of cookies.

As far as I know - ALL cookies set by a particular server - can be read 
re-set by any programme / process on the same server / website..

So your ASP script could read your PHP cookies  vice-versa..

I'm just learning PHP,  dont know cookies as yet (I use Perl/CGI for
cookies)
 have no experience at all on ASP...

I'll suggest to try a small PHP  a small ASP page,  try  set/read the
cookies.

G.




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




[PHP] Sub groups ? - Programming structure...

2002-04-09 Thread Gordon Stewart

Hello, - I'm used (in years gone by) to the Qbasic programme, where i can
create 'sub' routines,  view each routine on its own - Without reference /
Viewing the other code.. (I think its good like that..)..

I know in CGI/Perl - you can use sub-routines etc...

1) Does PHP allow sub-routines,  eg - I can send values to the routine,  it
processes it  does whatever it requires  returns to the spot where I
called it from.

2) For those of you that know Qbasic  know what i mean, is/are there any
programmes out there that can allow you to view / see any sub-routines in
Perl and/or PHP one at a time,  list them ..

(I hope so) - Good, but not necessary..

G.
(time for bed).




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




[PHP] New User of PHp/Mysql..

2002-04-07 Thread Gordon Stewart

Ive been using Mysql/PHP for a short while - I sent this messaghe to a big
PHP group (not enough users though)  about a week ago - No reply...

Can anyone help..
PS - Slingshot.co.nz doesnt have PHP - its just a text file.. - Save to your
own  SQL server  test, Or just review the code - No viruses or anything..

Thanks.

G.
[EMAIL PROTECTED]

-



http://homepages.slingshot.co.nz/~gordon52/4.txt

Ive been learning MySql for about 1 week now -  joined a MySql
group - but some questions I ask are more PHP related  not directly
involving MySQL..

anyway, for my big test script, Ive got the above URL

Just 'view source' to view the PHP scripting language...

when running, it searches your databases  brings up a list of active
databases.

When selected, it brings up a list of tables within the database..

(those two functions are ok..)

Now - in the script, - near the top, it says :-

if ($action =='tables'){  (start of problem area..)

Now - when you select the table, it displays all the names of each
column, within the table. (that part works..)


it has :- $tot=$i; - $tot now holds the number of columns in that
table - For my example on my PC, it held the number '17' which is
correct.


it now has 2 'loops'...

a) for ($count = 1; $row = mysql_fetch_row ($query_result_handle);
++$count)

b) for ($counta = 1; $tot; ++$counta)

Loop a, loops through the 4 rows of the database.

Loop B, displays all (17) of the colmns for each row...


Now - Problems

1) When my script runs, it is VERY fast - Doing things normally.
- EXCEPT - when it comes to the 2 loops.. - it goes Very slow - I
realise its got to do 2 sets of loops - but its going at a much
slower rate than if i did the same loops, on another programming
language.

2) It only displays the 1st row of my data.. - For the example
database i tested, I knew it had 4 rows.

problem questions :-

a) Is my looping correct - Or can anyone find a loop-hole / problem
in my programming. (Im not telling you if the pun was intentional or
not.)


PS - Ive now realised something,  changed my line from :-

for ($counta = 1; $tot; ++$counta)

to

for ($counta = 1; $row = mysql_fetch_row ($query_result_handle);
++$counta)


- now my script is really fast - However it doesnt show much of the
1st line of data :-(

PS, the uploaded one (URL above) - doesnt show the change - as yet..

Can anyone advise what im doing wrong ?

G.









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




Re: [PHP] Phone number validation

2002-04-07 Thread Gordon Stewart


Richard Baskett [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 What I do is strip all non-numeric numbers out and just store the number
as
 a string of numbers.. Then do validation on those numbers.. Make sure the
 right amount of numbers are there, valid country, city codes etc.
Probably
 an easier approach :)

Just as a curiosity - (I dont need / Want it now - Maybe later)

Where / what site, can we get a list of the valid country/city codes ?

G.




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




[PHP] Mail Attachments

2002-01-24 Thread Gordon Stewart

Dear List

I have just compleated a PHP web frontend to the standard mail function in
PHP.  I have got it to send and recieve email.

Can I take this programming task further and allow it to send and recieve
attachments. My script runs on a redhat 7 box.

Can anyone help?  How can i achieve this?

Gordon


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