[PHP] Re: problems with rename() - permission denied

2003-03-25 Thread liljim
Christian Rosentreter wrote: Hi Christian, I've a small problem, which mades me crazy... :\ I'm trying to rename() a swapfile to real destination file (atomic update). It works on differnt environments very well. Sadly not on my ISP-server I've added an chmod($swapfile,0777), but this has

[PHP] Re: Odd Parse Error

2003-03-24 Thread liljim
You have a curly brace, where you should have a square bracket: if ($values{$i] != 0){ //line 137 if($values[$i]) { James Shaun [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Using the following code i get a parse error for line 137, and i cant see anything wrong with it,

[PHP] Re: When to use htmlentities()

2003-03-24 Thread liljim
If you store your text htmlentitied in the database, you will need to apply htmlentities to the search string, but not when you bring the data back from the database tables (to either display in the text editing screen, or the normal viewing screen. Example: ?php $text = This is a test /textarea;

[PHP] Re: File manipulation tutorials / helpful resources

2003-03-24 Thread liljim
Tony, try searching the archives - the regular expression that's required to get the stuff between the body tags has been asked many, many times before. Here's a quick bit of code that might get you started: ?php $temp_file = /tmp/ . uniqid(yahoo); $myfile = /path/to/myfile.html; $file =

Re: [PHP] Months of the year

2003-01-06 Thread liljim
Another solution: $month_now = date(n); echo select name=\month\\n; for($i=$month_now, $j=0; $i=($month_now+12); $i++,$j++) { echo option value=\$i\; if($i == $month_now) { echo selected; } echo . date(F Y, mktime(0, 0, 0, $month_now+$j, 1, date(Y))) . /option\n; } echo

[PHP] Re: Code contents of a function

2003-01-03 Thread liljim
Output buffering functions sound like something you could use: ?php function OtherStuff() { echo MONKEY!!!br\n; } function DoStuff() { echo Somethingbr\n; echo Something elsebr\n; OtherStuff(); } // Start output buffering. ob_start(); // Grab the content. DoStuff();

[PHP] Re: mysql_num_rows

2002-12-18 Thread liljim
Hi John, John Taylor-Johnston wrote in message: I use $mycounter, not saying it is pretty. But if you have a whole bunch of stuff deleted, your last id might be worth a lot more than the actual number of rows. $myconnection = mysql_connect($server,$user,$pass);

Re: [PHP] Re: mysql_num_rows

2002-12-18 Thread liljim
d below. Regards, Philip Olson On Wed, 18 Dec 2002, liljim wrote: Hi John, John Taylor-Johnston wrote in message: I use $mycounter, not saying it is pretty. But if you have a whole bunch of stuff deleted, your last id might be worth a lot more than the actual number

Re: [PHP] ereg.

2002-12-18 Thread liljim
Instead of: (!ereg(^([a-zA-ZåÅäÄöÖ]{4,20})\$, $_REQUEST['f_name'])) Try: (!ereg(^[a-zA-ZåÅäÄöÖ]{4,20}$, $_REQUEST['f_name'])) (You don't need the brackets unless you're wanting to get the output of the matches, which in this case, it doesn't look as though you do) Better still:

[PHP] Re: Beginner question : Removing spaces in forms

2002-12-13 Thread liljim
Hi Andrew, Andrew Wilson [EMAIL PROTECTED] wrote in message: Hay guys i was wondering if there was a form parameter of something equivalent for input text boxes that when a user enters a number or series of numbers that it removes the spaces. If there is no alternative how would you go about

[PHP] Re: Populating form value fields.

2002-12-11 Thread liljim
Hi Steve, you will need to use mysql_fetch_* on the result (where * might be object, row, array, assoc): $query = SELECT * FROM products WHERE ItemCode='$ItemCode'; $result = mysql_query($query) // for debug or die(Error in query quot;$queryquot;. MySQL said: . mysql_error()); $row =

Re: [PHP] Struggling with code

2002-12-05 Thread liljim
Ben, consider re-working this slightly: $result = mysql_query($sql,$connection) or mysql_error(Couldn't execute query.); mysql_error() doesn't take any arguments (other than maybe a resource identifier ($connection, in this case)): it simply outputs problems, which allows you to diagnose what's

[PHP] Re: Check valid chars in string

2002-12-02 Thread liljim
It's missing a closing brace. I would, however, tend to drop that way of doing things and use a regex: function ValidChard($file_name) { if(preg_match(![^a-z0-9\-\.]!is, $file_name)) { return false; } return true; } Much easier on the eye, don't you think? :) James

[PHP] Re: rewrite urls with preg_replace

2002-11-28 Thread liljim
Hi Dieter, You need to use the 'e' modifier as well as 'is' in your pattern. Have a look in the manual, here: http://www.php.net/manual/en/pcre.pattern.modifiers.php If this modifier is set, preg_replace() does normal substitution of backreferences in the replacement string, evaluates it as PHP

Re: [PHP] question about Location

2002-09-06 Thread liljim
Are you needing to output anything to your users before the page is sent to this new page? If not, then simple answer, don't send output before redirecting. Brief example (coming from a submitted form) ?php extract($_POST); if ($action) { // something's been submitted. // Process all of

Re: [PHP] Source code

2002-09-06 Thread liljim
I might be missing something, but Wouldn't this suffice? : http://www.php.net/manual/en/function.highlight-file.php Maintains formatting *and* colours things up nicely. -James Lallous [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I think it is also good

[PHP] Re: Problem on file_exists()

2002-07-16 Thread liljim
Jack, Probably because of the space in the directory dealing room - you'd be best advised to avoid spaces in directory names. ~James Jack [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Dear all I had a folder which the path is :

[PHP] Re: ^k ? -- how do I match that?

2002-07-16 Thread liljim
Hi Jimmy, In many cases, I'd go for a regex, though with this (because it's just a straight replacement), I'd just use str_replace (and since about the closest thing to a vertical tab would be a new line in html, use that as the replacement): $string = str_replace(^K, \n, $string); James

[PHP] Re: strange php output

2002-07-10 Thread liljim
Calvin, this: (!$page==datetime) (as I interpret it, that means if $page is false, and it's equal to datetime (which should, in this context, also be false)) looks like it should read: ($page!=datetime) James Calvin Spealman [EMAIL PROTECTED] wrote in message [EMAIL

[PHP] Re: HTML formatting

2002-06-28 Thread liljim
Hello, I wrote this function: ?php function CleanUpHtml($var) { $var = preg_replace(!t(a|r|d)(.*?)style=\.*?\(.*?)!is, t$1$2$3, $var); $var = preg_replace(!table.*?!is, TABLE border=1 bordercolor='#66' cellpadding=3 cellspacing=0, $var); $var = str_replace(p, , $var); $var =

[PHP] Re: HTML formatting

2002-06-28 Thread liljim
Actually, I just threw in this amendment: function CleanUpHtml($var) { $var = preg_replace(!t(a|r|d)(.*?)style=\.*?\(.*?)!is, t$1$2$3, $var); $var = preg_replace(!table.*?!is, TABLE border=1 bordercolor='#66' cellpadding=3 cellspacing=0, $var); $var = str_replace(p, , $var); $var =

[PHP] Re: Searching for any number in a mysql query

2002-05-21 Thread liljim
Hi, try something like this: select [fields] from [table(s)] where [fieldtosearch] regexp ^([1-9]{1}|10); ~James [EMAIL PROTECTED] wrote in message 003901c200b2$27ccff40$0100a8c0@JohnH">news:003901c200b2$27ccff40$0100a8c0@JohnH... This isn't a one hundred percent PHP Q but here I go. If I

[PHP] Re: Reverse mySQL date

2002-05-21 Thread liljim
Hello, use DATE_FORMAT select date_format(datefield, '%d-%m-%Y') as mydate from table; ~James [EMAIL PROTECTED] wrote in message 005e01c200b5$194184c0$0100a8c0@JohnH">news:005e01c200b5$194184c0$0100a8c0@JohnH... How can I reverse the date coming out of mySQL? ie 2002-05-21 becomes

[PHP] Re: RegEx and ?

2002-04-24 Thread liljim
Hi Berber, you generally need to do some string replacements on the text you're using to put through the match before you actually do the match (and same for replacements). Just have a look at the pattern syntax in the manual for the characters you need to do the replacement on... e.g $string

[PHP] Re: RegEx and ?

2002-04-24 Thread liljim
What d'ya know. I should read the manual more regularly. http://www.php.net/manual/en/function.preg-quote.php ~J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Re: Trimming text

2002-04-24 Thread liljim
Hello Ashley, ? $string = trim($string); $string = preg_replace(/span class[^]+modified by.*?\/span\.$/is, , $string); // remove the \. if it doesn't end in a full stop^ ? Try that. James Ashley M. Kirchner [EMAIL PROTECTED] wrote in message [EMAIL

[PHP] Re: Removing Irregular characters

2002-04-24 Thread liljim
Hello Liam, varchar WILL work. Just ensure that you're applying addslashes() to the input before putting it into the database. http://www.php.net/addslashes James Liam Mackenzie [EMAIL PROTECTED] wrote in message

[PHP] Re: ereg size limit???

2002-04-22 Thread liljim
Hi, Sp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am trying to validate my input with ereg but I get the error Warning: REG_BADBR when I try over 255 characters. Is there anyway around this? Works = if(eregi('^[A-Za-z]{1,255}$', test sentence))

[PHP] Re: Maths Problem

2002-04-17 Thread liljim
Hello, Richard Meredith-Wilks [EMAIL PROTECTED] wrote in message B1CFE9307BACD211B071D11C344102A4E8E0@UKSTONTSRV3">news:B1CFE9307BACD211B071D11C344102A4E8E0@UKSTONTSRV3... Hi, I have a maths question. I'm trying to create a html form where a user can enter formula in an input

[PHP] Re: allowed tags reg exp

2002-04-10 Thread liljim
Hi try this (untested) ? // replace and and friends with their html equivelants. $input = htmlenitities($input); $input = preg_replace(!lt;(b|i|u)gt;(.*?)lt;/\\1gt;!is, $1$2/$1, $input); echo $input; ? I use something like this on one of my sites, though I check as the user inputs the

[PHP] Re: Regex Form Filter Help

2002-03-28 Thread liljim
Hello James, James Taylor [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have a site where users can type whatever they want in and it posts it to a database. I'm trying to eliminate whatever types of abuse I can think of, and, since I'm using nl2br on the

[PHP] Re: Trans_sid

2002-03-27 Thread liljim
Hi Rick, I asked this same question to an ISP I'm with, and was told that it's only possible through a re-compile. The way I got around it is this: I created a function to check whether SID was present (it only is when the session is first invoked, and from there on if the user doesn't have

Re: [PHP] Still REG EX

2002-03-25 Thread liljim
Have a look at this: function ValidateUrl($url) { // Check the syntax if (!preg_match(!((https?|ftp)://)(www\.)?([a-zA-Z0-9/\-]*)+\.([a-zA-Z0-9/\-]* )+([a-zA-Z0-9/\-\.]*)?!, $url)) { return false; } // If it's correct, then try and open it if (!@fopen($url, r)) { return false; }

[PHP] Re: reg-ex

2002-03-25 Thread liljim
John Fishworld [EMAIL PROTECTED] wrote in message 002301c1d3fa$b2c2f350$04010a0a@fishworld">news:002301c1d3fa$b2c2f350$04010a0a@fishworld... How can I change this to accept spaces as well ? (ereg(^[A-Za-zÀ-ÖØ-öø-ÿ]*$, $str)) Put a space in the character class. ~James -- PHP General

Re: [PHP] Returning mutliple matches of a regex with preg_match()

2002-03-21 Thread liljim
Also, make sure that you make the match ungreedy with the U modifier, or use: (.*?) James Niklas lampén wrote in message 000501c1d0aa$4a5d97f0$ba93c5c3@Niklas">news:000501c1d0aa$4a5d97f0$ba93c5c3@Niklas... preg_match_all(); Niklas -Original Message- From: Stefen Lars

[PHP] Re: replace digits

2002-03-19 Thread liljim
Hi Marc, try this: $string = preg_replace(/^41/, 0, $string); http://www.php.net/preg_replace / and / = delimiters ^ = start of string (line in multiline mode) So, it translates as, replace a leading 41 in $string with 0. ..or try the ereg function, which has already been mentioned. James

Re: [PHP] Re: A stupid question...

2002-03-11 Thread liljim
Hi chuck, use left() assuming your column is called name, then something like this will do: $letter = a; $get = @mysql_query(SELECT * FROM table WHERE LEFT(surname, 1) = '$letter' ORDER BY surname ASC); That should get out all of the fields beginning with a or A and list them alphabetically.

Re: [PHP] Re: A stupid question...

2002-03-11 Thread liljim
You're using the wildcard in the wrong place. Should be like '$letter%'; Or, left(column, 1) = '$letter'; use a die() and mysql_error() to report problems to the browser: $result =mysql_query(SELECT * FROM emply_info WHERE LEFT(Lname, 1) = '$letter' ORDER BY Lname, Fname DESC,$db) or

[PHP] Re: Exact string replacement...

2002-02-09 Thread liljim
Hello Desikan, this should suit your needs. ? $string = Is this is a way of getting strings containing \is\ dismissed from the string? It IS; $pattern = is; $string = preg_replace(/(^|\s|[^a-z]) . $pattern . ($|\s|[^a-z])/is, $1$2, $string); echo $string; ? ~James Please help me out in

[PHP] Re: Yet another regex question

2002-02-04 Thread liljim
Hello, Simon Simon H wrote in message... I'm trying to validate an input form, for database INSERT/UPDATE. I'm looking for a couple of Techniques and I cant seem to find examples anywhere: 1. Validate Alpha Text with spaces, such as NAME, CITY, STATE, but limit the length of each one

[PHP] Re: Yet another regex question

2002-02-04 Thread liljim
Hello again, This is excellent. If you don't mind digging out your functions, I'd much appreciate it... I'll have a look tomorrow. The previous question was for alpha only, no numeric ...names dont have numbers, but addresses usually do. Alright, well: [a-z] matches a through z [A-Z]

[PHP] Re: Ereg/replace/i/ or something ??

2002-01-30 Thread liljim
Hi Bart, I want to check the data from a form-field if it excists only of digits (0-9) and nothing else. How do I use the ereg()-function for this? Well, I prefer the preg_functions if (!preg_match(/^[0-9]{10}$/, $string)) { // contains stuff other than numbers, or is less than 10 digits

[PHP] Re: Help with regular expressions

2002-01-25 Thread liljim
Hi Daniel, José daniel ramos wey ... Hi! I´m new to regular expressions, and it seems to be an art to make it work as expected. I´m trying to remove all single-line comments from an string - that´s everything after // to the end of a line. I expected that this would do the job:

[PHP] Re: regexp to substitute incremental strings

2002-01-25 Thread liljim
Hi mweb, try this: ? $string = IMG SRC=\C:\dir1\dir2\dir3\img1.gif\ blah blah blah some text, html markup... IMG SRC=\img2.jpg\ blah blah again; $string = preg_replace(/IMG SRC=\.*?([0-9])\.(gif|jpg)\/i, IMG SRC=\UNIQUE_CODE_0$1.$2\, $string); echo nl2br($string); ? ~James Mweb wrote in

[PHP] Re: seems easy...

2002-01-24 Thread liljim
Hi Justin, $string = substr($string, 0, 5000) . text too long.; ? http://www.php.net/substr James Justin French [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, Really simple, but can't see which funtion to use in the manual. I want to take a

[PHP] Re: delete a file from the server

2002-01-24 Thread liljim
Hi Tommy, use unlink() $filename = mypic.jpg; unlink($filename) or die(Something's barfed); James How can i delete a file from the server in PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

[PHP] Re: help using ereg_replace()

2002-01-14 Thread liljim
Hello Erik, Hello everyone, I am trying to learn how to use ereg_replace(), but I don't seem to be doing it correctly. $phone is a 10-digit string. I want to perform the following: $phone = ereg_replace(.{10}, [part where I am confused], $phone); I would like the output to be

Re: [PHP] Re: help using ereg_replace()

2002-01-14 Thread liljim
Hi Erik, Thanks for the advice (and especially the explanation!) -- I note that you chose the Perl regexp engine rather than the e regexp engine (POSIX?). Quite a few people recommended O'Reilly's Mastering Regular Expressions over the weekend. Does anyone know if it covers the Perl

Re: [PHP] Reg ex help-Removing extra blank spaces before HTML output

2001-12-05 Thread liljim
Hello, The example Jack gave you will clear up spaces well, though to get both newlines and spaces into one: $input = preg_replace(/([ ]|\n){1,}/, \\1, $input); James Jack Dempsey [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... $text = preg_replace('|\s+|','

[PHP] Re: Need regular match help - possibly

2001-11-22 Thread liljim
Hello Gaylen, try this: $string = preg_replace(/\n{3,}/, \n\n\n, $string); James Gaylen Fraley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I need a routine that will allow me to trap multiple br and/or line feed characters and convert them to a constant

[PHP] Re: Need regular match help - possibly

2001-11-22 Thread liljim
/? That's the way I've always used the line break tag for wml pages, but hadn't realised that it's being written that way for standard html now. Is this a change in spec? James Liljim [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello Gayle

[PHP] Re: about the replacing HTML code by another codes in a Forum ?

2001-11-22 Thread liljim
Hiya, well, you could replace all script tags with this regex: $string = preg_replace(/\/?SCRIPT.*?/is, , $string); But, if you're converting all and to their html equivelants (which you should be) using something like htmlspecialchars or your own regex, you shouldn't even need to do that.

[PHP] Re: regular expression

2001-11-01 Thread liljim
Hello, Galkov Vladimir [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Need to remove all ../ /.. from user inputing string to prevent him walking and creating filesdirectories where I don't whant see them/him... The string: $path =

[PHP] Re: regular expression

2001-11-01 Thread liljim
Whooops, Pasted wrong line. This should do it: $string = preg_replace(/(\.*\/)+(.*?\.*\/)?/s, , $string); James -- 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

[PHP] Re: regular expression

2001-11-01 Thread liljim
Whooops, Pasted wrong line. This should do it: $string = preg_replace(/(\.*\/)+(.*?\.*\/)?/s, , $string); Gah... Not.. enough... caffeine: Modification: $string = preg_replace(/(\.*\/)+(.*?\.*\/)?(\.*)?/s, , $string); -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

[PHP] Re: Regex problem

2001-10-25 Thread liljim
Hello Leon, try this if (preg_match(/^([[:space:]]*)?\*/s, $string)) { echo Match.; } else { echo No match; } James Leon Mergen [EMAIL PROTECTED] wrote in message 002f01c15d2a$e4ca3030$012aa8c0@leon">news:002f01c15d2a$e4ca3030$012aa8c0@leon... Hi there, I am camping with a little regular

Re: [PHP] Re: syntax for checking if string contains something

2001-10-23 Thread liljim
Hey, if (isset($submit)){ if (!empty($qty)) { echo Please enter the quantity for your quotation enquiry.;} When nothing was filled in for $qty the if condition did not prompt me to enter a quantity. This is wrong: if (!empty($qty)) { echo Please enter the

[PHP] Re: mktime() problem

2001-10-23 Thread liljim
Hi James, I'm running 4.0.6 on a Solaris 8 box. The output given by echo mktime(0,0,0,1,1,1970); is 3600. Shouldn't it be 0? My box's locale is set to the UK defaults, so as I write this we are in daylight savings (GMT+1). Would this make a difference? (I have already tried I uploaded