"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 th
Tony, try searching the archives - the regular expression that's required to
get the stuff between the tags has been asked many, many times
before.
Here's a quick bit of code that might get you started:
http://www.yahoo.com/";;
$their_text = implode("", file($file));
# now let's get our match b
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:
"; ?>
That will not bring a desirab
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 w
Another solution:
$month_now = date("n");
echo "\n";
for($i=$month_now, $j=0; $i<=($month_now+12); $i++,$j++)
{
echo "" . date("F Y", mktime(0, 0, 0, $month_now+$j, 1, date("Y"))) .
"\n";
}
echo "\n";
This will start the month's dropdown on the month of the year through to the
month of th
Output buffering functions sound like something you could use:
\n";
}
function DoStuff()
{
echo "Something\n";
echo "Something else\n";
OtherStuff();
}
// Start output buffering.
ob_start();
// Grab the content.
DoStuff();
$content = ob_get_contents();
// Finish up.
ob_end_cle
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:
(!preg_ma
ell as if it equals 0 than there is no data to
> fetch. But if one ONLY wants a number of rows count,
> doing SELECT count(*)... works great as suggested
> below.
>
>
> Regards,
> Philip Olson
>
>
> On Wed, 18 Dec 2002, liljim wrote:
>
> > Hi John,
> >
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);
> mysql_select_db($db,$myco
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
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 "$query". MySQL said: " .
mysql_error());
$row = mysql_f
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
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
"M
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
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 g
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)
-James
"Meltem Demirkus" <[EMAIL PROTECTED]> wrote in message
03ef01c2558e$923180f0$550
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
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 : (\\nedcoraa\pdf_reports
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 PROTECTED]">
Actually, I just threw in this amendment:
function CleanUpHtml($var)
{
$var = preg_replace("!!is", "",
$var);
$var = preg_replace("!!is", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
pre
Hello,
I wrote this function:
!is", "",
$var);
$var = preg_replace("!!is", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
$var = str_replace("", "", $var);
return $var;
}
$variable = CleanUpHtml($variable);
echo $variable;
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 21-0
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
Hi Ed,
first example has been covered by others, so onto the next:
> Pulling a word between two other words without having to know what the
word
> is. For example, pulling whatever word displays between "the" and
> "sky". If the string was "the blue sky", the result would be the word
> blue.
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
00a501c1eb6f$08a6f060$0400a8c0@enigma">news:00a501c1eb6f$08a6f060$0400a8c0@en
Hello Ashley,
]+>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 PROTECTED]">news:[EMAIL PROTECTED]...
>
> I have a variab
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
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 =
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
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
Hi Erik.
Try this:
~James
"Erik Price" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have the following code --
>
> $phone_number = "8005551212";
> $phone_array = explode("", $phone_number);
> $phone_number = sprintf("(%s%s%s) %s%s%s-%s%s%s%s", $phone_a
Hi
try this (untested)
and friends with their html equivelants.
$input = htmlenitities($input);
$input = preg_replace("!<(b|i|u)>(.*?)\\1>!is", "<$1>$2",
$input);
echo $input;
?>
I use something like this on one of my sites, though I check as the user
inputs the info whether or not there
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 o
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 cooki
"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 Gene
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;
}
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
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.
J
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)
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
alphabetic
Hello Desikan,
this should suit your needs.
~James
> Please help me out in the following...
>
> $is='is';
> echo eregi_replace(" ".$is." "," ","This is a test string which contains
> is in dismissal");
> ?>
>
>
> Actually I want to replace "is" alone from the string and not all the
> words t
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]
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 ea
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 dig
Hi mweb,
try this:
blah blah blah some text, html markup...
blah blah again";
$string = preg_replace("//i", "", $string);
echo nl2br($string);
?>
~James
"Mweb" <> wrote in message ...
Hello,
What is the right regexp to handle this, either in a while loop (how?)
or all by itself? The clo
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:
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 P
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 t
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
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 out
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('|\
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
ed 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 Gaylen,
>
> try this:
>
> $string = preg_replace("/\n{3,
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 and/or line feed
> characters and convert them to a con
> 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 un
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 administrat
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 files&directories where I don't whant see them/him...
>
> The string:
>
> $path =
> eregi
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
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 u
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
60 matches
Mail list logo