php-general Digest 10 Feb 2008 11:59:02 -0000 Issue 5285
php-general Digest 10 Feb 2008 11:59:02 - Issue 5285 Topics (messages 269014 through 269022): Better DB Class MySQL 269014 by: nihilism machine 269015 by: Larry Garfield 269016 by: Nathan Nobbe 269017 by: Robert Cummings urgent !!! Please Help preg_replace ! 269018 by: LKSunny 269019 by: Robert Cummings 269020 by: LKSunny strtotime 269021 by: Ron Piggott 269022 by: Ron Piggott 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] -- ---BeginMessage--- Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. ?php class db { // Members public $db_user = ; public $db_pass = ; public $db_name = ; public $db_server = ; public $link; public $result_id; // Methods public function __construct() { $this-connect(); } // Connect to MySQL Server public function connect() { $this-link = mysql_connect($this-db_server,$this-db_user,$this- db_pass) or die(Error: Cannot Connect to DataBase); mysql_select_db($this-db_name,$this-link) or die(Error: Cannot Select Database ( . $this-db_name . )); } // MySQL Query public function query($sql) { $this-result_id = mysql_query($sql); return $this-fetch_rows(); } // MySQL Query public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } // MySQL Fetch Rows public function fetch_rows() { $rows = array(); if($this-result_id){ while($row = mysql_fetch_object($this-result_id)) { $rows[] = $row; } } return $rows; } // MySQL Affected Rows public function num_rows() { return mysql_num_rows($this-link); } // MySQL Affected Rows public function select_id() { return mysql_insert_id($this-link); } // Disconnect from MySQL Server public function disconnect() { mysql_close($this-link); } // Terminator Style Function simply in coolness public function Terminator($tbl) { } // Destruct! public function __destruct() { $this-disconnect(); } } ? ---End Message--- ---BeginMessage--- http://www.php.net/pdo All the cool kids are doing it. On Saturday 09 February 2008, nihilism machine wrote: Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. ?php class db { // Members public $db_user = ; public $db_pass = ; public $db_name = ; public $db_server = ; public $link; public $result_id; // Methods public function __construct() { $this-connect(); } // Connect to MySQL Server public function connect() { $this-link = mysql_connect($this-db_server,$this-db_user,$this- db_pass) or die(Error: Cannot Connect to DataBase); mysql_select_db($this-db_name,$this-link) or die(Error: Cannot Select Database ( . $this-db_name . )); } // MySQL Query public function query($sql) { $this-result_id = mysql_query($sql); return $this-fetch_rows(); } // MySQL Query public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } // MySQL Fetch Rows public function fetch_rows() { $rows = array(); if($this-result_id){ while($row = mysql_fetch_object($this-result_id)) { $rows[] = $row; } } return $rows; } // MySQL Affected Rows public function num_rows() { return mysql_num_rows($this-link); } // MySQL Affected Rows public function select_id() { return mysql_insert_id($this-link); } // Disconnect from MySQL Server public function disconnect() { mysql_close($this-link); } //
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
this i know already, but i think can do it single regex Robert Cummings [EMAIL PROTECTED] ¼¶¼g©ó¶l¥ó·s»D:[EMAIL PROTECTED] On Sun, 2008-02-10 at 14:33 +0800, LKSunny wrote: //please run this script, you can get what problem i got $html = eof a href=aaa.htmlaaa/a a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a a href=aaa.htmlcc gd c/a a href=aaa.htmlddd 123/a eof; /* i want replace any |a.has bbb./a|, like a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a */ ?php $reps = array ( array ( 'match' = '#a.*/a#Uims', 'check' = '#bbb#', 'replace' = 'X', ), ); foreach( $reps as $criteria ) { if( preg_match_all( $criteria['match'], $html, $matches ) ) { foreach( $matches[0] as $match ) { if( preg_match( $criteria['check'], $match ) ) { $html = str_replace( $match, $criteria['replace'], $html ); } } } } ? This does what you want to $html, but it doesn't do it in a single regex. I'm not sure it can be done with a single regex, and if it can, I doubt it's simple. I don't feel like investigating too far :) 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime
I am trying to calculate what was the date 18 months ago. When I give the command: $18_months_ago = strtotime(-18 months); It comes back with: Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE How would you calculate 18 months ago from today? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strtotime
I see I broke a rule. The variable can't start with a number. Still strtotime doesn't work with -18 months How would you handle this? Ron On Sun, 2008-02-10 at 06:46 -0500, Ron Piggott wrote: I am trying to calculate what was the date 18 months ago. When I give the command: $18_months_ago = strtotime(-18 months); It comes back with: Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE How would you calculate 18 months ago from today? Ron -- [EMAIL PROTECTED] www.actsministrieschristianevangelism.org Acts Ministries Christian Evangelism Where People Matter 12 Burton Street Belleville, Ontario, Canada K8P 1E6 In Belleville Phone : (613) 967-0032 In North America Call Toll Free : (866) ACTS-MIN Fax: (613) 967-9963 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
Ron Piggott wrote: I am trying to calculate what was the date 18 months ago. When I give the command: $18_months_ago = strtotime(-18 months); It comes back with: Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE That's a plain syntactical error, it's not related to strtotime(). Your variable name of '18_months_ago' is not valid in PHP. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
// Terminator Style Function simply in coolness public function Terminator($tbl) { } Terminator? Is this something I don't know about or is it simply a method that goes around killing other methods? Anyhoo, you may want to look at this: http://www.phpguru.org/article.php?ne_id=121 http://www.phpguru.org/pear_db_replacement/ It's a MySQL only database wrapper that mimics the PEAR::DB API, (which is, as I've been reminded a million times (roughly), obsolete), but is one sixth the size. Important if one of of your goals is speed. You could say if your goal is speed why use a wrapper at all? But it has the following advantages: 1. If you start off with PEAR::DB (for example) and then need to squeeze extra performance out of your site, the database wrapper is a good place to start (since it is generally used a lot). 2. It has useful methods (ie the get* methods) which speed up development time greatly. 3. I thought of others, but then subsequently forgot them. Doh. -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software for £299 hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
Larry Garfield wrote: http://www.php.net/pdo All the cool kids are doing it. Except that converting to converting PDO is, undoubtedly, far more work and will entail far more gotchas than the original poster wanted -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software for £299 hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime
I figured out what went wrong. Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: strtotime
Ron Piggott wrote: I see I broke a rule. The variable can't start with a number. Still strtotime doesn't work with -18 months How would you handle this? Ron Uh, it works fine here: php5 -r '$a=strtotime(-18 months); print strftime(%Y%m%d,$a); ': 20060810 /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Gzipped output
Hello, is it possible to make something like gzipped echo?. My idea was: $gzOut = gzopen('php://output','w'); but it fails with an error: bWarning/b: gzopen(php://output) [a href='function.gzopen'function.gzopen/a]: could not make seekable - php://output That script generates a large text file to download, so I thought I can gzip it somehow to make the downloads faster. The buffered way (to load all the output to some $buffer and then echo gzencode($buffer,6);) consumes too much memory. Can anyone help me with this? Best regards Jakub Cermak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gzipped output
Jakub wrote: That script generates a large text file to download, so I thought I can gzip it somehow to make the downloads faster. The buffered way (to load all the output to some $buffer and then echo gzencode($buffer,6);) consumes too much memory. You could write it to a local file, then do: header(Content-Type: application/x-gzip); Header(Content-Disposition: attached; filename=\\) passthru(gzip -c file); /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hex Strings Appended to Pathnames
Richard Lynch wrote: I don't know if it's before/after, but PHP can't change the GET request to something it wasn't... So THAT was the URL requested. You might have some kind of funky mod_rewrite rule messing you up... On Tue, January 29, 2008 5:22 am, Mick wrote: Richard Lynch wrote: On Sun, January 27, 2008 7:57 am, Mick wrote: Operating System: CentOS 4.6 PHP Version: 4.3.9-3.22.9 Zend Optimizer (free) version: 3.2.6 Hello. I've got somewhat of a strange problem here involving Squirrelmail. Basically, what is happening is that one of our customers is logged out of his Squirrelmail session at random intervals. This can occur when he goes to read an email or, after composing an email, when he clicks on the Send button. The following log entries correspond with those times that the customer is logged out. [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.php3a5def33 [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.php29e09f87 [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/move_messages.phpf9f96dfb [error] [client X.X.X.X] File does not exist: /var/www/squirrelmail/src/redirect.phpdc6cc80a So what would be the cause of appending those hex strings to those pathnames? You'll probably have to ask the squirrelMail guy... Unless you can reproduce it with other applications, it's not in PHP itself, probably. PS I'm a squirrelMail user, and I get logged out a lot too. :-( Hi Richard. Thank you for your reply. You'll probably have to ask the squirrelMail guy... I've already asked him, and he referred me to the PHP/Zend guys i.e. to here. ;) Actually, what the access logs show for these events is this for example: GET /squirrelmail/src/compose.php9e99b821 HTTP/1.1 404 GET /squirrelmail/src/redirect.php3a5def33 HTTP/1.1 404 Do you know if logging for the access log is performed before or after the URL is passed through to php? Cheers, Mick. Hi Richard. So THAT was the URL requested. As I had suspected. You might have some kind of funky mod_rewrite rule messing you up... There is no rewrite rule. It's an extremely strange problem. Cheers, Mick. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
On Feb 9, 2008 7:39 PM, Larry Garfield [EMAIL PROTECTED] wrote: http://www.php.net/pdo All the cool kids are doing it. Tried it. (Actually, I am using it for some stuff.) But I seriously hope it works better for MySQL than it does for SQL Server. Andrew
Re: [PHP] Gzipped output
Yes, I thought about this, but this has a big disadvantage - the client must wait for the file to be fully processed and compressed and then he can start downloading. I'd like to let the client start downloading the compressed parts while the further parts are still being processed and compressed - it's similar to streaming concept. I hope you can see what I mean. Jakub Čermák [EMAIL PROTECTED] ICQ 159971304 Per Jessen napsal(a): Jakub wrote: That script generates a large text file to download, so I thought I can gzip it somehow to make the downloads faster. The buffered way (to load all the output to some $buffer and then echo gzencode($buffer,6);) consumes too much memory. You could write it to a local file, then do: header(Content-Type: application/x-gzip); Header(Content-Disposition: attached; filename=\\) passthru(gzip -c file); /Per Jessen, Zürich
Re: [PHP] Gzipped output
Jakub wrote: Yes, I thought about this, but this has a big disadvantage - the client must wait for the file to be fully processed and compressed and then he can start downloading. I'd like to let the client start downloading the compressed parts while the further parts are still being processed and compressed - it's similar to streaming concept. I hope you can see what I mean. Maybe apaches mod_deflate is what you're after? That will do in-flight compression. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
Larry Garfield schreef: http://www.php.net/pdo All the cool kids are doing it. not true - some of them use firebird ;-) On Saturday 09 February 2008, nihilism machine wrote: Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. ?php class db { // Members public $db_user = ; public $db_pass = ; public $db_name = ; public $db_server = ; public $link; public $result_id; // Methods public function __construct() { $this-connect(); } // Connect to MySQL Server public function connect() { $this-link = mysql_connect($this-db_server,$this-db_user,$this- db_pass) or die(Error: Cannot Connect to DataBase); mysql_select_db($this-db_name,$this-link) or die(Error: Cannot Select Database ( . $this-db_name . )); } // MySQL Query public function query($sql) { $this-result_id = mysql_query($sql); return $this-fetch_rows(); } // MySQL Query public function insert($sql) { $this-result_id = mysql_query($sql); return $this-select_id; } // MySQL Fetch Rows public function fetch_rows() { $rows = array(); if($this-result_id){ while($row = mysql_fetch_object($this-result_id)) { $rows[] = $row; } } return $rows; } // MySQL Affected Rows public function num_rows() { return mysql_num_rows($this-link); } // MySQL Affected Rows public function select_id() { return mysql_insert_id($this-link); } // Disconnect from MySQL Server public function disconnect() { mysql_close($this-link); } // Terminator Style Function simply in coolness public function Terminator($tbl) { } // Destruct! public function __destruct() { $this-disconnect(); } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
Jochem Maas wrote: Larry Garfield schreef: http://www.php.net/pdo All the cool kids are doing it. not true - some of them use firebird ;-) Fire - what? :-) -- Richard Heyes http://www.websupportsolutions.co.uk Knowledge Base and Helpdesk software for £299 hosted for you - no installation, no maintenance, new features automatic and free ** New Helpdesk demo now available ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
On 2/10/08, Ron Piggott [EMAIL PROTECTED] wrote: I figured out what went wrong. Ron Care to share it with us? Floor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hex Strings Appended to Pathnames
On Feb 10, 2008 9:09 AM, Mick [EMAIL PROTECTED] wrote: There is no rewrite rule. It's an extremely strange problem. is this a production box; or more specifically, are you adverse to throwing xdebug on there? i suspect you could use the function tracing in xdebug to at least find out where these strange paths are coming from. -nathan
Re: [PHP] strtotime
The date value I was assigning was for a mySQL query ... a date range query. I was running my query when I hadn't assigned a date to the other date range variable. I didn't realized I hadn't copied my DATE() syntax to this area of my code. Ron On Sun, 2008-02-10 at 18:22 +0100, Floor Terra wrote: On 2/10/08, Ron Piggott [EMAIL PROTECTED] wrote: I figured out what went wrong. Ron Care to share it with us? Floor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
On Sun, 2008-02-10 at 16:46 +0800, LKSunny wrote: this i know already, but i think can do it single regex Considering you marked the email as urgent, perhaps you have better things to do than try to squeeze your problem into a regex. Feel free to post your single regex when you find it... a side note of how much time you wasted would be most informative too. Cheers, Rob. Robert Cummings [EMAIL PROTECTED] glsD:[EMAIL PROTECTED] On Sun, 2008-02-10 at 14:33 +0800, LKSunny wrote: //please run this script, you can get what problem i got $html = eof a href=aaa.htmlaaa/a a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a a href=aaa.htmlcc gd c/a a href=aaa.htmlddd 123/a eof; /* i want replace any |a.has bbb./a|, like a href=bbb.htmlcfdfd/a a href=aaa.htmlsfs sfsrbbb sfds/a */ ?php $reps = array ( array ( 'match' = '#a.*/a#Uims', 'check' = '#bbb#', 'replace' = 'X', ), ); foreach( $reps as $criteria ) { if( preg_match_all( $criteria['match'], $html, $matches ) ) { foreach( $matches[0] as $match ) { if( preg_match( $criteria['check'], $match ) ) { $html = str_replace( $match, $criteria['replace'], $html ); } } } } ? This does what you want to $html, but it doesn't do it in a single regex. I'm not sure it can be done with a single regex, and if it can, I doubt it's simple. I don't feel like investigating too far :) 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql question
i have this functuon: public function select_one($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) return stripslashes($ret); else return $ret; } what is $ret, an array? if so how can i access the individual rows in it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question
On Feb 10, 2008 12:52 PM, Per Jessen [EMAIL PROTECTED] wrote: nihilism machine wrote: $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) return stripslashes($ret); else return $ret; } what is $ret, an array? No, it's a mysql result object. no, its the contents of the first cell in the first record of the result set; from the doc on mysql_result(), http://www.php.net/manual/en/function.mysql-result.php which is what the function is using. if so how can i access the individual rows in it? this method does not return a result set to the caller. -nathan
Re: [PHP] mysql question
nihilism machine wrote: $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) return stripslashes($ret); else return $ret; } what is $ret, an array? No, it's a mysql result object. if so how can i access the individual rows in it? Look up mysql_fetch_assoc(). /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
At 12:38 PM -0500 2/10/08, Robert Cummings wrote: On Sun, 2008-02-10 at 16:46 +0800, LKSunny wrote: this i know already, but i think can do it single regex Considering you marked the email as urgent, perhaps you have better things to do than try to squeeze your problem into a regex. Feel free to post your single regex when you find it... a side note of how much time you wasted would be most informative too. Cheers, Rob. Rob: It's exchanges like this that piss me off. The OP marked his post as urgent meaning that he needed an answer immediately. You in turn, provide him elegant code that solves his problem, and he replies this i know already. If the OP knew this already, then it wasn't urgent! He certainly could have said Here's my code -- can anyone reduce it to a single regex? But no, he takes advantage of our time by stating a falsehood. I for one, won't be answering any of LKSunny's post. Where do we get people like this? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
On Feb 10, 2008 1:08 PM, Jason Pruim [EMAIL PROTECTED] wrote: Fire - what? :-) Isn't that a car? :) ya; but mustangs are cooler :) -nathan
[PHP] mysql question #2
Ok, I read the php.net info. so with this function though: public function select_one($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) { return stripslashes($ret); } else { return $ret; } } how can i get the contents of a column in the returned row say for something called Email as the column name. here is my code now: // Attempt to login a user public function CheckValidUser($Email, $Password) { $PasswordEncoded = $this-encode($Password); $sql = SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'; $result = $this-DB-select_one($sql); if ($result) { // User info stored in Sessions $_SESSION['Status'] = loggedIn; $_SESSION['ID'] = $row['ID']; $_SESSION['Email'] = $row['Email']; $_SESSION['AdminLevel'] = $row['AdminLevel']; $_SESSION['FirstName'] = $row['FirstName']; $_SESSION['LastName'] = $row['LastName']; return true; } else { return false; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Better DB Class MySQL
On Feb 10, 2008, at 10:39 AM, Richard Heyes wrote: Jochem Maas wrote: Larry Garfield schreef: http://www.php.net/pdo All the cool kids are doing it. not true - some of them use firebird ;-) Fire - what? :-) Isn't that a car? :) -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question
Nathan Nobbe wrote: what is $ret, an array? No, it's a mysql result object. no, its the contents of the first cell in the first record of the result set; from the doc on mysql_result(), http://www.php.net/manual/en/function.mysql-result.php which is what the function is using. Yep, you're right - I read mysql_query where the OP said mysql_result. Ignore the rest of my previous answer too. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
On Sun, 2008-02-10 at 12:55 -0500, tedd wrote: At 12:38 PM -0500 2/10/08, Robert Cummings wrote: On Sun, 2008-02-10 at 16:46 +0800, LKSunny wrote: this i know already, but i think can do it single regex Considering you marked the email as urgent, perhaps you have better things to do than try to squeeze your problem into a regex. Feel free to post your single regex when you find it... a side note of how much time you wasted would be most informative too. Cheers, Rob. Rob: It's exchanges like this that piss me off. The OP marked his post as urgent meaning that he needed an answer immediately. You in turn, provide him elegant code that solves his problem, and he replies this i know already. If the OP knew this already, then it wasn't urgent! He certainly could have said Here's my code -- can anyone reduce it to a single regex? But no, he takes advantage of our time by stating a falsehood. I for one, won't be answering any of LKSunny's post. Where do we get people like this? There's a colony of them living under the really big rock at the end of the yard :| 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
On Feb 10, 2008 12:55 PM, tedd [EMAIL PROTECTED] wrote: Where do we get people like this? the late-night homework challenge? -nathan
Re: [PHP] mysql question #2
On Feb 10, 2008 1:12 PM, nihilism machine [EMAIL PROTECTED] wrote: Ok, I read the php.net info. so with this function though: public function select_one($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) { return stripslashes($ret); } else { return $ret; } } as the function stands you wont be able to. you can alter it though: public function select_one($sql, $columnName) { $this-last_query = $sql; $r = mysql_query($sql); $ret = false; /// default return value is false if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $result = mysql_fetch_assoc($r); if(isset($result[$columnName])) { $ret = $result[$columnName]); } mysql_free_result($r); if ($this-auto_slashes) { return stripslashes($ret); } else { return $ret; } } note: i just hacked that together in my mail client :) -nathan
[PHP] Re: mysql question #2
nihilism machine wrote: Ok, I read the php.net info. so with this function though: public function select_one($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) { return stripslashes($ret); } else { return $ret; } } how can i get the contents of a column in the returned row say for something called Email as the column name. here is my code now: HUH? // Attempt to login a user public function CheckValidUser($Email, $Password) { $PasswordEncoded = $this-encode($Password); $sql = SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'; $result = $this-DB-select_one($sql); if ($result) { // User info stored in Sessions $_SESSION['Status'] = loggedIn; $_SESSION['ID'] = $row['ID']; $_SESSION['Email'] = $row['Email']; $_SESSION['AdminLevel'] = $row['AdminLevel']; $_SESSION['FirstName'] = $row['FirstName']; $_SESSION['LastName'] = $row['LastName']; return true; } else { return false; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Gzipped output
That would do the trick if it was allowed at the server but it isn't :( And it's not my server and I can't change its settings. Jakub Čermák [EMAIL PROTECTED] ICQ 159971304 Per Jessen napsal(a): Jakub wrote: Yes, I thought about this, but this has a big disadvantage - the client must wait for the file to be fully processed and compressed and then he can start downloading. I'd like to let the client start downloading the compressed parts while the further parts are still being processed and compressed - it's similar to streaming concept. I hope you can see what I mean. Maybe apaches mod_deflate is what you're after? That will do in-flight compression. /Per Jessen, Zürich
RE: [PHP] Gzipped output
-Original Message- From: Jakub [mailto:[EMAIL PROTECTED] Sent: Sunday, February 10, 2008 1:36 PM To: php-general@lists.php.net Subject: Re: [PHP] Gzipped output That would do the trick if it was allowed at the server but it isn't :( And it's not my server and I can't change its settings. Jakub Čermák [EMAIL PROTECTED] ICQ 159971304 Per Jessen napsal(a): Jakub wrote: Yes, I thought about this, but this has a big disadvantage - the client must wait for the file to be fully processed and compressed and then he can start downloading. I'd like to let the client start downloading the compressed parts while the further parts are still being processed and compressed - it's similar to streaming concept. I hope you can see what I mean. Maybe apaches mod_deflate is what you're after? That will do in-flight compression. /Per Jessen, Zürich How about something like this? (Needs debugging and testing, but... just a hint after all) ?php ob_start(ob_gzhandler); while ($someString = getTheNextPartOfTheLargeFile()) { echo $someString; ob_flush(); } ? Regards, Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 | Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: bestplace.biz | Web: seo-diy.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql question #2
2008. 02. 10, vasárnap keltezéssel 13.12-kor nihilism machine ezt írta: Ok, I read the php.net info. so with this function though: public function select_one($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_result($r, 0); mysql_free_result($r); if ($this-auto_slashes) { return stripslashes($ret); } else { return $ret; } } how can i get the contents of a column in the returned row say for something called Email as the column name. here is my code now: // Attempt to login a user public function CheckValidUser($Email, $Password) { $PasswordEncoded = $this-encode($Password); $sql = SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'; $result = $this-DB-select_one($sql); if ($result) { // User info stored in Sessions $_SESSION['Status'] = loggedIn; $_SESSION['ID'] = $row['ID']; $_SESSION['Email'] = $row['Email']; $_SESSION['AdminLevel'] = $row['AdminLevel']; $_SESSION['FirstName'] = $row['FirstName']; $_SESSION['LastName'] = $row['LastName']; return true; } else { return false; } } it seems to me you do not want a real 'select_one' but instead a 'select_one_row' like this: public function select_one_row($sql) { $this-last_query = $sql; $r = mysql_query($sql); if (!$r) { $this-last_error = mysql_error(); return false; } if (mysql_num_rows($r) != 1) { return false; } $ret = mysql_fetch_assoc($r); mysql_free_result($r); if ($this-auto_slashes) { return array_map('stripslashes', $ret); } else { return $ret; } } and then you would call it in your code like: public function CheckValidUser($Email, $Password) { $PasswordEncoded = $this-encode($Password); $sql = SELECT * FROM CMS_Users WHERE Email='$Email' AND Password='$PasswordEncoded'; $row = $this-DB-select_one_row($sql); if ($row) { // User info stored in Sessions $_SESSION['Status'] = loggedIn; $_SESSION['ID'] = $row['ID']; $_SESSION['Email'] = $row['Email']; $_SESSION['AdminLevel'] = $row['AdminLevel']; $_SESSION['FirstName'] = $row['FirstName']; $_SESSION['LastName'] = $row['LastName']; return true; } else { return false; } } note the changes: - use of mysql_fetch_assoc in the select_one_row function - putting the return value of the function into $row and then using that between the if function // this above might contain bugs as I just wrote it up here in my mailer greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to Protect Against SQL Injection Attacks While Using SQLite?
On Feb 10, 2008 2:38 PM, NotReally GonnaTell [EMAIL PROTECTED] wrote: Hello all, I am wondering how I should prevent SQL injection attacks while using SQLite, MySQL has the trusted mysqli_real_escape_string, but SQLite doesn't have it's own custom function, i've tried str_replace in my code, but SQLite returns an error whenever I use a '. I've tried googling around, but I haven't found anything useful. you can use PDO, and its prepared statements. -nathan
RE: [PHP] Gzipped output
Andrés Robinet wrote: How about something like this? (Needs debugging and testing, but... just a hint after all) ?php ob_start(ob_gzhandler); while ($someString = getTheNextPartOfTheLargeFile()) { echo $someString; ob_flush(); } ? I like it from a coding point of view (it's neat and elegant), but I don't think it achieves anything else than my initial suggestion of using exec(gzip -c). /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to Protect Against SQL Injection Attacks While Using SQLite?
Hello all, I am wondering how I should prevent SQL injection attacks while using SQLite, MySQL has the trusted mysqli_real_escape_string, but SQLite doesn't have it's own custom function, i've tried str_replace in my code, but SQLite returns an error whenever I use a '. I've tried googling around, but I haven't found anything useful.
Re: [PHP] How to Protect Against SQL Injection Attacks While Using SQLite?
Is there any other way to do this? I'd rather not use PDO. On Feb 10, 2008 2:46 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Feb 10, 2008 2:38 PM, NotReally GonnaTell [EMAIL PROTECTED] wrote: Hello all, I am wondering how I should prevent SQL injection attacks while using SQLite, MySQL has the trusted mysqli_real_escape_string, but SQLite doesn't have it's own custom function, i've tried str_replace in my code, but SQLite returns an error whenever I use a '. I've tried googling around, but I haven't found anything useful. you can use PDO, and its prepared statements. -nathan
Re: [PHP] How to Protect Against SQL Injection Attacks While Using SQLite?
On Feb 10, 2008 3:14 PM, NotReally GonnaTell [EMAIL PROTECTED] wrote: Is there any other way to do this? I'd rather not use PDO. what version of php are you using and what version of sqlite? this relevant info from the manual: Moreover, since PHP 5.1.0 SQLite depends on PDOhttp://www.php.net/manual/en/ref.pdo.php and SQLite 3 is supported through PDO SQLitehttp://www.php.net/manual/en/ref.pdo-sqlite.php . sqlite3 is quite a bit better than 2, and anyway if you dont want to use pdo there is sqlite_escape_string(). http://www.php.net/manual/en/function.sqlite-escape-string.php -nathan
Re: [PHP] Better DB Class MySQL
Nathan Nobbe wrote: On Feb 9, 2008 7:03 PM, nihilism machine [EMAIL PROTECTED] wrote: Looking to really beef up my DB class, any suggestions for functions to add that will be more time saving for a web 2.0 app, or ways to improve existing methods? thank you everyone in advance. first of all, as a matter of style, its conventional to capitalize class names. so you would change the name to Db. also, conventionally, member functions are not capitalized; so Terminator(), becomes terminator(). next thing is you have no escaping of the queries. you should be wrapping the $sql that gets passed into your query method in mysql_real_escape_string(). You don't escape the whole query. You want something like this: public function quote($string='') { return mysql_real_escape_string($string); } and call it like this: $query = select blah from table where username=', $db-quote($_POST['username']), ' and password=', $db-quote($_POST['password']), '; im not sure why you would name a call to mysql_insert_id(), select_id(); it seems better to preserve the original name. because dropping in a replacement to use sqlite/postgres/other db will still call 'mysql_insert_id()' ? Seems a bit strange. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP variable values
On Feb 10, 2008 6:30 PM, Ron Piggott [EMAIL PROTECTED] wrote: What is the command which shows the value of all the variables in memory? Ron get_defined_vars() -nathan
[PHP] PHP variable values
What is the command which shows the value of all the variables in memory? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ajax, an HTML form being saved in mySQL
I am trying to bring my programming skills together ... but I have hit a road block. I am writing my own ledger (accounting) software. I am needing help to pass 2 variables generated by Ajax through my form to be saved in a mySQL table. A sample of what ledger_select_account.js outputs is as follows --- the PHP script it accesses queries a table and then echo's this to the screen. SELECT name=account_reference OPTION value =1PayPal (REF: 1)/OPTION OPTION value =3Receiver General (REF: 3)/OPTION OPTION value =2TD Canada Trust (REF: 2)/OPTION /SELECT The source code for ledger_select_account.js is: var xmlHttp function showCustomer(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert (Your browser does not support AJAX!); return; } var url=ledger_account_details.php; url=url+?account_source=+str; url=url+sid=+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open(GET,url,true); xmlHttp.send(null); } function stateChanged () { if (xmlHttp.readyState == 4) { document.getElementById(txtHint).innerHTML=xmlHttp.responseText; } else { //alert(xmlHttp.readyState) } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject(Msxml2.XMLHTTP); } catch (e) { xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); } } return xmlHttp; } A sample of what ledger_select_gifi.js outputs is as follows --- the PHP script it accesses queries a table and then echo's this to the screen. SELECT NAME=gifi_reference OPTION VALUE=9Bank Charges (8715: Bank Charges)/OPTION OPTION VALUE=10Benevolent Fund (9270: Other Expenses)/OPTION OPTION VALUE=13Computer Equipment / Software (1774: Computer Equipment / Software)/OPTION OPTION VALUE=4Office Expenses (8811: Office stationery and supplies)/OPTION OPTION VALUE=12Our Advertising Campaign Expenses (8521: Advertising)/OPTION OPTION VALUE=8Photocopying (8810: Photocopying)/OPTION OPTION VALUE=7Postage (9275: Delivery, Freight and Express)/OPTION OPTION VALUE=5Telephone Expenses (9225: Telephone and Communications)/OPTION OPTION VALUE=6Web Site Hosting (9152: Internet)/OPTION /SELECT The source code for ledger_select_gifi.js is: var xmlHttp2 function showGIFI(str) { xmlHttp2=GetXmlHttpObject(); if (xmlHttp2==null) { alert (Your browser does not support AJAX!); return; } var url=ledger_gifi_details.php; url=url+?transaction_type=+str; url=url+sid=+Math.random(); xmlHttp2.onreadystatechange=stateChanged2; xmlHttp2.open(GET,url,true); xmlHttp2.send(null); } function stateChanged2 () { if (xmlHttp2.readyState == 4) { document.getElementById(txtGIFI).innerHTML=xmlHttp2.responseText; } else { //alert(xmlHttp.readyState) } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject(Msxml2.XMLHTTP); } catch (e) { xmlHttp=new ActiveXObject(Microsoft.XMLHTTP); } } return xmlHttp; } The form which submits the ledger entry is this: head script src=ledger_select_account.js/script script src=ledger_select_gifi.js/script /head center table trtd width=800 font face=times new roman centeruNew Ledger Entry/u/centerp center table form method=POST action=index.php?request=receive_ledger_entry_record trtd align=rightfont face=times new romanName Record Source:/td td SELECT NAME=account_source onchange=showCustomer(this.value) OPTION VALUE=0MAKE YOUR SELECTION/OPTION OPTION VALUE=1Member Services Account/OPTION OPTION VALUE=2Ledger Account/OPTION OPTION VALUE=3Supplier/OPTION OPTION VALUE=4Advertiser Account/OPTION /SELECT /td/tr trtd align=rightfont face=times new romanAccount Reference:/td td div id=txtHintbAccount holder information will be listed here./b/div /td/tr trtd align=rightfont face=times new romanTransaction Type:/td td SELECT NAME=transaction_type onchange=showGIFI(this.value) OPTION VALUE=0MAKE YOUR SELECTION/OPTION OPTION VALUE=1Donation/OPTION OPTION VALUE=2Expense/OPTION OPTION VALUE=3Income/OPTION OPTION VALUE=4PayPal Funds Transfer/OPTION OPTION VALUE=5Payroll/OPTION /SELECT /td/tr trtd align=rightfont face=times new romanGIFI Reference:/td td div id=txtGIFIbGIFI information will be listed here./b/div /td/tr trtd align=rightfont face=times new romanTransaction Date (-MM-DD):/td td input type=text name=transaction_date size=40 maxlength=10 /td/tr trtd/tdtd table trtd align=rightfont face=times new romanForeign Currency Received:/td td font face=times new roman$ input type=text name=foreign_currency_dollar_value size=20 maxlength=12 /td/tr trtd align=rightfont face=times new romanForeign Currency Identifier:/td td SELECT NAME=foreign_currency_identifier OPTION VALUE=0/OPTION OPTION VALUE=1U.S. Funds/OPTION /SELECT /td/tr trtd
[PHP] Trouble with PHP server script
Is it possible to use the $_SERVER['PHP_AUTH_USER']; construct in a URL forwarded site? I am trying to find the authorised user id so that I can access an SQL database with it. Anyone got some ideas? PHP looks like this ?php //Get User $user = $_SERVER['PHP_AUTH_USER']; // Get User type $db = mysql_connect(localhost, ., .) or die(Can't connect to database: .mysql_error()); mysql_select_db() or die(Can't select database: .mysql_error()); $query = SELECT * FROM user WHERE staffid LIKE $user; $result = mysql_query($query) or die ('Not a valid User: ' . mysql_error()); ?
Re: [PHP] Trouble with PHP server script
--- Robert Cox [EMAIL PROTECTED] wrote: Is it possible to use the $_SERVER['PHP_AUTH_USER']; construct in a URL forwarded site? I am trying to find the authorised user id so that I can access an SQL database with it. Anyone got some ideas? PHP looks like this ?php //Get User $user = $_SERVER['PHP_AUTH_USER']; // Get User type $db = mysql_connect(localhost, ., .) or die(Can't connect to database: .mysql_error()); mysql_select_db() or die(Can't select database: .mysql_error()); $query = SELECT * FROM user WHERE staffid LIKE $user; $result = mysql_query($query) or die ('Not a valid User: ' . mysql_error()); ? Robert, I think this link will help you to solve the problem. http://bugs.php.net/bug.php?id=29132 --- Nirmalya Lahiri [+91-9433113536] Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
Rob, $reps = array ( array ( 'match' = '#a.*/a#Uims', Can you explain what the 'U' from #Uims does? Does it have to do with Unicode? I can't find it anywhere (preg_match doc, man perlre, man perlop). Thanks! Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trouble with PHP server script
Robert Cox wrote: Is it possible to use the $_SERVER['PHP_AUTH_USER']; construct in a URL forwarded site? I am trying to find the authorised user id so that I can access an SQL database with it. Anyone got some ideas? PHP looks like this ?php //Get User $user = $_SERVER['PHP_AUTH_USER']; // Get User type $db = mysql_connect(localhost, ., .) or die(Can't connect to database: .mysql_error()); mysql_select_db() or die(Can't select database: .mysql_error()); You should always run mysql_real_escape_string() on any variables that you use in an SQL statement. $query = SELECT * FROM user WHERE staffid LIKE $user; You need to make sure that you surround your string with quotes. This is only if the $user is a string, if it is an int/number, the forget the quotes. $query = SELECT * FROM user WHERE staffid LIKE '$user'; The following should always reference your above DB resource $db Plus, this isn't how you should be checking for a valid user. The following would only hit the die() statement if there was an error with the SQL statement. Not if it didn't return any results. mysql_query($query, $db) or die('Not a valid user: '.mysql $result = mysql_query($query) or die ('Not a valid User: ' . mysql_error()); ? Note: You need to make sure that magic_quotes_gpc is not enabled. That will mess with doing things this way. Note: I am assuming that you will only match one and only one. If that is the case you need to switch the like to an = instead. staffid = '{$user}' don't worry about the curly braces, they are for PHP to identify the variable. They wont show up in your actual SQL statement. All that being said, try this instead. ?php // Get User type $db = mysql_connect(localhost, ., .) or die(Can't connect to database: .mysql_error()); mysql_select_db() or die(Can't select database: .mysql_error()); //Get User $user = mysql_real_escape_string(@$_SERVER['PHP_AUTH_USER'], $db); $query = SELECT * FROM user WHERE staffid = '{$user}'; $result = mysql_query($query, $db) or die('Error with query: '.mysql_error()); if ( mysql_num_rows($result) == 0 ) { // No results found, assume user does not exist } else { // User exists, do something about it. } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] urgent !!! Please Help preg_replace !!!!!!!!!!!!!!!!!!!!!
On Mon, 2008-02-11 at 13:42 +0900, Michael Moyle wrote: Rob, $reps = array ( array ( 'match' = '#a.*/a#Uims', Can you explain what the 'U' from #Uims does? Does it have to do with Unicode? I can't find it anywhere (preg_match doc, man perlre, man perlop). It makes the match Ungreedy. Look at the following example: $text = a href=blah/a ... a href=bleh/a; If we match with the following: preg_match_all( '#a.*/a#Uims', $html, $matches ) Then $matches will contain 2 matches... 1. a href=blah/a 2. a href=bleh/a However if we match with the following: preg_match_all( '#a.*/a#ims', $html, $matches ) Then $matches will only get 1 match... 1. a href=blah/a ... a href=bleh/a This is because the default behaviour is greedy, it will match as much as possible even if a shorter match exists. 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. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ajax, an HTML form being saved in mySQL
Hello, on 02/11/2008 12:19 AM Ron Piggott said the following: I am trying to bring my programming skills together ... but I have hit a road block. I am writing my own ledger (accounting) software. I am needing help to pass 2 variables generated by Ajax through my form to be saved in a mySQL table. A sample of what ledger_select_account.js outputs is as follows --- the PHP script it accesses queries a table and then echo's this to the screen. This is a bit confusing, but it seems you want a typical linked select input form. Take a look here and see if this is similar to what you want: http://www.meta-language.net/forms-examples.html?example=test_linked_select That was done with this forms generation and validation class. It comes with plug-in that can link select inputs in order to switch the options of one when another changes the selected value. It comes with a variant of that plug-in that can perform an AJAX request and retrive the new options from a MySQL database. http://www.phpclasses.org/formsgeneration -- Regards, Manuel Lemos PHP professionals looking for PHP jobs http://www.phpclasses.org/professionals/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php