Re: [PHP] Regexp help (simple)

2004-01-20 Thread Dagfinn Reiersøl
[EMAIL PROTECTED] wrote:

$string = 'ab12345-1';
if (preg_match('/^([a-zåäö]{2,3})([0-9]{4,5}(\-[0-9]{1,2}){0,1})$/i',
$string,
$m='')) {
  echo $m[1]; // - ab
  echo $m[2]; // - 12345-1
}
g. martin luethi
 

You can replace {0,1} with a question mark and [0-9] with \d (digit). 
Also, and I
think this is not in the PHP documentation, you can use POSIX character 
classes
inside the brackets. If you want to match alphabetical characters including
the Swedish and various other international ones like æ or ü, you can 
use [:alpha:].
You may not need it in this example, but it's excellent for 
internationalized regex matching.

if (preg_match('/^([[:alpha:]]{2,3})(\d{4,5}(\-\d{1,2})?)$/i',

Tue, 20 Jan 2004 09:59:37 +0100 Victor Spång Arthursson [EMAIL PROTECTED]:

 

Hi!

Anyone who could help me with this regexp problem?

I want to verify that a string is made up of 2-3 letters, (a-z + åäö,
A-Z + ÅÖÄ), directly followed by 4 or 5 digits, which could, but may
not, be followed by a minus and one or two digits.
Examples of valid strings:

abc12345
ABC12345
abc1234
ABC12345-1
ABC12345-01
I would also like to split them into an array consisting of 2 elements;

[0] = the first 2 or 3 letters
[1] = the rest
Example:

string = ab12345
[0] = ab
[1] = 12345
string = åäö1234-66
[0] = åäö
[1] = 1234-66
Lots of thanks in advance,

sincerely

Victor
--
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] hello to making the php pages

2004-01-20 Thread Dagfinn Reiersøl

echo Welcome to my homepage Mom. See my brand new wife!:


You must echo out what happened to your old wife before you send new 
wife to the brower.
If he kept the old wife, he needs to talk to both wives. If not, 
replacing the colon with a semicolon might help.


I have problem with PHP Codes from above. Where to fix Codes?


Joe's garage and PHP service station.  They have specials on Friday's.

;)

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


Re: [PHP] Using PHP with Style Sheets

2004-01-19 Thread Dagfinn Reiersøl
Freedomware wrote:

Sorry but you haven't really stumbled onto a pot of gold here or
anything.
Hmmm... it sounds like using PHP with style sheets isn't a recommended 
practice.
I wouldn't do it unless I had a good reason to do it. The reason that's 
cited on the page you referred to
is to have different code in Netscape 4 and real browsers. So if you 
have a real need to make pages
pages to look gorgeous in Netscape 4, you might consider it. Or if you 
want to do
pathologically ;-) advanced and flexible things with styles. Plain CSS 
is flexible enough for me most
of the time, but it's a good idea to learn it properly.



John Nichel wrote:

If you want PHP to parse your *.css files, you need to tell your 
webserver software to do so.  In Apache

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


But I'd like to give it a try. Thanks for the tips.

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


Re: [PHP] Syntax Error - This is WEIRD!

2004-01-16 Thread Dagfinn Reiersøl
Nick Wilson wrote:

if a script calls antohter like 'include('http://site.com/index.php');

Why would I get a syntax error on line 1 of index.php when it looks like
this:
?php
// line one above this one
What's the deal there?

Many thanks for any insight ;-)
 

I've never tried to do an include via HTTP, so maybe I'm clueless, but
it occurs to me that it might be a good idea to try doing a plain old
file include, using exactly the same file. I have the feeling it would
be interesting to know whether that would work or not.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Syntax Error - This is WEIRD!

2004-01-16 Thread Dagfinn Reiersøl
Donald Tyler wrote:

Yes that is true. But I would strongly recommend against doing that.

You should never include anything over HTTP. Its extremely messy, 100%
insecure and just a very very bad idea.
 

My spontaneous reaction is to agree with you. On the other hand, are 
SOAP or XML-RPC over
HTTP any more secure in principle? You would need some kind of 
authentication, of course,
unless you just love exposing your code.

It's a weird concept, but I was trying to give the guy who started the 
thread the benefit of the doubt. Maybe
he has a good reason for doing it. Maybe the people who implemented this 
feature in PHP had a good reason for
implementing it.

