|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 20 Feb 2007 04:33:13 -0000 Issue 4635
php-general-digest-help
lists.php.net
Date: Mon Feb 19 2007 - 22:33:13 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 20 Feb 2007 04:33:13 -0000 Issue 4635
Topics (messages 249022 through 249058):
Re: serialize() and special ANSI characters
249022 by: Roman Neuhauser
249026 by: Youri LACAN-BARTLEY
249030 by: Roman Neuhauser
Re: remote fopen not working, despite allow_url_fopen = on
249023 by: alex handle
Change in 5.2.1 re. parsing of URL
249024 by: Lewis Kapell
249025 by: Jochem Maas
249027 by: Lewis Kapell
Re: css in mail()
249028 by: Sancar Saran
249029 by: tedd
Month
249031 by: Dan Shirah
249032 by: Jay Blanchard
249033 by: Brad Bonkoski
249034 by: Dan Shirah
249035 by: Brad Fuller
249036 by: Jay Blanchard
249037 by: Dan Shirah
249038 by: Brad Fuller
249039 by: Dan Shirah
249040 by: Brad Bonkoski
249041 by: Brad Fuller
249042 by: Brad Bonkoski
249043 by: Dan Shirah
249044 by: Brad Bonkoski
249045 by: Dan Shirah
Re: Catch STDERR
249046 by: Peter Lauri
WHERE problem
249047 by: Mike Shanley
249048 by: Bruce Cowin
249049 by: Mike Shanley
249050 by: Brad Fuller
249051 by: Jay Blanchard
249052 by: Mike Shanley
Poblem with sesions
249053 by: Ashish Rizal
Re: LOL, preg_match still not working.
249054 by: Beauford
249056 by: Beauford
249057 by: Gregory Beaver
Classified Ads Script
249055 by: Matt Arnilo S. Baluyos (Mailing Lists)
importing contacts
249058 by: kumar3k
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
# ylacan
teicam.com / 2007-02-19 15:56:15 +0100:
> I'm just curious to find out if I'm the only person to have bumped into
> this kind of issue with serialize/unserialize.
>
> When I try and serialize an array containing a string value with the "?"
> character (alt+241 ASCII) such as :
> "120GB 2X512MB 15.4IN DVD?RW VHP FR"
>
> The resulting serialized array is truncated.
> ie. I would obtain :
>
> "a:17:{i:0;s:1:"A";i:1;s:7:"TOSHIBA";i:2;s:4:"3740";i:3;s:7:"404D862";i:4;s:31:"SATELLITE
> A100-044 CD/T2060-1.6";i:5;s:35:"120GB 2X512MB 15.4IN DVD"
>
> As you can see serialization seems to stall as soon as the "?" character
> shows up.
I don't see the effect you're mentioning, but this is on FreeBSD, so
perhaps there's a problem on Windows. I don't really believe it,
though, and would hazard a guess you're running into display problems
with your browser.
Another thing to mention is that ASCII only goes up to 127. You may
desire for ASCII 241 to mean +/-, but n-tilde is also a popular
interpretation... Use a character set which actually includes +/- as a
single character, and an encoding that can handle that charset.
The following test fails in 5.2.1:
<?php
class serializeASCII241 extends Tence_TestCase
{
function testTruncates()
{
return $this->assertEquals(
"120GB 2X512MB 15.4IN DVD",
serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR")
);
}
}
?>
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
attached mail follows:
Roman Neuhauser wrote:
> # ylacan
teicam.com / 2007-02-19 15:56:15 +0100:
>> I'm just curious to find out if I'm the only person to have bumped into
>> this kind of issue with serialize/unserialize.
>>
>> When I try and serialize an array containing a string value with the "?"
>> character (alt+241 ASCII) such as :
>> "120GB 2X512MB 15.4IN DVD?RW VHP FR"
>>
>> The resulting serialized array is truncated.
>> ie. I would obtain :
>>
>> "a:17:{i:0;s:1:"A";i:1;s:7:"TOSHIBA";i:2;s:4:"3740";i:3;s:7:"404D862";i:4;s:31:"SATELLITE
>> A100-044 CD/T2060-1.6";i:5;s:35:"120GB 2X512MB 15.4IN DVD"
>>
>> As you can see serialization seems to stall as soon as the "?" character
>> shows up.
>
> I don't see the effect you're mentioning, but this is on FreeBSD, so
> perhaps there's a problem on Windows. I don't really believe it,
> though, and would hazard a guess you're running into display problems
> with your browser.
>
> Another thing to mention is that ASCII only goes up to 127. You may
> desire for ASCII 241 to mean +/-, but n-tilde is also a popular
> interpretation... Use a character set which actually includes +/- as a
> single character, and an encoding that can handle that charset.
I'm probably just running into so encoding issues with the CSV files I'm
using on which I have no control whatsoever.
>
> The following test fails in 5.2.1:
>
> <?php
>
> class serializeASCII241 extends Tence_TestCase
> {
> function testTruncates()
> {
> return $this->assertEquals(
> "120GB 2X512MB 15.4IN DVD",
> serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR")
> );
> }
> }
>
> ?>
I'd just like to point out that your test will fail systematically
unless you use something like this :
function testTruncates()
{
$string = "120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR";
return $this->assertEquals(
"s:" . strlen($string) . ":\"120GB 2X512MB 15.4IN DVD",
serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR")
);
}
>
attached mail follows:
# ylacan
teicam.com / 2007-02-19 17:29:53 +0100:
> Roman Neuhauser wrote:
> >
> >class serializeASCII241 extends Tence_TestCase
> >{
> > function testTruncates()
> > {
> > return $this->assertEquals(
> > "120GB 2X512MB 15.4IN DVD",
> > serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR")
> > );
> > }
> >}
> >
> >?>
>
> I'd just like to point out that your test will fail systematically
> unless you use something like this :
>
> function testTruncates()
> {
> $string = "120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR";
> return $this->assertEquals(
> "s:" . strlen($string) . ":\"120GB 2X512MB 15.4IN DVD",
> serialize("120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR")
> );
> }
You're right, of course, I wrote that in a hurry, after I checked the
output of serialize() contained the whole input.
This is a better test, and it does work with the beforementioned
configuration (5.2.1 on FreeBSD).
<?php
class serializeASCII241 extends Tence_TestCase
{
function setUp()
{
$this->raw = "120GB 2X512MB 15.4IN DVD" . chr(241) . "RW VHP FR";
$this->serialized = sprintf(
's:%d:"%s";', strlen($this->raw), $this->raw
);
}
function testWorksAsExpected()
{
return $this->assertEquals(
$this->serialized,
serialize($this->raw)
);
}
}
?>
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
attached mail follows:
On 2/15/07, alex handle <alex.handle
gmail.com> wrote:
>
> Hi all,
>
> i recently upgraded a server from
> freebsd 5.x to 6.2
> php 4.4.2 -> php 4.4.4
> apache 1.3 -> apache 2.2.4.
>
> It worked all great till i noticed that the remote fopen()/file() did not
> work.
>
> allow_url_fopen is set to "On" and the httpd-error.log shows this error
> message:
>
> [Thu Feb 15 14:15:42 2007] [error] [client xxx] PHP Warning: file() [<a
> href='function.file'>function.file </a>]: php_network_getaddresses:
> getaddrinfo failed: hostname nor servname provided, or not known in
> /home/domains/x/xxx/tmp/remote.php on line 2
> [Thu Feb 15 14:15:42 2007] [error] [client xxx] PHP Warning: file(
> http://google.com/) [<a href='function.file'>function.file</a>]: failed to
> open stream: Invalid argument in /home/domains/x/xxx/tmp/remote.php on line
> 2
>
> A lynx from the server to google.com works.
> Then i put google.com in the /etc/hosts file and i got this message:
>
> [Thu Feb 15 14:19:47 2007] [error] [client xxx] PHP Warning: file(
> http://google.com/) [<a href='function.file'>function.file</a>]: failed to
> open stream: HTTP request failed! in /home/domains/x/xxx/tmp/remote.php on
> line 2
>
> With curl i can fetch remote content, but i have to put the domainname in
> the hosts file. Verry strange!?
>
> Here my test file:
> <?php
> var_dump(file('http://google.com/') <http://google.com/%27%29>);
> ?>
>
> phpinfo and configure.log of the freebsd-ports is attached
>
> <http://www.dict.cc/englisch-deutsch/Thanks+in+advance+TIA.html>Thanks in
> advance!
>
> Alex
>
>
>
A minute ago i tried to run my test script (remote.php) on the shell and the
remote fopen works!!
The problem must be within the php apache module or apache self.
Is there a way to debug the php apache module?
attached mail follows:
There seems to be a behavior change introduced in 5.2.1 and I would like
to know if it was deliberate.
A couple of years ago, PHP introduced functionality that made it
possible to use a certain trick. I don't know how to describe this
trick in words, so I will illustrate with an example.
http://www.mydomain.com/mypage.php/phonypage.pdf
In this example there is a PHP script called mypage.php which serves up
a PDF. Putting the extra text at the end of the URL makes it appear to
the user's browser that the URL ends with '.pdf' rather than '.php'. We
introduced this hack at my company because a few users were unable to
view pages containing PDF or RTF content, presumably because of some
combination of browser and/or firewall settings.
I find that version 5.2.1 breaks this behavior - attempting to visit a
URL such as the above produces a 'page not found' error. Presumably
because it is trying to find the file 'phonypage.pdf' which doesn't exist.
My question is, should this be regarded as a bug which might be fixed?
Or is this a deliberate change of behavior?
--
Thank you,
Lewis Kapell
Computer Operations
Seton Home Study School
attached mail follows:
Lewis Kapell wrote:
> There seems to be a behavior change introduced in 5.2.1 and I would like
> to know if it was deliberate.
>
> A couple of years ago, PHP introduced functionality that made it
> possible to use a certain trick. I don't know how to describe this
> trick in words, so I will illustrate with an example.
>
> http://www.mydomain.com/mypage.php/phonypage.pdf
>
> In this example there is a PHP script called mypage.php which serves up
> a PDF. Putting the extra text at the end of the URL makes it appear to
> the user's browser that the URL ends with '.pdf' rather than '.php'. We
> introduced this hack at my company because a few users were unable to
> view pages containing PDF or RTF content, presumably because of some
> combination of browser and/or firewall settings.
>
> I find that version 5.2.1 breaks this behavior - attempting to visit a
> URL such as the above produces a 'page not found' error. Presumably
> because it is trying to find the file 'phonypage.pdf' which doesn't exist.
>
> My question is, should this be regarded as a bug which might be fixed?
> Or is this a deliberate change of behavior?
this is nothing to do with php - it's down to your webserver settings.
>
attached mail follows:
If this has nothing to do with PHP, maybe you can explain why the
behavior was broken when I upgraded from 5.2.0 to 5.2.1, and started
working again the instant I reverted back to 5.2.0. No other
configuration changes were made on the web server.
??
Thank you,
Lewis Kapell
Computer Operations
Seton Home Study School
Jochem Maas wrote:
> Lewis Kapell wrote:
>> There seems to be a behavior change introduced in 5.2.1 and I would like
>> to know if it was deliberate.
>>
[snip]
>
> this is nothing to do with php - it's down to your webserver settings.
>
>
attached mail follows:
On Monday 19 February 2007 17:03, Danial Rahmanzadeh wrote:
> how can i use css with mail()?
> thank u
<?php
$data ='';
$fp = fopen ("site/themes/".$arrStat['theme']."/css/main.css","r");
while (!feof($fp)) { $data.= fgets($fp, 16384); }
$mail="
<html>
<head>
<title>Title</title>
<style>".$data."</style>
</head>
<body>
Html content
</body>
</html>";
mail('anrah
gmail.com', 'You are welcome', $mail);
?>
attached mail follows:
At 4:38 PM +0100 2/19/07, Jochem Maas wrote:
>Danial Rahmanzadeh wrote:
>> how can i use css with mail()?
>
>this kind of question is really annoying [today] - it shows that you are
>a f***ing lazy b'std who can't even be bothered to formulate a question
>properly let alone type something like 'CSS mail php' into the nearest
>search engine.
>
>we are not here to do your job for you.**
>
>please STFW and go find yourself a tutorial/clue/code-snippet
>related to sending HTML email [using php].
>
>**suppressing the desire to rant along the lines of "my job went to India
>and now I'm relegated to spoon feeding the answers to the moron, who has been
>programming for all of 3 days but *is* getting paid for the work I'm
>still doing,
>for free"
Jochem:
Well... I see no reason to sugar-coat your reply. Tell him what you
really think. :-)
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Greetings,
I have the following code which populates a dropdown box so a user can
select a month. They see the month name and the SELECTED value is the
corresponding numeric value 1-12 for the month. However, the selected
value for January would be 1. I need the selected value fro January to be
01. How would I accomplish this?
<select name="month">
<?PHP
for ($m=1;$m<=12;$m++)
{
$months=date('M', mktime(0, 0, 0, $m, 1));
if ($m == $_POST['month'])
echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
else
echo "<option value=\"$m\">$months</option>";
}
?>
</select>
attached mail follows:
[snip]
I have the following code which populates a dropdown box so a user can
select a month. They see the month name and the SELECTED value is the
corresponding numeric value 1-12 for the month. However, the selected
value for January would be 1. I need the selected value fro January to
be
01. How would I accomplish this?
<select name="month">
<?PHP
for ($m=1;$m<=12;$m++)
{
$months=date('M', mktime(0, 0, 0, $m, 1));
if ($m == $_POST['month'])
echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
else
echo "<option value=\"$m\">$months</option>";
}
?>
</select>
[/snip]
http://www.php.net/date
attached mail follows:
Dan Shirah wrote:
> Greetings,
>
> I have the following code which populates a dropdown box so a user can
> select a month. They see the month name and the SELECTED value is the
> corresponding numeric value 1-12 for the month. However, the selected
> value for January would be 1. I need the selected value fro January
> to be
> 01. How would I accomplish this?
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++)
> {
> $months=date('M', mktime(0, 0, 0, $m, 1));
> if ($m == $_POST['month'])
> echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
> else
> echo "<option value=\"$m\">$months</option>";
> }
> ?>
> </select>
>
Probably a number of options..
check functions... str_pad(), sprintf()
Or you could just have an array...
$months = array('01'=>'January','02'=>'February', ...)
foreach($months as $k => $v) {
echo "<option value=$k>$v</option>\n";
}
(Not usually recommended, but the name/values of months do not change
often...)
-B
attached mail follows:
If I change my date value to m instead of M, that would only affect the
visual month representation that they see, and not the "selected" value that
I want to input into my database though....right?
On 2/19/07, Jay Blanchard <jblanchard
pocket.com> wrote:
>
> [snip]
> I have the following code which populates a dropdown box so a user can
> select a month. They see the month name and the SELECTED value is the
> corresponding numeric value 1-12 for the month. However, the selected
> value for January would be 1. I need the selected value fro January to
> be
> 01. How would I accomplish this?
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++)
> {
> $months=date('M', mktime(0, 0, 0, $m, 1));
> if ($m == $_POST['month'])
> echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
> else
> echo "<option value=\"$m\">$months</option>";
> }
> ?>
> </select>
> [/snip]
>
> http://www.php.net/date
>
>
attached mail follows:
> -----Original Message-----
> From: Dan Shirah [mailto:mrsquash2
gmail.com]
> Sent: Monday, February 19, 2007 1:27 PM
> To: php-general
> Subject: [PHP] Month
>
> Greetings,
>
> I have the following code which populates a dropdown box so a user can
> select a month. They see the month name and the SELECTED value is the
> corresponding numeric value 1-12 for the month. However, the selected
> value for January would be 1. I need the selected value fro January to
> be
> 01. How would I accomplish this?
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++)
> {
> $months=date('M', mktime(0, 0, 0, $m, 1));
> if ($m == $_POST['month'])
> echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
> else
> echo "<option value=\"$m\">$months</option>";
> }
> ?>
> </select>
sprintf("%02s", $m)
attached mail follows:
[snip]
If I change my date value to m instead of M, that would only affect the
visual month representation that they see, and not the "selected" value
that I want to input into my database though....right?
[/snip]
Do a combination.
attached mail follows:
Okay, so sprintf("%02s", $m) means that the value of $m would be checked for
the amount of digits returned. If less than two digits a zero would be
added to the front, correct?
On 2/19/07, Jay Blanchard <jblanchard
pocket.com> wrote:
>
> [snip]
> If I change my date value to m instead of M, that would only affect the
> visual month representation that they see, and not the "selected" value
> that I want to input into my database though....right?
> [/snip]
>
> Do a combination.
>
attached mail follows:
> -----Original Message-----
> From: Dan Shirah [mailto:mrsquash2
gmail.com]
> Sent: Monday, February 19, 2007 1:44 PM
> To: Jay Blanchard
> Cc: php-general
> Subject: Re: [PHP] Month
>
> Okay, so sprintf("%02s", $m) means that the value of $m would be checked
> for
> the amount of digits returned. If less than two digits a zero would be
> added to the front, correct?
Yes.
% = start of format string
0 = padding specifier
2 = width specifier
s = type specifier (string)
attached mail follows:
Okay, when I try the sprintf I get the following error when I try to save my
form
Incorrect syntax near 's'.
<select name="month">
<?PHP
for ($m=1;$m<=12;$m++) {
$months=date('M', mktime(0, 0, 0, $m, 2));
echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
}
?>
</select>
On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>
> > -----Original Message-----
> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
> > Sent: Monday, February 19, 2007 1:44 PM
> > To: Jay Blanchard
> > Cc: php-general
> > Subject: Re: [PHP] Month
> >
> > Okay, so sprintf("%02s", $m) means that the value of $m would be checked
> > for
> > the amount of digits returned. If less than two digits a zero would be
> > added to the front, correct?
>
> Yes.
>
> % = start of format string
> 0 = padding specifier
> 2 = width specifier
> s = type specifier (string)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Dan Shirah wrote:
> Okay, when I try the sprintf I get the following error when I try to
> save my
> form
>
> Incorrect syntax near 's'.
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++) {
> $months=date('M', mktime(0, 0, 0, $m, 2));
> echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
try: echo "<option value=\".sprintf('%02s', $m)."\">$months</option>";
your trying to call a function inside of a string...
-B
> }
> ?>
> </select>
>
>
> On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>
>> > -----Original Message-----
>> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
>> > Sent: Monday, February 19, 2007 1:44 PM
>> > To: Jay Blanchard
>> > Cc: php-general
>> > Subject: Re: [PHP] Month
>> >
>> > Okay, so sprintf("%02s", $m) means that the value of $m would be
>> checked
>> > for
>> > the amount of digits returned. If less than two digits a zero
>> would be
>> > added to the front, correct?
>>
>> Yes.
>>
>> % = start of format string
>> 0 = padding specifier
>> 2 = width specifier
>> s = type specifier (string)
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
attached mail follows:
> -----Original Message-----
> From: Dan Shirah [mailto:mrsquash2
gmail.com]
> Sent: Monday, February 19, 2007 2:08 PM
> To: Brad Fuller
> Cc: Jay Blanchard; php-general
> Subject: Re: [PHP] Month
>
> Okay, when I try the sprintf I get the following error when I try to save
> my
> form
>
> Incorrect syntax near 's'.
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++) {
> $months=date('M', mktime(0, 0, 0, $m, 2));
> echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
> }
> ?>
> </select>
I'm pretty sure you need to use double quotes on the format string.
echo "<option value=\"".sprintf("%02s", $m)."\">$months</option>";
attached mail follows:
Brad Bonkoski wrote:
> Dan Shirah wrote:
>> Okay, when I try the sprintf I get the following error when I try to
>> save my
>> form
>>
>> Incorrect syntax near 's'.
>>
>> <select name="month">
>> <?PHP
>> for ($m=1;$m<=12;$m++) {
>> $months=date('M', mktime(0, 0, 0, $m, 2));
>> echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
> try: echo "<option value=\".sprintf('%02s', $m)."\">$months</option>";
> your trying to call a function inside of a string...
oops..typo, forgot the additional {"}
echo "<option value=\"".sprintf('%02s', $m)."\">$months</option>";
> -B
>> }
>> ?>
>> </select>
>>
>>
>> On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>>
>>> > -----Original Message-----
>>> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
>>> > Sent: Monday, February 19, 2007 1:44 PM
>>> > To: Jay Blanchard
>>> > Cc: php-general
>>> > Subject: Re: [PHP] Month
>>> >
>>> > Okay, so sprintf("%02s", $m) means that the value of $m would be
>>> checked
>>> > for
>>> > the amount of digits returned. If less than two digits a zero
>>> would be
>>> > added to the front, correct?
>>>
>>> Yes.
>>>
>>> % = start of format string
>>> 0 = padding specifier
>>> 2 = width specifier
>>> s = type specifier (string)
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>
attached mail follows:
Just when I think I'm getting the hang of PHP, I get confused beyond belief
:|
Is this working for you guys? When I test my page only 1/2 of the months
show up now. <scratching head>
<select name="month">
<?PHP
for ($m=1;$m<=12;$m++) {
$months=date('M', mktime(0, 0, 0, $m, 1));
echo "<option value=\"".sprintf("%02d", $m).\">$months</option>";
}
?>
</select>
On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>
> > -----Original Message-----
> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
> > Sent: Monday, February 19, 2007 2:08 PM
> > To: Brad Fuller
> > Cc: Jay Blanchard; php-general
> > Subject: Re: [PHP] Month
> >
> > Okay, when I try the sprintf I get the following error when I try to
> save
> > my
> > form
> >
> > Incorrect syntax near 's'.
> >
> > <select name="month">
> > <?PHP
> > for ($m=1;$m<=12;$m++) {
> > $months=date('M', mktime(0, 0, 0, $m, 2));
> > echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
> > }
> > ?>
> > </select>
>
> I'm pretty sure you need to use double quotes on the format string.
>
> echo "<option value=\"".sprintf("%02s", $m)."\">$months</option>";
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Dan Shirah wrote:
> Just when I think I'm getting the hang of PHP, I get confused beyond
> belief
> :|
>
> Is this working for you guys? When I test my page only 1/2 of the months
> show up now. <scratching head>
>
> <select name="month">
> <?PHP
> for ($m=1;$m<=12;$m++) {
> $months=date('M', mktime(0, 0, 0, $m, 1));
> echo "<option value=\"".sprintf("%02d", $m).\">$months</option>";
Still missing a double quote in there.
echo "<option value=\"".sprintf("%02d", $m)."\">$months</option>";
> }
> ?>
> </select>
>
>
> On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
>>
>> > -----Original Message-----
>> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
>> > Sent: Monday, February 19, 2007 2:08 PM
>> > To: Brad Fuller
>> > Cc: Jay Blanchard; php-general
>> > Subject: Re: [PHP] Month
>> >
>> > Okay, when I try the sprintf I get the following error when I try to
>> save
>> > my
>> > form
>> >
>> > Incorrect syntax near 's'.
>> >
>> > <select name="month">
>> > <?PHP
>> > for ($m=1;$m<=12;$m++) {
>> > $months=date('M', mktime(0, 0, 0, $m, 2));
>> > echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
>> > }
>> > ?>
>> > </select>
>>
>> I'm pretty sure you need to use double quotes on the format string.
>>
>> echo "<option value=\"".sprintf("%02s", $m)."\">$months</option>";
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
attached mail follows:
GAH! Sorry. <rubs eyes>
On 2/19/07, Brad Bonkoski <bbonkoski
mediaguide.com> wrote:
>
> Dan Shirah wrote:
> > Just when I think I'm getting the hang of PHP, I get confused beyond
> > belief
> > :|
> >
> > Is this working for you guys? When I test my page only 1/2 of the
> months
> > show up now. <scratching head>
> >
> > <select name="month">
> > <?PHP
> > for ($m=1;$m<=12;$m++) {
> > $months=date('M', mktime(0, 0, 0, $m, 1));
> > echo "<option value=\"".sprintf("%02d", $m).\">$months</option>";
> Still missing a double quote in there.
> echo "<option value=\"".sprintf("%02d", $m)."\">$months</option>";
> > }
> > ?>
> > </select>
> >
> >
> > On 2/19/07, Brad Fuller <bfuller
cpacampaigns.com> wrote:
> >>
> >> > -----Original Message-----
> >> > From: Dan Shirah [mailto:mrsquash2
gmail.com]
> >> > Sent: Monday, February 19, 2007 2:08 PM
> >> > To: Brad Fuller
> >> > Cc: Jay Blanchard; php-general
> >> > Subject: Re: [PHP] Month
> >> >
> >> > Okay, when I try the sprintf I get the following error when I try to
> >> save
> >> > my
> >> > form
> >> >
> >> > Incorrect syntax near 's'.
> >> >
> >> > <select name="month">
> >> > <?PHP
> >> > for ($m=1;$m<=12;$m++) {
> >> > $months=date('M', mktime(0, 0, 0, $m, 2));
> >> > echo "<option value=\"sprintf('%02s', $m)\">$months</option>";
> >> > }
> >> > ?>
> >> > </select>
> >>
> >> I'm pretty sure you need to use double quotes on the format string.
> >>
> >> echo "<option value=\"".sprintf("%02s", $m)."\">$months</option>";
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
>
>
attached mail follows:
It looks like that will be the situation. Sad that exec() don't have that
feature as an option. Maybe in the future :)
Best regards,
Peter Lauri
www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free
-----Original Message-----
From: M.Sokolewicz [mailto:tularis
php.net]
Sent: Monday, February 19, 2007 11:59 AM
To: Frank Arensmeier
Cc: Peter Lauri; php-general
lists.php.net
Subject: Re: [PHP] Catch STDERR
you could instead use the proc_* functions to do this. However, seen as
those are pretty complicated and were not available in most php versions
ran by most hosts, a lot of people had to come up with other ways
around it. The most used way is indeed what you described. A simple:
$t = tempnam();
exec('/bin/SomeCommand 2>'.$t);
$stderror = file_get_contents($t);
is what most scripts seem to use currently
- tul
Frank Arensmeier wrote:
> Spontaneously, my suggestion would to pipe the STDERR output from your
> command to a file. I have to admit that this doesn't feel like the most
> efficient solution since you would involve some reading / writing to
> your filesystem.
>
> Regards.
> //frank
>
> 17 feb 2007 kl. 21.49 skrev Peter Lauri:
>
>> Hi,
>>
>> I am executing exec('some cool command', $stdout, $exitcode);
>>
>> That is fine. I get what I in the beginning wanted. However, now I
>> need to
>> catch the STDERR that the command is generating as well. Some of you
>> might
>> tell me to redirect STDERR to STDOUT, but that is not possible as I
>> need to
>> use the STDOUT as is to automate a process.
>>
>> I know I can do fwrite(STDERR, 'Output some error\n');
>>
>> So could I fread(STDERR, SOMESIZE)?
>>
>> Is there anyone with experience of best way of doing this? Should I maybe
>> use proc_open or something similar and then write it to a file, and then
>> read that file? Hrm, doesn't make any sense to do that.
>>
>> Best regards,
>> Peter Lauri
>>
>> www.dwsasia.com - company web site
>> www.lauri.se - personal web site
>> www.carbonfree.org.uk - become Carbon Free
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
attached mail follows:
I'd like to think I understood code a little better than this, but I've
got a problem with my WHERE...
I know it's the WHERE because I get a good result when I leave it out.
And the random function is also working... I honestly can't figure it
out. Thanks in advance for help with this laughable prob.
---------------------------
// How many are there?
$result = mysql_query("SELECT count(*) FROM fortunes");
$max = mysql_result($result, 0);
// Get randomized!... the moderated way...
$randi = mt_rand(1, $max-1);
$q = "SELECT text FROM fortunes WHERE index = '$randi'";
$choose = mysql_query($q);
$chosen1 = mysql_fetch_array($choose);
// Ready to ship...
$fortune = '<span class="quotecyc">"' . $chosen1[0] .
'"<br/>-Omniversalism.com</span>';
mysql_close();
--
Mike Shanley
~you are almost there~
attached mail follows:
Are you getting an error or just nothing returned? The first thing I'd check is if index is a numeric field and if it is, remove the single quotes from around $randi in the where clause.
Regards,
Bruce
>>> Mike Shanley <thebarmy
omniversalism.com> 20/02/2007 9:23:08 a.m. >>>
I'd like to think I understood code a little better than this, but I've
got a problem with my WHERE...
I know it's the WHERE because I get a good result when I leave it out.
And the random function is also working... I honestly can't figure it
out. Thanks in advance for help with this laughable prob.
---------------------------
// How many are there?
$result = mysql_query("SELECT count(*) FROM fortunes");
$max = mysql_result($result, 0);
// Get randomized!... the moderated way...
$randi = mt_rand(1, $max-1);
$q = "SELECT text FROM fortunes WHERE index = '$randi'";
$choose = mysql_query($q);
$chosen1 = mysql_fetch_array($choose);
// Ready to ship...
$fortune = '<span class="quotecyc">"' . $chosen1[0] .
'"<br/>-Omniversalism.com</span>';
mysql_close();
--
Mike Shanley
~you are almost there~
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Without the single-quotes, I still get nothing returned.
Bruce Cowin wrote:
> Are you getting an error or just nothing returned? The first thing I'd check is if index is a numeric field and if it is, remove the single quotes from around $randi in the where clause.
>
>
>
> Regards,
>
> Bruce
>
>
>>>> Mike Shanley <thebarmy
omniversalism.com> 20/02/2007 9:23:08 a.m. >>>
>>>>
> I'd like to think I understood code a little better than this, but I've
> got a problem with my WHERE...
>
> I know it's the WHERE because I get a good result when I leave it out.
> And the random function is also working... I honestly can't figure it
> out. Thanks in advance for help with this laughable prob.
> ---------------------------
> // How many are there?
>
> $result = mysql_query("SELECT count(*) FROM fortunes");
> $max = mysql_result($result, 0);
>
> // Get randomized!... the moderated way...
>
> $randi = mt_rand(1, $max-1);
> $q = "SELECT text FROM fortunes WHERE index = '$randi'";
> $choose = mysql_query($q);
> $chosen1 = mysql_fetch_array($choose);
>
> // Ready to ship...
>
> $fortune = '<span class="quotecyc">"' . $chosen1[0] .
> '"<br/>-Omniversalism.com</span>';
>
> mysql_close();
>
>
--
Mike Shanley
~you are almost there~
"A new eye opens on March 5." -Omniversalism.com
attached mail follows:
> -----Original Message-----
> From: Mike Shanley [mailto:thebarmy
omniversalism.com]
> Sent: Monday, February 19, 2007 3:50 PM
> Cc: php-general
lists.php.net
> Subject: Re: [PHP] WHERE problem
>
> Without the single-quotes, I still get nothing returned.
>
> Bruce Cowin wrote:
> > Are you getting an error or just nothing returned? The first thing I'd
> check is if index is a numeric field and if it is, remove the single
> quotes from around $randi in the where clause.
> >
Two things that come to mind...
1) If there are 100 records in there, is the value of the 'index' column
exactly 1-100? It won't do any good to give it a random value of 1-100 if
your records are numbered 101-200 :P
2) INDEX is a mysql keyword. Try putting backticks around it.
"... WHERE `index` = $randi"
If all else fails, remove the part of your code that generates the random
'index' and just use "ORDER BY RAND() LIMIT 1" in your query.
HTH,
Brad
attached mail follows:
[snip]
// Get randomized!... the moderated way...
$randi = mt_rand(1, $max-1);
$q = "SELECT text FROM fortunes WHERE index = '$randi'";
$choose = mysql_query($q);
$chosen1 = mysql_fetch_array($choose);
[/snip]
Put the random statement in the query
SELECT foo FROM bar ORDER BY RAND() LIMIT 1
attached mail follows:
This was the problem. Thanks very much!
Brad Fuller wrote:
>
> 2) INDEX is a mysql keyword. Try putting backticks around it.
> "... WHERE `index` = $randi"
>
>
>
--
Mike Shanley
~you are almost there~
"A new eye opens on March 5." -Omniversalism.com
attached mail follows:
Hi , I am having problem with log in and log out . I have a main
login page where one can login with the username and password
stored in mysql database.
PHP Code:
<?php
session_start();
//ob_start();
require_once 'functions.php';
$UserName = $_POST['UserName'];
$Password = $_POST['Password'];
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$adminAddress = getAbsolutePath().'adminlogin.php';
$userAddress = getAbsolutePath().'userlogin.php';
$samePage = getAbsolutePath().'login.php';
if ($_POST){
$error = login_check($_POST);
if (trim ($error)=="")
{
$accesslevel = accessLevel($UserName);
?>
<?php
if ($accesslevel == "admin"){
$_SESSION['level'] = "admin";
$_SESSION['username'] = $_POST['UserName'];
$_SESSION["userid"] = login($_POST);
include ('adminlogin.php');
//echo "<script language='javascript'>
location.href='$adminAddress';
exit();
}
else if ($accesslevel == "user") {
$_SESSION['level'] = "user";
$_SESSION['username'] = $_POST['UserName'];
$_SESSION["userid"] = login($_POST);
include ('userlogin.php');
exit();
}
}
else {
//$_SESSION['loggedIn'] = false;
unset ($_SESSION['userid']);
unset ($_SESSION['username']);
unset ($_SESSION['level']);
echo "Error :$error";
}
}
//ob_end_flush();
?>
<BODY>
<FORM id=form1 name=loginform method=post>
so after login user is directed to the corresponding page.
The problem is that when some user is logged in to the user page
or admin page, at the same time if i want to login to the user
page from other computers , it lets me login but after that
whatever link i click in userlogin page, takes me back to login
page. And i have to log in to userpage and click on log out and
then it will work.
its quite strange and i dont know why it is acting like this.
Also in userlogin page i am have a link to other page which i am
calling by
PHP Code:
if ($_GET['mode'] == "basketball"){
include ('basket_closed.php');
}
and link is userlogin.php?mode=basketball
My Log out script is
PHP Code:
<?php
session_start();
//store to test if they were logged in
$old_user = $_SESSION['userid'];
//$_SESSION['loggedIn'] = false;
unset ($_SESSION['userid']);
unset ($_SESSION['username']);
unset ($_SESSION['level']);
session_destroy();
?>
I need help on this...i couldn't came up with any clue, Any idea..
i really appreciate your help
attached mail follows:
Read my original email for the example string, I have referred to this in
every one of my emails. It's even at the bottom of this one.
-----Original Message-----
From: Al [mailto:news
ridersite.org]
Sent: February 18, 2007 10:35 AM
To: php-general
lists.php.net
Subject: [PHP] Re: LOL, preg_match still not working.
If you want help, you must provide some example text strings that are to be
matched. You keep posting your pattern and that's the problem.
Beauford wrote:
> Mails been down since this morning (sorry, that's yesterday morning).
> Anyway, not sure if this went through, so here it is again.
>
> ------
>
> The bottom line is I want to allow everything in the expression and
nothing
> else. The new line does not seem to be an issue - I can put as many
returns
> as I want, but as soon as I add some punctuation, it falls apart.
>
> As I said before, the ! and the period from my original example are
reported
> as invalid - as they are in the expression they should be valid, I'm sure
> there are other examples as well, but you can see what the problem is. If
I
> take out the ! and period from my example and leave the new lines in, it
> works fine.
>
> Thanks
>
>
>
>> -----Original Message-----
>> From: Gregory Beaver [mailto:greg
chiaraquartet.net]
>> Sent: February 17, 2007 12:21 PM
>> To: Beauford
>> Cc: PHP
>> Subject: [PHP] Re: LOL, preg_match still not working.
>>
>> Beauford wrote:
>>> Hi,
>>>
>>> I previously had some issues with preg_match and many of
>> you tried to help,
>>> but the same problem still exists. Here it is again, if
>> anyone can explain
>>> to me how to get this to work it would be great - otherwise
>> I'll just remove
>>> it as I just spent way to much time on this.
>>>
>>> Thanks
>>>
>>> Here's the code.
>>>
>>> if(empty($comment)) { $formerror['comment'] = nocomments;
>>> }
>>> elseif(!preg_match('|^[a-zA-Z0-9!?
#$%^&*();:_.\\\\ /\t-]+$|',
>>> $comment)) {
>>> $formerror['comment'] = invalidchars;
>>> }
>>>
>>> This produces an error, which I believe it should not.
>>>
>>> Testing 12345. This is a test of the emergency broadcast system.
>>>
>>> WAKE UP!!!!!!
>> Hi,
>>
>> Your sample text contains newlines. If you wish to allow newlines,
>> instead of " \t" you should use the whitespace selector "\s"
>>
>> <?php
>> $comment = 'Testing 12345. This is a test of the emergency
>> broadcast system.
>>
>> WAKE UP!!!!!!';
>> if(!preg_match('|^[a-zA-Z0-9!?
#$%^&*();:_.\\\\\s/-]+$|', $comment)) {
>> echo 'oops';
>> } else {
>> echo 'ok';
>> }
>> ?>
>>
>> Try that code sample, and you'll see that it says "ok"
>>
>> What exactly are you trying to accomplish with this
>> preg_match()? What
>> exactly are you trying to filter out? I understand you want to
>> eliminate "invalid characters" but why are they invalid? I
>> ask because
>> there may be a simpler way to solve the problem, if you can
>> explain what
>> the problem is.
>>
>> Thanks,
>> Greg
>>
>> --
>> 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
attached mail follows:
I pasted this right from my PHP file, so it is correct. Just to elaborate. I
have tested this until my eyes are bleeding.
Sometimes this works sometimes it doesn't.
One minute !!!##$$ This is a test &&%% will work the way it is supposed to,
the next minute it does not.
It seems that the first time through it is fine, but on the second time and
on it is not.
So if I keep hitting submit on my form with the above string, it will be ok
on the first submit, but on subsequent submits it says there are invalid
characters.
Suffice it to say, it is wonky. It seems like it works when it wants to.
Thanks
-----Original Message-----
From: Janet Valade [mailto:jvalade
eoni.com]
Sent: February 18, 2007 11:07 AM
To: Beauford
Subject: Re: [PHP] Re: LOL, preg_match still not working.
Perhaps the code in your email, that is working for other people, is not
the same code that you are testing and having problems with. Perhaps you
should try clipboarding the code from the email into a file to test
yourself. Perhaps there is a typo in the code you are actually testing,
so that it is not the same as the code in the email you sent to the
list. Anyway, you can test that by clipboarding the code from your
email, like others are doing, and testing it.
Janet
Beauford wrote:
> Mails been down since this morning (sorry, that's yesterday morning).
> Anyway, not sure if this went through, so here it is again.
>
> ------
>
> The bottom line is I want to allow everything in the expression and
nothing
> else. The new line does not seem to be an issue - I can put as many
returns
> as I want, but as soon as I add some punctuation, it falls apart.
>
> As I said before, the ! and the period from my original example are
reported
> as invalid - as they are in the expression they should be valid, I'm sure
> there are other examples as well, but you can see what the problem is. If
I
> take out the ! and period from my example and leave the new lines in, it
> works fine.
>
> Thanks
>
>
>
>
>>-----Original Message-----
>>From: Gregory Beaver [mailto:greg
chiaraquartet.net]
>>Sent: February 17, 2007 12:21 PM
>>To: Beauford
>>Cc: PHP
>>Subject: [PHP] Re: LOL, preg_match still not working.
>>
>>Beauford wrote:
>>
>>>Hi,
>>>
>>>I previously had some issues with preg_match and many of
>>
>>you tried to help,
>>
>>>but the same problem still exists. Here it is again, if
>>
>>anyone can explain
>>
>>>to me how to get this to work it would be great - otherwise
>>
>>I'll just remove
>>
>>>it as I just spent way to much time on this.
>>>
>>>Thanks
>>>
>>>Here's the code.
>>>
>>> if(empty($comment)) { $formerror['comment'] = nocomments;
>>> }
>>> elseif(!preg_match('|^[a-zA-Z0-9!?
#$%^&*();:_.\\\\ /\t-]+$|',
>>>$comment)) {
>>> $formerror['comment'] = invalidchars;
>>> }
>>>
>>>This produces an error, which I believe it should not.
>>>
>>>Testing 12345. This is a test of the emergency broadcast system.
>>>
>>>WAKE UP!!!!!!
>>
>>Hi,
>>
>>Your sample text contains newlines. If you wish to allow newlines,
>>instead of " \t" you should use the whitespace selector "\s"
>>
>><?php
>>$comment = 'Testing 12345. This is a test of the emergency
>>broadcast system.
>>
>>WAKE UP!!!!!!';
>>if(!preg_match('|^[a-zA-Z0-9!?
#$%^&*();:_.\\\\\s/-]+$|', $comment)) {
>> echo 'oops';
>>} else {
>> echo 'ok';
>>}
>>?>
>>
>>Try that code sample, and you'll see that it says "ok"
>>
>>What exactly are you trying to accomplish with this
>>preg_match()? What
>>exactly are you trying to filter out? I understand you want to
>>eliminate "invalid characters" but why are they invalid? I
>>ask because
>>there may be a simpler way to solve the problem, if you can
>>explain what
>>the problem is.
>>
>>Thanks,
>>Greg
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
>
--
Janet Valade -- janet.valade.com
attached mail follows:
Beauford wrote:
> I pasted this right from my PHP file, so it is correct. Just to elaborate. I
> have tested this until my eyes are bleeding.
>
> Sometimes this works sometimes it doesn't.
>
> One minute !!!##$$ This is a test &&%% will work the way it is supposed to,
> the next minute it does not.
>
> It seems that the first time through it is fine, but on the second time and
> on it is not.
> So if I keep hitting submit on my form with the above string, it will be ok
> on the first submit, but on subsequent submits it says there are invalid
> characters.
>
> Suffice it to say, it is wonky. It seems like it works when it wants to.
The problem is in the rest your code, not the regex, otherwise it would
fail every time. Please post the code after removing sensitive
passwords and other information, but leave as unaltered as possible.
Only then can anyone help debug this problem.
Thanks,
Greg
attached mail follows:
Hello everyone,
I'm planning to put up a local classified ads website and I'm looking
for an open-source script for this.
I've already had some links from Google and Sourceforge but I'd like
to get some opinions on people who've already run a classifieds
website as to what they're using and what they think of it.
Best Regards,
Matt
--
Stand before it and there is no beginning.
Follow it and there is no end.
Stay with the ancient Tao,
Move with the present.
attached mail follows:
hai
I am doing MCA in India ,now i am doing final year project in php
language,my project title is "importing contact from gmail" any one know the
coding in php language help me.
my id:kumar_7584
yahoo.co.in
--
View this message in context: http://www.nabble.com/importing-contacts-tf3256650.html#a9054316
Sent from the PHP - General mailing list archive at Nabble.com.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]