[PHP] Sigh....regex - need to search/replace string for anything but numbers

2005-01-25 Thread Matt Babineau
Ahh so the regex gods are pissed at me. This is simple (I think), but I need
to figure out how to strip out everything in a string that is not a number.
Any takers?

Thanks,

Matt Babineau
Criticalcode
w: http://www.criticalcode.com
p: 858.733.0160
e: [EMAIL PROTECTED]



Re: [PHP] Sigh....regex - need to search/replace string for anything but numbers

2005-01-25 Thread Rick Fletcher
Matt Babineau wrote:
Ahh so the regex gods are pissed at me. This is simple (I think), but I need
to figure out how to strip out everything in a string that is not a number.
Any takers?
I appear to have written that last snippet without really even looking 
at it.  This one works.

?php
$string = asd98.a98asd/7987asd;
$numbers = preg_replace( /[^0-9]/, , $string );
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Sigh....regex - need to search/replace string for anything but numbers

2005-01-25 Thread Rick Fletcher
Matt Babineau wrote:
Ahh so the regex gods are pissed at me. This is simple (I think), but I need
to figure out how to strip out everything in a string that is not a number.
Any takers?
?php
$string = asd98.a98asd/7987asd;
$numberless = preg_replace_all( /[^0-9]/, , $string );
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Sigh :)

2002-12-06 Thread Ford, Mike [LSS]
OK, I think I've solved this, and you'll probably kick yourself when I explain it!  
But first, a teaser:  what looks like a double-quote in HTML, but isn't?

-Original Message-
From: John Taylor-Johnston

 If I run the SQL in PHPMyAdmin, (a MySQL web interface), it works.
 
 jdaxell.ccl = 2 records found.
 
 SELECT id,AU,ST,BT,AT FROM ccl_main WHERE MATCH
 (TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO)
 AGAINST ('ready maria' IN BOOLEAN MODE)
 ORDER BY id asc
 
 But try to pass it through PHP - zippo. MySQL thinks it is a boolean
 search for
 +ready +maria
 not an exact search for the two words together
 
 ready maria
 
 MySQL does not see the double quotes. It should. Somehow, PHP is
 thwarting them?

Not PHP, your browser, I suspect.  In fact there are no quotes there!  No, donm't yell 
at me, there really aren't!!

Close inspection of the source of your non-working result reveals that what it has 
actually searched for is quot;ready mariaquot; -- which, of course, displays on the 
screen as ready maria, with the HTML quot; entities converted to double quotes!  Of 
course, as the $search variable actually contains the version with the quot; 
entities, this is what MySQL sees, and duly regards it as a non-quoted string 
contining the words quot, ready and maria, and a few non-significant punctuation marks!

What I think is happening is that your browser is encoding certain characters in the 
form field into HTML entities before submitting them -- so to get PHP to see them 
correctly, you're going to need to unencode any HTML-entities in the string in your 
$search variable.  I suggest a quick visit to the manual page for html_entity_decode 
(http://www.php.net/html-entity-decode) may be in order (this function is not 
available until PHP 4.3.0, but the manual page does give a pre-4.3.0 alternative).

(Of course, don't forget to keep the HTML-entities version for echoing back to your 
HTML results page!)

This was a neat one -- hope this analysis helps!

Cheers!

Mike

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




Re: [PHP] Sigh :)

2002-12-06 Thread 1LT John W. Holmes
 OK, I think I've solved this, and you'll probably kick yourself when I
explain it!  But first, a teaser:  what looks like a double-quote in HTML,
but isn't?

Hey, if that's it, I get a free kick, too. I suggested that a while ago but
there was no response.

---John Holmes...


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




[PHP] Sigh :)

2002-12-04 Thread John Taylor-Johnston
Hi,

Can someone take a look at this again, please?

http://news.php.net/article.php?group=php.generalarticle=126934

Your posts so far have proven fruitless. Thanks for trying. :) I do appreciate it.

I will try to answer everyone at the same time.

Someone mentionned it might be a problem with magic_quotes, but I didn't really follow.

