php-general Digest 13 Nov 2006 05:47:23 -0000 Issue 4456
Topics (messages 244524 through 244542):
Re: spot the mistake
244524 by: Jochem Maas
244529 by: Robert Cummings
244530 by: Curt Zirzow
244531 by: Robert Cummings
Re: activation through email
244525 by: Jochem Maas
Re: PHP product licensing...
244526 by: Rory Browne
Re: Encoder efficiency
244527 by: Jochem Maas
Re: PEAR::MDB2 andquery
244528 by: Alain Roger
Parsing brackets in text
244532 by: Dotan Cohen
244533 by: Chris
244534 by: Dotan Cohen
244535 by: Dotan Cohen
244536 by: Chris
244537 by: Chris
244538 by: Dotan Cohen
Mysql strategy
244539 by: Dotan Cohen
244540 by: Chris
Re: How do you do the ? mark after a filename
244541 by: Thomas Bonham
244542 by: J R
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Ross wrote:
> echo ('<a href="#"
> onclick="window.open(\'news/old_news_list.php?month=$j&year='.$i.'\',\'\',\'width=700,height=500\');
> return false \" >$thisMonth</a>');
>
t my first guess is that you've back-slashed something you
shouldn't have - try breaking it down (and/or looking at the html source) ...
$url = "news/old_news_list.php?month=$j&year=$i";
$js = "window.open('%s','','width=700,height=500'); return false;";
$lnk = '<a href="#" onclick=".$js." >%s</a>
printf($lnk, $url, $thisMonth);
>
> I am trying to get this to open in a popup however it doess not open and I
> cannot work out why. Must be a syntax arror as the page displays ok.
>
>
> Ross
>
--- End Message ---
--- Begin Message ---
On Sun, 2006-11-12 at 15:21 +0000, Ross wrote:
> echo ('<a href="#"
> onclick="window.open(\'news/old_news_list.php?month=$j&year='.$i.'\',\'\',\'width=700,height=500\');
> return false \" >$thisMonth</a>');
>
>
> I am trying to get this to open in a popup however it doess not open and I
> cannot work out why. Must be a syntax arror as the page displays ok.
$j and $thisMonth need to be moved outside of the string so that PHP
will expand their values.
Not sure if that will fix the popup not opening at all issue.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
On 11/12/06, Ross <[EMAIL PROTECTED]> wrote:
echo ('<a href="#"
onclick="window.open(\'news/old_news_list.php?month=$j&year='.$i.'\',\'\',\'width=700,height=500\');
return false \" >$thisMonth</a>');
Just remove any question on what is wrong:
$thisUrl = "news/old_news_list.php?month=$j&year=$i";
?>
<a href="<?php echo $thisUrl;?>"
onClick="window.open('<?php echo
$thisUrl;>','','width=700,height=500'); return false;"
>$thisMonth</a>
<?php
- No wierd escaping stuff. (.\',\'\',\''.'\',')
- Clear on what you are doing.
- javascript broke? it will still work
I am trying to get this to open in a popup however it doess not open and I
cannot work out why. Must be a syntax arror as the page displays ok.
if it was a syntax error, the page would not display.
curt.
--- End Message ---
--- Begin Message ---
On Sun, 2006-11-12 at 11:36 -0800, Curt Zirzow wrote:
> On 11/12/06, Ross <[EMAIL PROTECTED]> wrote:
> >
> > echo ('<a href="#"
> > onclick="window.open(\'news/old_news_list.php?month=$j&year='.$i.'\',\'\',\'width=700,height=500\');
> > return false \" >$thisMonth</a>');
>
> Just remove any question on what is wrong:
>
> $thisUrl = "news/old_news_list.php?month=$j&year=$i";
> ?>
> <a href="<?php echo $thisUrl;?>"
> onClick="window.open('<?php echo
> $thisUrl;>','','width=700,height=500'); return false;"
> >$thisMonth</a>
> <?php
Switching in and out of PHP mode... YUCK :B
Yeah, yeah I know... cue the "PHP was originally designed as a template
language..." *barf* ;)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Ahmad Al-Twaijiry wrote:
> Hi everyone
>
> I have a site with around 1000 new users everyday, and when every user
> register my scripts will send a random password to his email.
that many users everyday? might be time to invest in a programmer or 2?
even if your site generates no income there must be some revenue generation
potential that could attract investment. no?
>
> the problem is that I got many users (specially hotmail users)
> complain that they didn't receive any email (even in the hotmail junk
> box).
>
> I know that hotmail is filtering me as a possibly a spammer (because I
> use a shared mail server) and there is nothing I can do about this.
there are probably quite a few things you can do to make you
emails appear less spammy than they do now - don't use HTML, include a
valid sender address, er ... check the web and the archives for plenty of
good advice on making emails your site send less spammy-looking.
> now I stooped sending the password to the users email and I just make
> the user chose his own password and he can login directly without the
> need to check his email for the password.
>
> but the problem now is that many users are registering with a fake
> emails :(
>
> so I want to ask you if you have any solution for this ? how can I (in
> someway) make my scripts check if the email is valid and exists email
> before I register him without the need to send any password or
> activation link to his email ?
someone else pointed out that you could use the MX server to ask whether
an account exists ... this is a potentiall slow process and should be done
as a batch job (e.g. using cron to run a email addr checking script once a day)
>
> do you have any idea ?
>
> Thanks
>
>
--- End Message ---
--- Begin Message ---
Google for ASP Loophole.
On 11/12/06, Jon Anderson <[EMAIL PROTECTED]> wrote:
I'll get right to the point, then explain after... I'm looking to
release some PHP code as partially open-source. Basically a GPL-like
license for non-commercial use, and proprietary license for anyone else.
I'm wondering about people's experience with various licenses
(open-source or not). I'd be really glad to hear opinions and
experiences about any successes and failures.
As for my reasoning:
As I understand it (correct me if I'm wrong), the GPL leaves some holes
with regards to code used internally within a company (especially web
stuff) where GPL'd PHP code can be used and changed internally by that
company without returning changes even if the code is used in a
public-facing website - so long as they don't re-distribute the software.
I've read through a bunch of other licenses, but I'm no lawyer. So
rather than jumping blindly, I thought I'd seek out the opinions of
those who've been there. There's no substitute for the concrete
experience. :-)
I really like the idea of open-source software, so I would very much
like to release my code so that it can benefit the open-source
community, but make sure that commercial use is appropriately controlled
at the same time.
Please reply to the list only, no need to cc.
Cheers,
jon
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
> Hi,
>
> What is Zend Encoder efficency.
dunno, ask Zend. ;-)
> After encoding shall we assume our code was
> safe...
well safety != efficiency for one, secondly it depends on
you definition of safe.
it's fairly safe from people trying to read/understand the source
code - although I doubt it's 100% safe from someone with the skills
and desire to decode (and/or unobsfucate) the source enough to
get a reasonable understanding of the inner workings.
if you code is safe in terms of usage ... that depends on whether
what you wrote ... no ammount of encoding will fix any XSS, SQl-injection,etc
vulnerabilities your code may contain.
>
> Or what should we expected
>
> Regards
>
> Sancar
>
--- End Message ---
--- Begin Message ---
I'm still debugging the MDB2 issue that i have.
in fact, my problem comes from :
if (!PEAR::loadExtension($this->phptype)) {
return $this->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
'extension '.$this->phptype.' is not compiled into PHP',
__FUNCTION__);
}
from connect function located in MDB2.
even if the extension php_pgsql.dll is loaded by php.ini, it seems that PEAR
is not able to see it.
Maybe creators of this package could track this bug or at least investigate
with.
Because when i control via phpinfo(), pgsql module is loaded normally... the
proof is that i can use pgsql without PEAR on my web pages without problem.
So i will investigate more, the PEAR::loadExtension($this->phptype) function
because there is the mistake.
Alain
On 11/12/06, Alain Roger <[EMAIL PROTECTED]> wrote:
Hi,
I'm still wondering how are linked MDB2 class and MDB2_Driver_pgsql class.
when i analyze the code of DB.php and pgsql.php, it's clear that DB.phpcheck a
class based on phptype and therefore include the
pgsql.php file.
But i did not find something similar in MDB2.php.
i would like to understand how can i do execute a query via MDB2 class on
a postgreSQL DB.
here is my code and for sure it does not work.
the $db2->query(); is not a function from MDB2...only from
MDB2_Driver_pgsql class.
global $dsn;
$options = array('debug' => 2,
'portability' => MDB2_PORTABILITY_ALL,
);
$query = 'SELECT * from sp_u_001(\'all\')';
$db2 = & new MDB2();
$db2->connect($dsn);
if (MDB2::isError($db2))
{
die("Error connection :
".$db2->getMessage()."<br><br>".$res->getUserinfo());
}
$res =$db2->query($query);
if (MDB2::isError($res))
{
die("Error connection :
".$res->getMessage()."<br><br>".$res->getUserinfo());
}
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
--- End Message ---
--- Begin Message ---
I need to replace text enclosed in brackets with links. How can I get
that text, though? I've tried numerous variations of the following,
with no success:
$articleText=preg_replace('/\[[a-z]]/i' , makeLink($1), $articleText);
I cannot get the text between the brackets send to the makeLink
function. Could someone push me in the right direction? An example of
the text would be:
$articleText="Ajax is an acronym of Asynchronous [JavaScript] and [XML]";
Where I'd like the strings "JavaScript" and "XML" sent to the makeLink
function. Thanks in advance.
Dotan Cohen
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
I need to replace text enclosed in brackets with links. How can I get
that text, though? I've tried numerous variations of the following,
with no success:
$articleText=preg_replace('/\[[a-z]]/i' , makeLink($1), $articleText);
I cannot get the text between the brackets send to the makeLink
function. Could someone push me in the right direction? An example of
the text would be:
$articleText="Ajax is an acronym of Asynchronous [JavaScript] and [XML]";
Where I'd like the strings "JavaScript" and "XML" sent to the makeLink
function. Thanks in advance.
Don't know if this is your problem but you need to escape the trailing ]
as well:
preg_replace('/\[[a-z]\]/i', .....
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 12/11/06, Chris <[EMAIL PROTECTED]> wrote:
Dotan Cohen wrote:
> I need to replace text enclosed in brackets with links. How can I get
> that text, though? I've tried numerous variations of the following,
> with no success:
> $articleText=preg_replace('/\[[a-z]]/i' , makeLink($1), $articleText);
>
> I cannot get the text between the brackets send to the makeLink
> function. Could someone push me in the right direction? An example of
> the text would be:
> $articleText="Ajax is an acronym of Asynchronous [JavaScript] and [XML]";
>
> Where I'd like the strings "JavaScript" and "XML" sent to the makeLink
> function. Thanks in advance.
Don't know if this is your problem but you need to escape the trailing ]
as well:
preg_replace('/\[[a-z]\]/i', .....
Thanks, but that wasn't quite it, either. This code:
<?php
function makeLink($title) {
$returnString="<b>$title</b>";
return $returnString;
}
$articleText="This is a very [long] string.";
$articleText=preg_replace('/\[[a-z]\]/i' , makeLink($1), $articleText);
print $articleText;
?>
produces this error:
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE
or '$' in /home/user/public_html/testpage.php on line 9
I'm sorry that I didn't include the error message in my original
email. Also, I got the same error with and without the last closing
bracket escaped.
Dotan Cohen
http://simplesniff.com/
--- End Message ---
--- Begin Message ---
On 13/11/06, Chris <[EMAIL PROTECTED]> wrote:
Dotan Cohen wrote:
> On 12/11/06, Chris <[EMAIL PROTECTED]> wrote:
>> Dotan Cohen wrote:
>> > I need to replace text enclosed in brackets with links. How can I get
>> > that text, though? I've tried numerous variations of the following,
>> > with no success:
>> > $articleText=preg_replace('/\[[a-z]]/i' , makeLink($1), $articleText);
>> >
>> > I cannot get the text between the brackets send to the makeLink
>> > function. Could someone push me in the right direction? An example of
>> > the text would be:
>> > $articleText="Ajax is an acronym of Asynchronous [JavaScript] and
>> [XML]";
>> >
>> > Where I'd like the strings "JavaScript" and "XML" sent to the makeLink
>> > function. Thanks in advance.
>>
>> Don't know if this is your problem but you need to escape the trailing ]
>> as well:
>>
>> preg_replace('/\[[a-z]\]/i', .....
>>
>
> Thanks, but that wasn't quite it, either. This code:
>
> <?php
> function makeLink($title) {
> $returnString="<b>$title</b>";
> return $returnString;
> }
>
> $articleText="This is a very [long] string.";
> $articleText=preg_replace('/\[[a-z]\]/i' , makeLink($1), $articleText);
> print $articleText;
> ?>
>
> produces this error:
> Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE
> or '$' in /home/user/public_html/testpage.php on line 9
>
> I'm sorry that I didn't include the error message in my original
> email. Also, I got the same error with and without the last closing
> bracket escaped.
Ah, completely missed that part. You can't pass "$1" through like that.
You have to do some funky quoting to do what you want in one go.
http://php.net/preg_replace
Check "Example 4. Using the 'e' modifier"
or use a callback:
http://www.php.net/manual/en/function.preg-replace-callback.php
I had looked at both of those already- with neither luck nor
understanding. I can fuddle my way through a simple regex, but that
monster has me bewildered. I'm pretty sure that preg_replace is all I
need, but I can't figure out the correct syntax for referencing a
chunk of the data.
I'm of course not asking anybody to write the regex for me, rather to
show me how it must be so that I'll know how to construct them. I saw
another, similar example on ilovejackdaniels.com where the author had
parsed Google query strings, but that example was even more confounded
than the one in TFphpM.
Dotan Cohen
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
On 12/11/06, Chris <[EMAIL PROTECTED]> wrote:
Dotan Cohen wrote:
> I need to replace text enclosed in brackets with links. How can I get
> that text, though? I've tried numerous variations of the following,
> with no success:
> $articleText=preg_replace('/\[[a-z]]/i' , makeLink($1), $articleText);
>
> I cannot get the text between the brackets send to the makeLink
> function. Could someone push me in the right direction? An example of
> the text would be:
> $articleText="Ajax is an acronym of Asynchronous [JavaScript] and
[XML]";
>
> Where I'd like the strings "JavaScript" and "XML" sent to the makeLink
> function. Thanks in advance.
Don't know if this is your problem but you need to escape the trailing ]
as well:
preg_replace('/\[[a-z]\]/i', .....
Thanks, but that wasn't quite it, either. This code:
<?php
function makeLink($title) {
$returnString="<b>$title</b>";
return $returnString;
}
$articleText="This is a very [long] string.";
$articleText=preg_replace('/\[[a-z]\]/i' , makeLink($1), $articleText);
print $articleText;
?>
produces this error:
Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE
or '$' in /home/user/public_html/testpage.php on line 9
I'm sorry that I didn't include the error message in my original
email. Also, I got the same error with and without the last closing
bracket escaped.
Ah, completely missed that part. You can't pass "$1" through like that.
You have to do some funky quoting to do what you want in one go.
http://php.net/preg_replace
Check "Example 4. Using the 'e' modifier"
or use a callback:
http://www.php.net/manual/en/function.preg-replace-callback.php
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
On 13/11/06, Chris <[EMAIL PROTECTED]> wrote:
Dotan Cohen wrote:
> On 12/11/06, Chris <[EMAIL PROTECTED]> wrote:
>> Dotan Cohen wrote:
>> > I need to replace text enclosed in brackets with links. How can I
get
>> > that text, though? I've tried numerous variations of the following,
>> > with no success:
>> > $articleText=preg_replace('/\[[a-z]]/i' , makeLink($1),
$articleText);
>> >
>> > I cannot get the text between the brackets send to the makeLink
>> > function. Could someone push me in the right direction? An
example of
>> > the text would be:
>> > $articleText="Ajax is an acronym of Asynchronous [JavaScript] and
>> [XML]";
>> >
>> > Where I'd like the strings "JavaScript" and "XML" sent to the
makeLink
>> > function. Thanks in advance.
>>
>> Don't know if this is your problem but you need to escape the
trailing ]
>> as well:
>>
>> preg_replace('/\[[a-z]\]/i', .....
>>
>
> Thanks, but that wasn't quite it, either. This code:
>
> <?php
> function makeLink($title) {
> $returnString="<b>$title</b>";
> return $returnString;
> }
>
> $articleText="This is a very [long] string.";
> $articleText=preg_replace('/\[[a-z]\]/i' , makeLink($1), $articleText);
> print $articleText;
> ?>
>
> produces this error:
> Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE
> or '$' in /home/user/public_html/testpage.php on line 9
>
> I'm sorry that I didn't include the error message in my original
> email. Also, I got the same error with and without the last closing
> bracket escaped.
Ah, completely missed that part. You can't pass "$1" through like that.
You have to do some funky quoting to do what you want in one go.
http://php.net/preg_replace
Check "Example 4. Using the 'e' modifier"
or use a callback:
http://www.php.net/manual/en/function.preg-replace-callback.php
I had looked at both of those already- with neither luck nor
understanding. I can fuddle my way through a simple regex, but that
monster has me bewildered. I'm pretty sure that preg_replace is all I
need, but I can't figure out the correct syntax for referencing a
chunk of the data.
I'm of course not asking anybody to write the regex for me, rather to
show me how it must be so that I'll know how to construct them. I saw
another, similar example on ilovejackdaniels.com where the author had
parsed Google query strings, but that example was even more confounded
than the one in TFphpM.
<?php
function makeLink($matches) {
$returnString="<b>" . $matches[1] . "</b>";
return $returnString;
}
$articleText="This is a very [long] string.";
$articleText=preg_replace_callback('/\[([a-z]+)\]/i' , "makeLink",
$articleText);
print $articleText . "\n";
?>
The callback takes whatever the regular expressions returns (alpha
characters between [ and ]) and runs it through function "makeLink".
Not sure how that will go with multiple []'s etc in the same string but
it should get you started.
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
On 13/11/06, Chris <[EMAIL PROTECTED]> wrote:
<?php
function makeLink($matches) {
$returnString="<b>" . $matches[1] . "</b>";
return $returnString;
}
$articleText="This is a very [long] string.";
$articleText=preg_replace_callback('/\[([a-z]+)\]/i' , "makeLink",
$articleText);
print $articleText . "\n";
?>
The callback takes whatever the regular expressions returns (alpha
characters between [ and ]) and runs it through function "makeLink".
Not sure how that will go with multiple []'s etc in the same string but
it should get you started.
I didn't know that I had to call the function like that- I don't
remember ever seeing it called that way. Also, I must google the
meaning of the (~+) in the regex.
Thank you very much, Chris. I very much appreciate the assistance.
Know that I am learning, not just asking for hand-holding!
Dotan Cohen
--- End Message ---
--- Begin Message ---
If I have to perform 30 LIKE searches for different keywords in a
varchar field, which strategy would be recommended:
1) 30 searches, one for each keyword
2) To select the varchar field from all the rows, and search through
them with php's array functions?
There are about 500 rows in the table, and growing. The mysql server
is on localhost, and the machine is a dedicated server running RHEL.
It's not my machine, so I'd like to be responsible with resources, as
much as I can be. Thanks in advance for any advice.
Dotan Cohen
http://what-is-what.com/what_is/ajax.html
--- End Message ---
--- Begin Message ---
Dotan Cohen wrote:
If I have to perform 30 LIKE searches for different keywords in a
varchar field, which strategy would be recommended:
1) 30 searches, one for each keyword
No. Horribly inefficient.
2) To select the varchar field from all the rows, and search through
them with php's array functions?
No. Make the database do the work.
Use full text indexing:
http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html
--
Postgresql & php tutorials
http://www.designmagick.com/
--- End Message ---
--- Begin Message ---
Thank you for that, it was a big help.
Can I also call function that way?
Again thank you for your help.
Thomas
Tom Chubb wrote:
On 12/11/06, Thomas Bonham <[EMAIL PROTECTED]> wrote:
Hi All,
I keep seeing the ? mark after many file names index.php?id=234.
So what I would like to know is how do you make them. I have heard that
they can make a programs life sampler when doing somethings with a
database.
Thank you,
Thomas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
You can retrieve variables from the URL using the GET method. This is
similar to using the POST method with data from forms.
A typical url with something like
www.domain.com/index.php?id=35&format=html would provide the page with
two variables, id & format.
It's the equivalent of putting the following in the page.
$id = 35;
$format = 'html';
This is popular with simple CMS/Templating systems where you use a
standard page and the id variable loads the relevant article text.
Hope that helps.
Tom
--- End Message ---
--- Begin Message ---
using "<form method=get...", it is automatically generated but you can also
do it manually in your anchor tag like so: <a href="
www.domain.com/index.php?id=35&format=html">click me</a>
in your php you can get its value by use of the $_GET variable.
hth,
john
On 11/13/06, Thomas Bonham <[EMAIL PROTECTED]> wrote:
Thank you for that, it was a big help.
Can I also call function that way?
Again thank you for your help.
Thomas
Tom Chubb wrote:
> On 12/11/06, Thomas Bonham <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>
>> I keep seeing the ? mark after many file names index.php?id=234.
>>
>> So what I would like to know is how do you make them. I have heard that
>> they can make a programs life sampler when doing somethings with a
>> database.
>>
>> Thank you,
>>
>> Thomas
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> You can retrieve variables from the URL using the GET method. This is
> similar to using the POST method with data from forms.
> A typical url with something like
> www.domain.com/index.php?id=35&format=html would provide the page with
> two variables, id & format.
> It's the equivalent of putting the following in the page.
> $id = 35;
> $format = 'html';
>
> This is popular with simple CMS/Templating systems where you use a
> standard page and the id variable loads the relevant article text.
>
> Hope that helps.
>
> Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
GMail Rocks!!!
--- End Message ---