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
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,
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;
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 =
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
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();
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);
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
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:
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
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 =
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
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
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
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
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 :
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
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
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 =
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 =
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
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
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
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
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
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
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))
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
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
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
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
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;
}
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
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.
James
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.
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
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
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
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]
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
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 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
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
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
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
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,
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+|','
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
/? 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
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.
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 =
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
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,
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
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
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
58 matches
Mail list logo