http://news.php.net/article.php?group=php.generalarticle=126990

I did test what he suggested:

From John Holmes
 try this

Doesn't work. :) Thanks. I did try:

$sql = SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST ('.$search.' IN 
BOOLEAN MODE) ORDER BY id asc;

It echos:

('\ready maria\' IN BOOLEAN MODE)

It should echo:

('ready maria' IN BOOLEAN MODE)

for it to work. But even if I add slashquotes, it won't do it.

--
could you get the error message with mysql_error() and post it here?

There is no error. I wish there was :) Thanks for trying.

Doesn't work - Resembles +ready +maria
hmm - how do you get your string ready maria?

input name=search

why '.$table.' and not '.$table.'
with what you've got now, I believe you are looking for table name.

Good idea. Done that. Doesn't change . :) Thanks.

also, use double quotes for start and end of variables as in:
$sql=select * from '.$table.' where var='some
value other than a number' ;

Doesn't work. :) Thanks.

John


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




Re: [PHP] Sigh :)

2002-12-04 Thread Ray Hunter
Which version of mysql are you using?

--
Ray

On Wed, 2002-12-04 at 10:33, John Taylor-Johnston wrote:
 Hi,
 
 Can someone take a look at this again, please?
 
 http://news.php.net/article.php?group=php.generalarticle=126934
 
 Your posts so far have proven fruitless. Thanks for trying. :) I do appreciate it.
 
 I will try to answer everyone at the same time.
 
 Someone mentionned it might be a problem with magic_quotes, but I didn't really 
follow.
 
 http://news.php.net/article.php?group=php.generalarticle=126990
 
 I did test what he suggested:
 
 From John Holmes
  try this
 
 Doesn't work. :) Thanks. I did try:
 
 $sql = SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST ('.$search.' IN 
BOOLEAN MODE) ORDER BY id asc;
 
 It echos:
 
 ('\ready maria\' IN BOOLEAN MODE)
 
 It should echo:
 
 ('ready maria' IN BOOLEAN MODE)
 
 for it to work. But even if I add slashquotes, it won't do it.
 
 
--
 could you get the error message with mysql_error() and post it here?
 
 There is no error. I wish there was :) Thanks for trying.
 
 Doesn't work - Resembles +ready +maria
 hmm - how do you get your string ready maria?
 
 input name=search
 
 why '.$table.' and not '.$table.'
 with what you've got now, I believe you are looking for table name.
 
 Good idea. Done that. Doesn't change . :) Thanks.
 
 also, use double quotes for start and end of variables as in:
 $sql=select * from '.$table.' where var='some
 value other than a number' ;
 
 Doesn't work. :) Thanks.
 
 John


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




RE: [PHP] Sigh :)

2002-12-04 Thread Van Andel, Robert
One question that comes up is why are you putting the double quotes around the search 
string ready maria?  Should there be an entry in the database that includes the double 
quotes.  Right now that is what your sql statement is looking for.  So an entry like 
this

Are you ready maria?

Would not be found but an entry like

The book ready maria is great

Would return something.



Robbert van Andel 


-Original Message-
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 9:33 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Sigh :)


Hi,

Can someone take a look at this again, please?

http://news.php.net/article.php?group=php.generalarticle=126934

Your posts so far have proven fruitless. Thanks for trying. :) I do appreciate it.

I will try to answer everyone at the same time.

Someone mentionned it might be a problem with magic_quotes, but I didn't really follow.

http://news.php.net/article.php?group=php.generalarticle=126990

I did test what he suggested:

From John Holmes
 try this

Doesn't work. :) Thanks. I did try:

$sql = SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST ('.$search.' IN 
BOOLEAN MODE) ORDER BY id asc;

It echos:

('\ready maria\' IN BOOLEAN MODE)

It should echo:

('ready maria' IN BOOLEAN MODE)

for it to work. But even if I add slashquotes, it won't do it.

--
could you get the error message with mysql_error() and post it here?

There is no error. I wish there was :) Thanks for trying.

