|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: php-general-digest-help
lists.php.netDate: Sat Sep 01 2001 - 20:19:48 CDT
php-general Digest 2 Sep 2001 01:19:48 -0000 Issue 851
Topics (messages 65598 through 65619):
loop? or conditional problem
65598 by: syaggie
FULLTEXT search sorting results
65599 by: BRACK
65617 by: Mark Maggelet
Re: The future of PHP
65600 by: Christian Reiniger
65602 by: Zeev Suraski
65603 by: Zeev Suraski
Re: formating numbers to two decimal points - money - best ways
65601 by: fx
Mdb conversion
65604 by: Rogerio Coelho - Equipeweb - CompuLand ISP
65606 by: Jeff Lewis
65607 by: Adi Wibowo
Re: Reg-Variables
65605 by: Papp Gyozo
*Great Mortgage Rates*
65608 by: turboduck.mails.ch
Re: File Upload Problem Solving?
65609 by: Marc Davenport
generate random ascii string
65610 by: bill
65611 by: Sean C. McCarthy
65612 by: Philip Olson
65613 by: bill
Re: $str[0] vs $str{0} was : generate random ascii string
65614 by: Philip Olson
65616 by: bill
Memory Usage
65615 by: Prottoss
potential preg_replace bug; unsure however
65618 by: alvarez.sto13.st-oneline.de
Re: seeking good annotate script
65619 by: Matthew A. Schneider
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:
Okay the the script is attached below. i am baffled at the problem. as you
can see the script does a rather simplistic generation of passwords. it
then writes them into two files.
the problem is the first time i run (i am running it stand alone) it works
fine and the result is two files with 32 entries (and the mysql entries are
also correct). the second time i run it. i (there should be 44 new entries
make one file with 76 entries and another with 44)
however what i get is a file with 1233 entries and another with 1201.
now i admit the code is not beautiful but my concern is more of what is
causing this. i have checked the variables both $i and $rows appear fine.
when i look at the text files what i see is it assigns the 44 entries and
then repeats them. all i can figure is it is the conditional or whiel loop?
why does it work perfect the first time??
<?php
mysql_connect("localhost:/var/run/mysql/mysql.sock");
mysql_select_db("VQRGDATA");
$letter = array("Gob", "Lol", "woZ", "Kop", "MoS", "tRu", "SAw", "NoR",
"TEf","TaF", "JoP", "lOg", "tAn", "FiSH", "cAT", "VAn", "bAb", "Mob",
"KorN", "BeAt", "roSe", "KlaP", "iZ", "GEr", "HaT", "ZaaM", "toAd", "emU");
$results = mysql_query("SELECT members.id, members.lname FROM members, users
WHERE users.id <> members.id");
$rows= mysql_num_rows($results);
if($rows != 0)
{
while($info = mysql_fetch_array($results))
{
if($info[0] != 0)
{
$ids[] = $info[0];
$lnames[] = $info[1];
}
}
mysql_free_result($results);
$i=0;
while($i < $rows-1)
{
srand((double) microtime() * 1000000);
$pass_letter_key = array_rand($letter);
srand((double) microtime() * 1000000);
$pass_num1 = mt_rand(0, 26);
srand((double) microtime() * 1000000);
$pass_num2 = mt_rand(100, 926);
$strip = trim($lnames[$i]);
$lower = strtolower($strip);
$infochop = substr($lower, -5, 4);
$username = $infochop.$pass_num2;
$password = $pass_num1. $letter[$pass_letter_key].$pass_num2;
$respass = mysql_query("SELECT password FROM users WHERE
password='$password'");
$pass_row = mysql_num_rows($respass);
if(!$pass_row)
{
mysql_query("INSERT INTO users(id, username,password) VALUES('$ids[$i]',
'$username', '$password') ");
$complete = fopen("complete.txt", "a+");
$input[] = $ids[$i]."\t".$username."\t".$password."\n";
fputs($complete, $input[$i]);
fclose($complete);
$i++;
}
mysql_free_result($respass);
}
}
$new = implode("", $input);
$newtxt = fopen("new.txt", "w");
fputs($newtxt, $new);
fclose($newtxt);
?>
attached mail follows:
I have query -
$res = mysql_query("SELECT
skits.*,category.cat_id,category.cat_name FROM skits,category WHERE
MATCH (title,descr,skits) AGAINST ('%$search_idea%') and skits.lang
like 'English' and skits.category like category.cat_id limit $limit,10 ");
I expect to get results sorted by relevance and it actually does BUT (!)
inside of categories =( I mean it sorts result first by category and
second by relevance. How do I make it to be sorted by only relevance?
Thank you in advance,
Youri
<>< <>< <>< <>< God is our provider ><> ><> ><> ><>
http://www.body-builders.org
attached mail follows:
On Sat, 1 Sep 2001 14:01:57 +0200, BRACK (brak
nettaxi.com) wrote:
>I have query -
>
>$res = mysql_query("SELECT
>skits.*,category.cat_id,category.cat_name FROM skits,category WHERE
>MATCH (title,descr,skits) AGAINST ('%$search_idea%') and skits.lang
>like 'English' and skits.category like category.cat_id limit
>$limit,10 ");
>
>I expect to get results sorted by relevance and it actually does BUT
>(!)
>inside of categories =( I mean it sorts result first by category and
>second by relevance. How do I make it to be sorted by only
relevance?
try it like this:
$res = mysql_query("SELECT
skits.*,category.cat_id,category.cat_name,MATCH (title,descr,skits)
AGAINST ('%$search_idea%') as relevance FROM skits,category WHERE
skits.lang like 'English' and skits.category like category.cat_id
having relevance>0 order by relevance desc limit $limit,10 ");
attached mail follows:
On Friday 31 August 2001 15:22, Manuel Lemos wrote:
> > I actually mention PHP-GTK in my sessions. I mention it as an
> > anecdote, much like I mention some of the other interesting modules
> > and projects in PHP (e.g., PEAR). I'm really not sure why people
> > think I'm trying to bury PHP-GTK. Just because I don't see PHP-GTK
> > as a main course of PHP, doesn't mean I don't think it's an important
> > and useful project.
>
> Oh, man, do you really do that? That is worse than not mention it at
> all. You may be joking but not everybody may understand it that way.
> Doing that you ruining the credibility of those efforts that take PHP
> far out what originally it was meant for. If you are going to just make
> it a joke, you'd better not mention it at all. I think that is
Heyheyhey, cool down. Anecdote != Joke. That's important. "Anecdote" in
this context simply means an "and by the way, there also other
interesting uses for PHP: ..."
Actually that's just what you wanted him to say :)
> > >In this company, they have choose Microsoft stuff because they think
> > > it is the right choice for what they do. For some things, PHP could
> > > be a better choice, but it would be hard to convince who is in
> > > charge above me because PHP does not benefit of a great credibility
> > > in the market that would help me to make a good case to switch to
> > > PHP.
> >
> > In the US (and perhaps in the rest of America), that's relatively
> > true. That's not the case in Europe or the far east. It has a lot
> > to do with mentality and corporate culture.
>
> So, what? Even if it is like you say, because you have this perception
> that it is not that way in Europe and far east, you are not going to do
> anything to help people living in the Americas to make a better case
> for PHP in the corporate world?
Much can be done - we all know that. But:
(1) Most of that requires either mucho $$ or heaps|truckloads|... of
time. Rasmus certainly has neither and the zend people already spend
their time doing the really important thing (improving the language).
So such marketing campaigns have to come from other people.
(2) American corporate culture (hmm, rhymes with "vulture"... :) listens
to the players with the most money. MS, Sun, Oracle, ...
So the only marketing plan that has a good chance to work is "Somehow
make about 5 billion dollars within a year and burn half of it for glossy
ads etc".
I certainly won't do this...
(3) http://php.net/usage.php
Period.
Marketing really isn't the most important thing to do :)
Conclusion:
PHP's future looks bright, everyone is working hard to make it even
brighter, and we all can dance happily around on the flowery meadows
(except when working of course :)
-- Christian Reiniger LGDC Webmaster (http://lgdc.sunsite.dk/)Error 032: Recursion error - see error 032
attached mail follows:
At 16:22 31-08-01, Manuel Lemos wrote: >Oh, man, do you really do that? That is worse than not mention it at >all. You may be joking but not everybody may understand it that way. >Doing that you ruining the credibility of those efforts that take PHP >far out what originally it was meant for. If you are going to just make >it a joke, you'd better not mention it at all. I think that is extremely >unfair for people like Andrei and other that worked so much on it! :-(
Uhm, I'm not joking. Richard pointed out to me in a personal letter that anecdote may not be the right word here (thanks, Richard :). I mention them (PHP-GTK, PEAR, etc) at the end of my presentations, as a list of pointers people should look into if they have interest in that particular subject.
Manuel, you should *REALLY* relax about this 'Zeev vs. PHP-GTK'. This is absolutely the last time I'm going to say it - I have nothing against PHP-GTK, and Andrei and I work very well together.
>So, what? Even if it is like you say, because you have this perception >that it is not that way in Europe and far east, you are not going to do >anything to help people living in the Americas to make a better case for >PHP in the corporate world?
No, that's not what I'm saying. I'm not going to say what I was saying again, though. Look in my old posts if you're interested...
Zeev
attached mail follows:
At 14:52 01-09-01, Christian Reiniger wrote: >On Friday 31 August 2001 15:22, Manuel Lemos wrote: > > > I actually mention PHP-GTK in my sessions. I mention it as an > > > anecdote, much like I mention some of the other interesting modules > > > and projects in PHP (e.g., PEAR). I'm really not sure why people > > > think I'm trying to bury PHP-GTK. Just because I don't see PHP-GTK > > > as a main course of PHP, doesn't mean I don't think it's an important > > > and useful project. > > > > Oh, man, do you really do that? That is worse than not mention it at > > all. You may be joking but not everybody may understand it that way. > > Doing that you ruining the credibility of those efforts that take PHP > > far out what originally it was meant for. If you are going to just make > > it a joke, you'd better not mention it at all. I think that is > >Heyheyhey, cool down. Anecdote != Joke. That's important. "Anecdote" in >this context simply means an "and by the way, there also other >interesting uses for PHP: ..." >Actually that's just what you wanted him to say :)
Oh, so it *was* the right word? :)
Zeev
attached mail follows:
if your datas are stored in a DB you should specify the precision of the float in the table : float(8,2)
> Anyone have functions for formatting numbers being multiplied by variables > and whatnot to two decimal points - rounded up? As for displaying total > cost, etc? > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com >
attached mail follows:
Hi, Folks !!
I am in trouble. I need to convert a mdb database to mysql. Can PHP handle this? Where can I learn about it?
Thanks in advance.
[]īs Rogerio Coelho. Equipeweb - CompuLand Design http://www.equipeweb.com.br Tel/Fax:(xx) 24 237-2088
attached mail follows:
I needed this recently as well and found some converters right here:
http://www.mysql.com/documentation/mysql/bychapter/manual_Contrib.html#SEC60 7
They usually are run from within the MDB macros but it helped me convert my database over :)
Jeff
----- Original Message -----
From: "Rogerio Coelho - Equipeweb - CompuLand ISP"
<rogerio
compuland.com.br>
To: <php-general
lists.php.net>
Sent: Saturday, September 01, 2001 9:40 AM
Subject: [PHP] Mdb conversion
Hi, Folks !!
I am in trouble. I need to convert a mdb database to mysql. Can PHP handle this? Where can I learn about it?
Thanks in advance.
[]īs Rogerio Coelho. Equipeweb - CompuLand Design http://www.equipeweb.com.br Tel/Fax:(xx) 24 237-2088
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribelists.php.net For additional commands, e-mail: php-general-help
lists.php.net To contact the list administrators, e-mail: php-list-admin
lists.php.net
attached mail follows:
On Sat, 1 Sep 2001, Rogerio Coelho - Equipeweb - CompuLand ISP wrote: > Hi, Folks !! > > I am in trouble. I need to convert a mdb database to mysql. > Can PHP handle this? Where can I learn about it? > > Thanks in advance.
It doesn't need PHP to convert access to mysql. Just go to mysql.com and search for convertion script (vb) to be included into mdb and run it.
You will get two text files (consist of SQL scripts that create tables and insert data). Use those files as scripts for mysql.
Adi Wibowo ------ http://dewey.petra.ac.id
* Work matter : adiw
petra.ac.id
* Private matter : adiwibowo
excite.com
------------------------------------------
attached mail follows:
Hi,
On Linux/Unix systems you may use Semaphore and shared memory functions. http://www.php.net/manual/en/ref-sem.php
or simply use sessions. However, session variables are stored in flat files or in db.
----- Original Message -----
From: senthilvellan <senthil_kovai
yahoo.com>
To: <php-general
lists.php.net>
Sent: Saturday, September 01, 2001 7:08 AM
Subject: [PHP] Reg-Variables
Hello Techies,
Is it possible to have our own global variables that can be shared between more than one programs in php.Is there any other go to share between programs(Other than flat files and database).Any help is appreciate.
Thanks in advance, Senthilvellan.
attached mail follows:
mnu76 Whether a new home loan is what you seek or to refinance your current home loan at a lower interest rate, we can help!
Mortgage rates haven't been this low in the last 12 months, take action now!
Refinance your home with us and include all of those pesky credit card bills or use the extra cash for that pool you've always wanted...
Where others say NO, we say YES!!! Even if you have been turned down elsewhere, we can help!
Easy terms! Our mortgage referral service combines the highest quality loans with the most economical rates and the easiest qualifications!
Take just 2 minutes to complete the following form. There is no obligation, all information is kept strictly confidential, and you must be at least 18 years of age. Service is available within the United States only. This service is fast and free.
Free information request form: PLEASE VISIT
http://www.freewebhostingcentral.com/mortgagezone
****************************************************************
Since you have received this message you have either responded
to one of our offers in the past or your address has been
registered with us. If you wish to be removed please reply to:
mailto:morleads7
yahoo.com?subject=remove
****************************************************************
xqw3j
*********
attached mail follows:
On Fri, 31 Aug 2001, Jeff Oien wrote:
> I have a user who is unable to upload files but I don't know where
> to start with the troubleshooting process. I have this:
>
>
copy("$img1", "/blah/$username/$img1_name")
> or die("File upload didn't work.");
>
> and they are getting the die message. All but one person are able
> to upload.
> Jeff Oien
Check the following things. 1. Permissions. The Directory of the particular user might be set different and therefore be the reason for the upload. 2. Max File Size. I'm assuming that you are trying the same file for all people, but if not then the one person that can upload might just be uploading a smaller file than the rest. Just a thought.
You may want to use is_uploaded_file() and move_uploaded_file() if you are using PHP 4.0.2 or greater.
hope this helps cheers, marc davenport
attached mail follows:
How can a random string of only letters and numbers be generated?
I'm stumped so far on how to avoid including symbols.
attached mail follows:
Hi,
If you have random string including symbols just take them of with regexp. Look at the manual for regular expresion functions. Hope it helps.
Sean C. McCarthy SCI, s.L. (www.sci-spain.com)
bill wrote:
>
> How can a random string of only letters and numbers be generated?
>
> I'm stumped so far on how to avoid including symbols.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe
lists.php.net
> For additional commands, e-mail: php-general-help
lists.php.net
> To contact the list administrators, e-mail: php-list-admin
lists.php.net
attached mail follows:
Hi Bill,
Here's a quick hack, should get you on your way :
function randomString($len) { global $seed;
$tmp = '';
$chars = 'abcdefghijklmnopqrstuvwxyz'; $chars .= strtoupper($chars); $chars .= '0123456789';
if (empty($seed)) { mt_srand ((float) microtime() * 1000000); $seed = TRUE; }
// weak error checking mechanism if ($len < 1 || !is_numeric($len)) $len = 8;
$chars_len = strlen($chars);
for ($a=1; $a <= $len; $a++) { $tmp .= $chars{mt_rand(0,$chars_len)}; }
return $tmp; }
That was fun :)
Regards, Philip Olson
On Sat, 1 Sep 2001, bill wrote:
> How can a random string of only letters and numbers be generated?
>
> I'm stumped so far on how to avoid including symbols.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe
lists.php.net
> For additional commands, e-mail: php-general-help
lists.php.net
> To contact the list administrators, e-mail: php-list-admin
lists.php.net
>
attached mail follows:
Philip,
With a few tweaks, it works great, thanks!
Here's what worked:
function randomString($len) { global $seed;
$tmp = '';
$chars = 'abcdefghijklmnopqrstuvwxyz'; $chars .= strtoupper($chars); $chars .= '0123456789';
if (empty($seed)) { mt_srand ((float) microtime() * 1000000); $seed = TRUE; }
// weak error checking mechanism if ($len < 1 || !intval($len)) $len = 8;
$chars_len = strlen($chars);
for ($a=1; $a <= $len; $a++) { $tmp .= $chars[mt_rand(0,$chars_len)]; }
return $tmp; }
Philip Olson wrote:
> Hi Bill,
>
> Here's a quick hack, should get you on your way :
>
> function randomString($len)
> {
> global $seed;
>
> $tmp = '';
>
> $chars = 'abcdefghijklmnopqrstuvwxyz';
> $chars .= strtoupper($chars);
> $chars .= '0123456789';
>
> if (empty($seed)) {
> mt_srand ((float) microtime() * 1000000);
> $seed = TRUE;
> }
>
> // weak error checking mechanism
> if ($len < 1 || !is_numeric($len)) $len = 8;
>
> $chars_len = strlen($chars);
>
> for ($a=1; $a <= $len; $a++) {
> $tmp .= $chars{mt_rand(0,$chars_len)};
> }
>
> return $tmp;
> }
>
> That was fun :)
>
> Regards,
> Philip Olson
>
> On Sat, 1 Sep 2001, bill wrote:
>
> > How can a random string of only letters and numbers be generated?
> >
> > I'm stumped so far on how to avoid including symbols.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe
lists.php.net
> > For additional commands, e-mail: php-general-help
lists.php.net
> > To contact the list administrators, e-mail: php-list-admin
lists.php.net
> >
attached mail follows:
It appears the only change you made was :
> $tmp .= $chars[mt_rand(0,$chars_len)];
From :
> > $tmp .= $chars{mt_rand(0,$chars_len)};
Which is strange. the [] use on strings has been depreciated in favor of {} as of php4 but I don't know at what version {} came into being exactly. What version of PHP are you running, php3? Or, does anyone know much about this?
Anyway, glad it works :)
For informational purposes, this depreciation is stated here :
http://www.php.net/manual/en/language.types.string.php
And for those watching at home, am referring to :
$string = 'abc';
print $string[0]; // depreciated (might not work one day, when?)
vs.
print $string{0};
Both print 'a' though.
Regards, Philip Olson
attached mail follows:
Hi Philip,
Yes, I have a choice of PHP3 or 4 and this script happened to be in PHP 3 so I just tweaked it. I didn't realize that one day $chars[mt_rand(0,$chars_len)] would "no longer work", but at least it is backwards compatible now. I've made a mental note of that for future reference.
PHP 3 also barked at
is_numeric()
which I just changed to intval()
I should really do better bounds checking. How about:
$len=intval($len); if (!$len) $len=8;
kind regards,
bill
Philip Olson wrote:
> It appears the only change you made was : > > > $tmp .= $chars[mt_rand(0,$chars_len)]; > > >From : > > > > $tmp .= $chars{mt_rand(0,$chars_len)}; > > Which is strange. the [] use on strings has been depreciated in favor > of {} as of php4 but I don't know at what version {} came into being > exactly. What version of PHP are you running, php3? Or, does anyone know > much about this? > > Anyway, glad it works :) > > For informational purposes, this depreciation is stated here : > > http://www.php.net/manual/en/language.types.string.php > > And for those watching at home, am referring to : > > $string = 'abc'; > > print $string[0]; // depreciated (might not work one day, when?) > > vs. > > print $string{0}; > > Both print 'a' though. > > Regards, > Philip Olson
attached mail follows:
Is it possible to profile the memory usage of a php script? I am trying to determine why do certain scripts claim to reach the 8meg memory limit although not appear to do anything that would result in large memory usage.
Prottoss
attached mail follows:
I built a Perl-style regex to match function calls in C-like languages where $name is the functions name. The functions are assumed to accept a single string as parameter.
Here it is.
/$name\s*\(\s*\"(.*)\"\s*\)\s*;/s
The expression is successfully preg_match'ed on a stream of code, but when preg_replace is passed the same expression it does not return. The piece of code I tested this with was fairly small so that an increased demand of computation time is unlikely be the reason for this behaviour.
Substituting the subexpression (.*) by ([^\"]*) remedies this.
The version of the PHP install is 4.05.
Any ideas?
D. Alvarez Arribas <alvarez
st-oneline.net>
attached mail follows:
Daniel,
It doesn't get much easier than Philip Greenspun's "Loquacious" (http://www.greenspun.com/com/home.html). Philip begins the description of his free comment server thusly:
"You have a Web server with static pages. You want users to be able to add comments dynamically to any of your pages. However, you don't want to turn all of your Web pages into computer programs. You don't want to sweat your way through all of Web Tools Review and learn how to run your own Relational Database Management System-backed Web site. You don't want to spend the rest of your life backing up and maintaining the relational database."
Try it you'll like it. It's not PHP though (TCL likely).
Best regards,
Matthew A. Schneider
matsch
sasites.com
----- Original Message -----
From: "daniel goldin" <daniel
blue-lamp.com>
To: <php-general
lists.php.net>
Sent: Friday, August 31, 2001 10:31 PM
Subject: [PHP] seeking good annotate script
>
> I'm looking for a good script that implements an
> annotation function--much like the manual at php.net. Anybody
> know where I could find such a beast?
>
>
> Daniel Goldin
> daniel
blue-lamp.com
> 323-225-1926
>
> www.blue-lamp.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe
lists.php.net
> For additional commands, e-mail: php-general-help
lists.php.net
> To contact the list administrators, e-mail: php-list-admin
lists.php.net
>
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]