You should have all the files you need to include located on your web
server.
 

Yes, I don't know why you would want to keep them on a remote server.

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


Re: [PHP] SOLVED= is ' or different in MS-Word then ascII?

2004-01-15 Thread Dagfinn Reiersøl
Roger Spears wrote:

Hello Everybody,

I have found a solution and/or the root of the problem.  I googled on 
the topic of MS-Word + smart quotes.

That lead me to this site:
http://www.rpgtimes.net/rpgtimes/guide.php?guide=1
It seems that the default for Word is to have smart quotes to on. 
When you have smart quotes on it replaces the ordinary straight 
quotes with a left specific and right specific quote.

To correct this:
Go into TOOLSAUTO-CORRECTAUTO-FORMATremove checkmark from replace 
straight quotes with smart quotes.  Also in TOOLSAUTO-CORRECT you 
must remove the line in AUTO-REPLACE about replacing ... with three 
dots that are closer together.

Once I did that, my problem was solved  Thanks to all who have 
helped today.  I appreaciate it!!
I'm happy for you :-), but didn't you say you were taking input from
visitors? Can you force them to turn smart quotes off?
To me it looks like you're pointing out a general problem that anyone
might run into: visitors may copy characters into a Web
form that are not entirely safe to display in an HTML page. That would
be anything except plain ASCII. That would include
smart quotes and a lot of accented letters that don't normally occur in
English. I haven't thought this through before, but I think
the safest thing to do would be to replace thos characters with their
HTML entity equivalents at some point before you display them.
For the smart quotes, the entities would be lsquo; rsqou; ldquo; and
rdquo;
Of course, you could replace them with dumb quotes instead, but the
smart quotes look better. That's why MS word and other word
processors do what they do.
BEFORE I changed these two Word settings, when writing to the 
database, the ord() (ordinate) value for the left quote was 147 and 
the right quote was 148.  When being retrieved from the database, the 
ord() (ordinate) value for the left quote was 17 and the right quote 
was 19.

Thanks again to everyone who offered help!

Roger

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


Re: [PHP][PEAR] PEAR::DB_Common::nextId()

2004-01-15 Thread Dagfinn Reiersøl
Alessandro Vitale wrote:

I would like to get the last insert id... anyone has some experience in
using the PEAR::DB_Common::nextId() ?
 

Yes. You have a PEAR DB object $db, and you do:

$id = $db-nextID('Documents');
$db-query(INSERT INTO Documents (id,title,text) VALUES
($id,'Title','Text'));
The confusing thing about this is the fact that Documents in the two
lines don't necessarily have anything to do
with each other. The first is the name of a sequence, the other is the
name of a table. They're just both called
'Documents'. What happens, and I believe this isn't described in the
documentation, is that PEAR DB stores
the current ID of the Documents sequence in a separate table called
Documents_seq:
mysql select * from Documents_seq;
+-+
| id  |
+-+
| 200 |
+-+
So it's a completely different mechanism than using mysql_insert_id().

In fact, it might be a better idea to have just one sequence and
generate IDs for all tables from that:
$id = $db-nextID('Sequence');
$db-query(INSERT INTO Documents (id,title,text) VALUES
($id,'Title','Text'));
$id = $db-nextID('Sequence');
$db-query(INSERT INTO Users (id,username...) VALUES ($id,$username...));
any suggestion would be very much appreciated.

alessandro

 

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


Re: [PHP] is ' or different in MS-Word then ascII?

2004-01-14 Thread Dagfinn Reiersøl
Roger Spears wrote:

Marek Kilimajer wrote:
 I don't know what the character is but if you paste it into the
 textarea, ord() will tell you.

When I run ord(), it returns the value of 19.  I'm guessing that is a 
hex value.  And when I look that up on the ascII table, it says:
19 DC3 (Device Control 3)

For some reason when it retrieves the CLOB from the database it is 
converting any  that were created with MS-Word into this DC3 character.
According to the table at:

http://www.bbsinc.com/iso8859.html

the start quote character in the Windows Latin-1 character set is hex 93
= hex 80 + 13 = decimal 128 + 19. So it seems the 8-bit character has
lost its highest bit and become a 7-bit character.
Strange indeed
Stranger things have happened...

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