Doesn't work - Resembles +ready +maria
hmm - how do you get your string ready maria?

input name=search

why '.$table.' and not '.$table.'
with what you've got now, I believe you are looking for table name.

Good idea. Done that. Doesn't change . :) Thanks.

also, use double quotes for start and end of variables as in:
$sql=select * from '.$table.' where var='some
value other than a number' ;

Doesn't work. :) Thanks.

John


-- 
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] Sigh :)

2002-12-04 Thread John Taylor-Johnston
Hi,
I'm searching for an exact match of ready maria. So I'm using the double quotes to 
demarcate the exact search, as per MySQL rules. I'm not searching for the double 
quotes.
John


Van Andel wrote:

 One question that comes up is why are you putting the double quotes around the 
search string ready maria?  Should there be an entry in the database that includes 
the double quotes.  Right now that is what your sql statement is looking for.  So an 
entry like this

 Are you ready maria?

 Would not be found but an entry like

 The book ready maria is great

 Would return something.

 Robbert van Andel

 -Original Message-
 From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 9:33 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Sigh :)

 Hi,

 Can someone take a look at this again, please?

 http://news.php.net/article.php?group=php.generalarticle=126934

 Your posts so far have proven fruitless. Thanks for trying. :) I do appreciate it.

 I will try to answer everyone at the same time.

 Someone mentionned it might be a problem with magic_quotes, but I didn't really 
follow.

 http://news.php.net/article.php?group=php.generalarticle=126990

 I did test what he suggested:

 From John Holmes
  try this

 Doesn't work. :) Thanks. I did try:

 $sql = SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST ('.$search.' IN 
BOOLEAN MODE) ORDER BY id asc;

 It echos:

 ('\ready maria\' IN BOOLEAN MODE)

 It should echo:

 ('ready maria' IN BOOLEAN MODE)

 for it to work. But even if I add slashquotes, it won't do it.

 
--
 could you get the error message with mysql_error() and post it here?

 There is no error. I wish there was :) Thanks for trying.

 Doesn't work - Resembles +ready +maria
 hmm - how do you get your string ready maria?

 input name=search

 why '.$table.' and not '.$table.'
 with what you've got now, I believe you are looking for table name.

 Good idea. Done that. Doesn't change . :) Thanks.

 also, use double quotes for start and end of variables as in:
 $sql=select * from '.$table.' where var='some
 value other than a number' ;

 Doesn't work. :) Thanks.



Re: [PHP] Sigh :)

2002-12-04 Thread John Taylor-Johnston
Ray,

I admit, it is a newer function in MySQL:

http://www.mysql.com/doc/en/Fulltext_Search.html

Since MySQL 3.23.23. All you need is a fulltext index.

I am using, however, MySQL 4.0.5-beta-max-debug, but had the same problem in previous 
verisons. I have just never gottent his double quotes thing to work.

If I run the SQL in PHPMyAdmin, (a MySQL web interface), it works.

jdaxell.ccl = 2 records found.

SELECT id,AU,ST,BT,AT FROM ccl_main WHERE MATCH
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO)
AGAINST ('ready maria' IN BOOLEAN MODE)
ORDER BY id asc

But try to pass it through PHP - zippo. MySQL thinks it is a boolean search for
+ready +maria
not an exact search for the two words together
ready maria

MySQL does not see the double quotes. It should. Somehow, PHP is thwarting them?

This works:
http://ccl.flsh.usherb.ca/print/print.html?search=%26quot%3Bready+maria%26quot%3B
http://ccl.flsh.usherb.ca/print/display.test.inc.phps


This doesn't:
http://ccl.flsh.usherb.ca/print/index.html?search=%26quot%3Bready+maria%26quot%3B
http://ccl.flsh.usherb.ca/print/display.table.inc.phps

I've tried every combination of syntax I know. This should but doesn't do the trick:

