Re: [PHP-DB] Random numbers?

2002-02-03 Thread Patrik Wallstrom

On sön, 03 feb 2002, Chris Payne wrote:

 Hi there everyone,
 
 I need to generate a random number between 1 and 15 for insertion into a 
 DB, I can easily do the DB side of it but what is the best method for
 quickly generating a random number between 1 and 15 (including 1 and 15  
 in the equation)?

srand((double)microtime()*100);
$randomnumber = rand(1,15);

Something like this?

--
patrik_wallstrom-foodfight-[EMAIL PROTECTED]+46-709580442

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] crypt and decrypt and xor

2002-01-15 Thread Patrik Wallstrom

On Tue, 15 Jan 2002, Thomas omega Henning wrote:

 Hello All,

 Does PHP have a crypt and decrypt algorithm?

You have the crypt() function, and more crypto algorithms can be found in
the mcrypt package.

 Is xor supported by php and can you give me some examples for it?

$c = $p ^ $k

^ is the XOR operator.

--
patrik_wallstrom-foodfight-[EMAIL PROTECTED]+46-709580442


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] MySQL Persistent connection is TOO persistent???

2001-08-28 Thread Patrik Wallstrom

On Tue, 28 Aug 2001, Brian Grayless wrote:

 Gotta problem

 For some reason, many of my persistent connections aren't terminating. I end
 up with up to 30 connections to MySQL that aren't being used. My guess is
 that the user connection is slow and  the script never finishes running or
 something.

 Is there a way to get all my connections to close, or is there a PHP script
 that can close any unused connections???

Regarding persistent connections, this is how I believe it works:
In apache httpd.conf you have:
MinSpareServers 5
MaxSpareServers 10

The MaxSpareServers gives you the maximum of apache daemons running
simultaneously.

In php.ini, you have these statements:
mysql.max_persistent= -1

-1 is default, change this to the number of maximum persistent connections
per apache daemon. This will give you the following formula:

total_persistent_connections = MaxSpareServers * mysql.max_persistent

The MySQL-configuration my.cnf:

set-variable= max_connections=255
set-variable= wait_timeout=3600

Make sure that total_persistent_connections is less than max_connections,
to give you some overhad for non persistent connections and other mysql
sessions. The wait_timeout variable is simply the maximum idle time for a
connection to exist. Lower it if you have still have problems with the php
persistent connections.

This should really be in the FAQ.

--
 patrik wallstrom |  f o o d f i g h t
 tel: +46-8-6188428   |  s t o c k h o l m
 gsm: +46-709580442   |  - - - - - - - - -


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Escaping queries in php using InterBase

2001-08-22 Thread Patrik Wallstrom

On Wed, 22 Aug 2001, Yves Glodt wrote:

 Hello,

 I'm in trouble with my current project which uses Interbase as backend.
 (php.ini: magic_quotes_sybase = On)
 When I insert a string containing a ', like Beverly D'Angelo,
 php saves it with two '
 When I insert it with two ', it gets saved with four '

[...]

I have always wondered why there is no mysql specifig quoting functions in
php. Here is what I use:

function myslashes($content = ) {
$content = str_replace(\\,,$content);
$content = str_replace(',\\',$content);
return $content;
}

I guess Interbase also uses backslash for quoting?

--
 patrik wallstrom |  f o o d f i g h t
 tel: +46-8-6188428   |  s t o c k h o l m
 gsm: +46-709580442   |  - - - - - - - - -


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Insert Update

2001-08-04 Thread Patrik Wallstrom

On Sat, 4 Aug 2001, Joris Kluivers wrote:

 is there a mysql query that inserts into a database, but if the item
 already exists it does not insert but updates?

replace into

--
 patrik wallstrom |  f o o d f i g h t
 tel: +46-8-6188428   |  s t o c k h o l m
 gsm: +46-709580442   |  - - - - - - - - -


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]