$sql = 'SELECT id,AU,ST,BT,AT FROM '.$table.' WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO)
AGAINST (\''.stripslashes($search).'\' IN BOOLEAN MODE) ORDER BY id asc';


John

Ray Hunter wrote:

 Which version of mysql are you using?

 --
 Ray

 On Wed, 2002-12-04 at 10:33, John Taylor-Johnston wrote:
  Hi,
 
  Can someone take a look at this again, please?
 
  http://news.php.net/article.php?group=php.generalarticle=126934
 
  Your posts so far have proven fruitless. Thanks for trying. :) I do appreciate it.
 
  I will try to answer everyone at the same time.
 
  Someone mentionned it might be a problem with magic_quotes, but I didn't really 
follow.
 
  http://news.php.net/article.php?group=php.generalarticle=126990
 
  I did test what he suggested:
 
  From John Holmes
   try this
 
  Doesn't work. :) Thanks. I did try:
 
  $sql = SELECT id,AU,ST,BT,AT FROM $table WHERE MATCH 
(TNum,YR,AU,ST,SD,BT,BC,AT,PL,PR,PG,LG,AUS,KW,GEO,AN,RB,CO) AGAINST ('.$search.' IN 
BOOLEAN MODE) ORDER BY id asc;
 
  It echos:
 
  ('\ready maria\' IN BOOLEAN MODE)
 
  It should echo:
 
  ('ready maria' IN BOOLEAN MODE)
 
  for it to work. But even if I add slashquotes, it won't do it.
 
  
--
  could you get the error message with mysql_error() and post it here?
 
  There is no error. I wish there was :) Thanks for trying.
 
  Doesn't work - Resembles +ready +maria
  hmm - how do you get your string ready maria?
 
  input name=search
 
  why '.$table.' and not '.$table.'
  with what you've got now, I believe you are looking for table name.
 
  Good idea. Done that. Doesn't change . :) Thanks.
 
  also, use double quotes for start and end of variables as in:
  $sql=select * from '.$table.' where var='some
  value other than a number' ;
 
  Doesn't work. :) Thanks.
 
  John

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




Re: [PHP] sigh... forms

2002-07-11 Thread Richard Lynch

Speaking of forms, and I'm sure lots have asked this before me, but anyone
know anywhere I can go to see some examples or existing code for
automatically generating and and validating dynamic forms?  

Wait though, I'm already doing this myself.  To explain further, what I
really want is an abstract set of php functions to say, ok, I want another
form with say 10 questions, and I want to define each question and set of
possible answers (input types and ranges) manually, and have the action
script automatically check that the input types and ranges for each question
are valid.

hforms (not that many 'o's but more than one) inside of PHPLib does
this, I think...

Or are PHPLib and oforms competitors?

Whatever.

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




Re: [PHP] sigh... forms

2002-07-10 Thread Chris Earle

I don't have time to actually make the function for you, but I know it could
be easily done with a single function and a double for loop, which could go
through an two-dimensional array of the questions (first element), answers
(next group except last), and the right answer (last element).

basically:

$ArrCount = count($Question);

for ($Counter = 0; $Counter  $ArrCount; $Counter++)
{
$Que = $Question[$Counter][0];
$SecArrCount = count($Question[$Counter]);
// SecArrCount should be the number equal to the last element (answer)
?SCRIPT LANGUAGE=Javascriptfunction CheckAnswer() {var RightAnswer
= $Question[$Counter][$SecArrCount]; }/SCRIPT?
for ($AnsCount = 1; $AnsCount  SecArrCount; $AnsCount++):
?!--Write the HTML code with the PHP variables
($Question[$Counter][$AnsCount]) placed where they're needed--?
endfor;
$AnsCount++;
}

The other loop would then generate a table row kind of like this:

TRTD
SCRIPT LANGUAGE=Javascript...
function CheckAnswer(str)
{
var Answer = ?=$Question[$Counter][$LastElementNum]?
if (
}
/SCRIPT...
$Question[$Counter][0]..BR..INPUT.. onChange=CheckAnswer(this.value)
or SELECT..options...
onClick=CheckAnswer(this.value)/SELECT../TD../TR..

I didn't check to see if any of that stuff worked, but it should give you a
basic idea of what I mean.


In response to one of your e-mails to me (for some reason I cannot send
e-mail right now, but I can post in here): RE: [PHP] Generating word
documents based on fields in a browser

I would think so, and with all of the functions with PHP it might be easier.



I had some trouble making up a template language in ASP, but in PHP it would
be quite easy because of the vast amount of built-in functions.  You might
be able to fiddle with the exec(); function to start up programs on a
Windows server, but don't take my word for it.



Henning Sittler [EMAIL PROTECTED] wrote in message
FBA86B8BA4D6D411BC2A0002B323D39A019408D4@MAIL2">news:FBA86B8BA4D6D411BC2A0002B323D39A019408D4@MAIL2...
 Speaking of forms, and I'm sure lots have asked this before me, but anyone
 know anywhere I can go to see some examples or existing code for
 automatically generating and and validating dynamic forms?

 Wait though, I'm already doing this myself.  To explain further, what I
 really want is an abstract set of php functions to say, ok, I want another
 form with say 10 questions, and I want to define each question and set of
 possible answers (input types and ranges) manually, and have the action
 script automatically check that the input types and ranges for each
question
 are valid.



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




RE: [PHP] sigh... forms

2002-07-09 Thread Henning Sittler

Speaking of forms, and I'm sure lots have asked this before me, but anyone
know anywhere I can go to see some examples or existing code for
automatically generating and and validating dynamic forms?  

Wait though, I'm already doing this myself.  To explain further, what I
really want is an abstract set of php functions to say, ok, I want another
form with say 10 questions, and I want to define each question and set of
possible answers (input types and ranges) manually, and have the action
script automatically check that the input types and ranges for each question
are valid.


Henning Sittler
www.inscriber.com



-Original Message-
From: Chris Earle [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 09, 2002 1:38 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] can I call a variable... using variables?


Why not just make the form's input names var[] then PHP will make them
into an array:

for ($i = 1; $i  100; $i++)
{
 if ($var[$i -1]  0)
  echo Yup. . $var[$i - 1] . is greater than 0.;
}

-- 
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] *sigh* xmldom win2k php4.1.2 apache

2002-03-26 Thread botsai

I worked with the xmldom under php4.0.6 and everything was fine and dandy,
though since I upgraded php on my staging server which is a win2k(pro) box
to 4.1.2 there has been no way to get the libxml to work. I first tried
4.1.1, that wouldnt work, so I had a little bit of hope that 4.1.2 would do
the trick but unfortunately I am still stuck.
I almost cant believe that it isn't possible to get libxml to work on win2k
with php 4.1.2, I tried everything I could possibly come up with, reading
Mad Osterby's guide for 100 times over, looked on every forum I could find,
but no results.

If anybody has an idea (or can state that they could get it running) then
please let me know, I am now developing on the live server which is not a
relaxed situation - if I produce an error 4 portals go down and or show
error msg's to the users untill the time I fixed them, which doesn't
precisely make my commissiongivers happy.

If there's noone out there who got it running, I will have to trash win2k
and install linux, but that would be an enormous job so please please please
if you know something, share this with me!

Thanks very much

*   *   * *  *   ** *  *   *
*
*  Tobias Beuving
*  g a d g e t sm e d i a
*  http://www.gadgets.nl
*   *   * *  *   ** *  *   *
*



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




Re: [PHP] *sigh* xmldom win2k php4.1.2 apache

2002-03-26 Thread Analysis Solutions

Hi Tobias:

On Tue, Mar 26, 2002 at 11:02:50AM +0100, botsai wrote:
 I worked with the xmldom under php4.0.6 and everything was fine and dandy,
 though since I upgraded php on my staging server which is a win2k(pro) box
 to 4.1.2 there has been no way to get the libxml to work.

Forgive me for stating the obvious, but hey, simple oversights happen...  
Have you removed the ; from in front of this line in your php.ini
file?
   ;extension=php_domxml.dll

--Dan

-- 
PHP scripts that make your job easier
  http://www.analysisandsolutions.com/code/
 SQL Solution  |  Layout Solution  |  Form Solution
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y

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