[PHP] regex
I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Naturally I have only used part of sql statement and table, column names have been changed. (Think the one I'm trying on is 2000+ characters. So its not a case of set number of words/numbers between [] it could be 2 or it could be 4 etc) Anyone workout what I am talking about and can help would be appreciated. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] performance/load testing ...
hi guys, I need to do some performance testing for a site of mine. I want to compare performance of various combinations of using APC, Squid, Apache/LightHTTPD mod_php/fastcgi. all very well I can build the various setups but I'm stuck as to how to go about recreating realistic load on the machine in question. I don't want to have to go out and buy some commercial software. STFW is making my head spin. Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] performance/load testing ...
Ron Rademaker schreef: Hi Jochem, Apache comes with an nice ab tool which stands for apache benchmarking. You can use this to benchmark stuff like concurrent requests. indeed, I know ab, but it doesn't allow for a very realistic request 'spread' - at least as far as I know. I was hoping for a bit more detailed info on mimicking real-world site usage, e.g. maybe using access logs as a source of url data? Ron Jochem Maas wrote: hi guys, I need to do some performance testing for a site of mine. I want to compare performance of various combinations of using APC, Squid, Apache/LightHTTPD mod_php/fastcgi. all very well I can build the various setups but I'm stuck as to how to go about recreating realistic load on the machine in question. I don't want to have to go out and buy some commercial software. STFW is making my head spin. Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] performance/load testing ...
On Mon, 2008-01-21 at 10:50 +0100, Jochem Maas wrote: Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? I went through a similar headache recently, and looked at a whole whack of testing suites that are available. You can take a look at http://www.opensourcetesting.org/performance.php first, but I ended up using Apache JMeter most. It really is quite configurable and usable and gives you a lot of information. --Paul -- . | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :: All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Posting Summary for Week Ending 18 January, 2008: php-general@lists.php.net
2008. 01. 19, szombat keltezéssel 11.12-kor Daniel Brown ezt írta: Aside from that, Zoltan, if you happen to be able to find the function to post without much problem, feel free, and I'll look into incorporating it into the script. Otherwise, I can fix it myself. My fault for not thinking about non-English characters and such. here you are. it is from my Imap class so it might need some refactoring to fit your code, but aside from that it works for me well. /** * decodes email headers to utf-8 (and optionally kills line breaks + cuts to width adding ...) * * @param string $ret text to be decoded * @param boolean $killReturnChars whether to kill return characters * @param boolean $replaceTags whether to replace with gt; and with lt; * @param int $maxLength nr of characters returned * @return string utf-8 encoded string **/ public function decode_mail_header($ret, $killReturnChars = true, $replaceTags = false, $maxLength = 0) { mb_internal_encoding('utf-8'); $dec = imap_mime_header_decode($ret); $ret = ''; foreach ($dec as $as) { $text= $as-text; $charset = $as-charset; if ($charset == 'default' || empty($charset)) { $charset = 'iso-8859-1'; } else if ($charset == 'x-unknown') { // if somehow (faulty header) cannot be decoded give it another try $text = @mb_decode_mimeheader($text); } $ret .= @mb_convert_encoding($text, 'utf-8', $charset); } if ($maxLength 0) { $len = mb_strwidth($ret, 'utf-8'); if ($len $maxLength) { $ret = mb_substr($ret, 0, $maxLength, 'utf-8') . '...'; } } // kill return chars if ($killReturnChars) { $ret = mb_ereg_replace(\r, ' ', $ret); $ret = mb_ereg_replace(\n, ' ', $ret); } if ($replaceTags) { $ret = mb_ereg_replace('', 'lt;', $ret); $ret = mb_ereg_replace('', 'gt;', $ret); } return $ret; } greets Zoltán Németh -- /Dan Daniel P. Brown Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since Nineteen-Seventy-[mumble]. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] performance/load testing ...
Jochem Maas wrote: Ron Rademaker schreef: Hi Jochem, Apache comes with an nice ab tool which stands for apache benchmarking. You can use this to benchmark stuff like concurrent requests. indeed, I know ab, but it doesn't allow for a very realistic request 'spread' - at least as far as I know. Indeed it doesn't, but you appear to want to figure out what optimization works best. You don't need realistic spread for that, even more I think you shouldn't want realistic spread for that but something comparable instead. If anything, the result of ab are very useful for comparing results. I was hoping for a bit more detailed info on mimicking real-world site usage, e.g. maybe using access logs as a source of url data? Ron Jochem Maas wrote: hi guys, I need to do some performance testing for a site of mine. I want to compare performance of various combinations of using APC, Squid, Apache/LightHTTPD mod_php/fastcgi. all very well I can build the various setups but I'm stuck as to how to go about recreating realistic load on the machine in question. I don't want to have to go out and buy some commercial software. STFW is making my head spin. Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Can yo upost the code you have got to do the conversion so far please? Regards Keith - Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk All email addresses are challenge-response protected with TMDA [http://tmda.net] - On Mon, 21 Jan 2008, Peter wrote: To: php-general@lists.php.net From: Peter [EMAIL PROTECTED] Subject: [PHP] regex I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Naturally I have only used part of sql statement and table, column names have been changed. (Think the one I'm trying on is 2000+ characters. So its not a case of set number of words/numbers between [] it could be 2 or it could be 4 etc) Anyone workout what I am talking about and can help would be appreciated. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] performance/load testing ...
Ron Rademaker schreef: Jochem Maas wrote: Ron Rademaker schreef: Hi Jochem, Apache comes with an nice ab tool which stands for apache benchmarking. You can use this to benchmark stuff like concurrent requests. indeed, I know ab, but it doesn't allow for a very realistic request 'spread' - at least as far as I know. Indeed it doesn't, but you appear to want to figure out what optimization works best. You don't need realistic spread for that, even more I think you shouldn't want realistic spread for that but something comparable instead. If anything, the result of ab are very useful for comparing results. hmm, you have a point - I guess I'll get stuck in. I was hoping for a bit more detailed info on mimicking real-world site usage, e.g. maybe using access logs as a source of url data? Ron Jochem Maas wrote: hi guys, I need to do some performance testing for a site of mine. I want to compare performance of various combinations of using APC, Squid, Apache/LightHTTPD mod_php/fastcgi. all very well I can build the various setups but I'm stuck as to how to go about recreating realistic load on the machine in question. I don't want to have to go out and buy some commercial software. STFW is making my head spin. Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Well actually not a real lot so far. I'm just trial and error(lots of that) at the moment. I've only been 'playing with php for about a month or so. $file = phptest1.txt; $rep = array (tbl_ , _%, bool default 0, bool default 1, '?'); $wih = array (, _pc, bool DEFAULT FALSE, bool DEFAULT TRUE, ); if (is_file($file)) : $fh = fopen($file, r+) or die(File does not exist); while (! feof($fh)) : $line = fgets($fh,4096); $str = strtolower($line); $str_fixed = str_replace($rep, $wih, $str); print $str_fixed . br /; endwhile; Then as far as the regexp part for replacing the space inbetween [blah blah blah] with _ goes it was a case of try delete try delete etc. I may need to break the string into an array but that in its self adds its own problems. Think one of my problems is Im try to run before I can crawl with php, postgre regex etc. Also its fun trying to workout things when all the books you come across are php/mysql. Came across an old message in my trawl of the news group that 'may' help going to give that a try as soon as I get the time. (it was more to do with replacing | with space between but it maybe convertable) Keith Roberts [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Can yo upost the code you have got to do the conversion so far please? Regards Keith - Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk All email addresses are challenge-response protected with TMDA [http://tmda.net] - On Mon, 21 Jan 2008, Peter wrote: To: php-general@lists.php.net From: Peter [EMAIL PROTECTED] Subject: [PHP] regex I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Naturally I have only used part of sql statement and table, column names have been changed. (Think the one I'm trying on is 2000+ characters. So its not a case of set number of words/numbers between [] it could be 2 or it could be 4 etc) Anyone workout what I am talking about and can help would be appreciated. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST/GET into variables
On Jan 20, 2008 10:15 PM, nihilism machine [EMAIL PROTECTED] wrote: im trying to keep this php4 OOP. im just trying to clean the post/gets and then make them all into variables with their names being the keys to the get/post, and their values as the variables values. ie: $_POST['someFormInputName'] = somevalue ... turns into $someFormInputName = somevalue. I am not concerned about cleaning the input as i have a function already for that. On Jan 20, 2008, at 10:06 PM, Nathan Nobbe wrote: On Jan 20, 2008 9:47 PM, nihilism machine [EMAIL PROTECTED] wrote: how does this look? should this by me calling ... myforms = new forms(); work by turning all key/value pairs for both get and post into variable names of the same name as the get/post key, and the variable values as the values from the post/get? class forms { // Some stuff var $MyPosts; var $MyGets; var $CleanedInput; // Connect to the database function forms() { foreach($_POST as $curPostKey = $curPostVal) { CleanInput($curPostKey); $$curPostKey = $curPostVal; } foreach($_GET as $curGetKey = $curGetVal) { CleanInput($curGetKey); $$curGetKey = $curGetVal; } } // Attempt to login a user function CleanInput($userInput) { return $this-CleanedInput; } } im a little bit lost on the comments about connecting to the database and logging in a user. if you are writing a class to filter data in the $_POST and /or $_GET, then thats all it should be responsible for. the decision youll have to make is this; will this class simply act as a filter for these arrays, which means it will modify the data in those arrays, or will it leave the contents of those arrays unaltered and store the filtered values in instance variables? the design of the class will depend upon this decision. i think if you want to keep it simple, you should shoot for the former option. then your class would look something like this class InputFilter { public static function filterInput($optionalFilter='') { if(count($_GET) 0) { self::filterArray($_GET, $optionalFilter); } if(count($_POST) 0) { self::filterArray($_POST, $optionalFilter); } } private static function filterArray($array, $optionalFilter='') { foreach($array as $key = $value) { $$key = self::filterValue($value); if(!empty($optionalFilter) is_callable($optionalFilter)) { $$key = $optionalFilter($$key); } } } private static function filterValue($value) { return trim(stripslashes($value));/// -- NOTE: this is only an example } } then from client space you would just say InputFilter::filterInput(); then, subsequently you can use $_POST and $_GET directly with the assumption that the input has been escaped. and, using the class above, you can also supply a custom filtering function as well, on a per-need basis; eg. function filterMsql($value) { return mysql_real_escape_string($value); } InputFilter::filterInput('filterMysql'); NOTE: i just typed this into my mail client, so it might not be perfect. -nathan Look up extract(). This is a horrible idea you're trying to do though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST/GET into variables
On Jan 20, 2008 10:06 PM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Jan 20, 2008 9:47 PM, nihilism machine [EMAIL PROTECTED] wrote: how does this look? should this by me calling ... myforms = new forms(); work by turning all key/value pairs for both get and post into variable names of the same name as the get/post key, and the variable values as the values from the post/get? class forms { // Some stuff var $MyPosts; var $MyGets; var $CleanedInput; // Connect to the database function forms() { foreach($_POST as $curPostKey = $curPostVal) { CleanInput($curPostKey); $$curPostKey = $curPostVal; } foreach($_GET as $curGetKey = $curGetVal) { CleanInput($curGetKey); $$curGetKey = $curGetVal; } } // Attempt to login a user function CleanInput($userInput) { return $this-CleanedInput; } } im a little bit lost on the comments about connecting to the database and logging in a user. if you are writing a class to filter data in the $_POST and /or $_GET, then thats all it should be responsible for. the decision youll have to make is this; will this class simply act as a filter for these arrays, which means it will modify the data in those arrays, or will it leave the contents of those arrays unaltered and store the filtered values in instance variables? the design of the class will depend upon this decision. i think if you want to keep it simple, you should shoot for the former option. then your class would look something like this class InputFilter { public static function filterInput($optionalFilter='') { if(count($_GET) 0) { self::filterArray($_GET, $optionalFilter); } if(count($_POST) 0) { self::filterArray($_POST, $optionalFilter); } } private static function filterArray($array, $optionalFilter='') { foreach($array as $key = $value) { $$key = self::filterValue($value); if(!empty($optionalFilter) is_callable($optionalFilter)) { $$key = $optionalFilter($$key); } } } private static function filterValue($value) { return trim(stripslashes($value));/// -- NOTE: this is only an example } } then from client space you would just say InputFilter::filterInput(); then, subsequently you can use $_POST and $_GET directly with the assumption that the input has been escaped. and, using the class above, you can also supply a custom filtering function as well, on a per-need basis; eg. function filterMsql($value) { return mysql_real_escape_string($value); } InputFilter::filterInput('filterMysql'); NOTE: i just typed this into my mail client, so it might not be perfect. -nathan Hi Nathan, I don't think making a single generic function to iterate over every value in the GET/POST arrays is a very good idea. Each field on a form can contain very different pieces of data that should be handed quite differently. I know you did point out that this is just an example, but nonetheless your class is intended to iterate over everything with a generic solution. Say you have three fields: name, email, and comments textarea. On the back end your script should know that the three different fields have different character limits and they should also be validated differently. The email should be checked to make sure it is a valid email address. The two other fields can have constraints like the name field has to be between 4 characters and a max of 64. Then the comments has a minimum of 1 and a max of 65535. How do you accomplish this with one blanket function without passing in a massive array of options. What if there is another field that requires some sort of number. If someone came through and typed e3 (not malicious, just a typo) then the all in one would say that is perfect. There are plenty of filtering libraries available such as ext/filter[1], Zend_Filter[2], and Stubbles Validators [3]. I lean towards the Stubbles method of applying reusable filters to data. These libraries have many eyes on them and are tested pretty well. To forego all this work and start your own really requires a bigger effort than most people realize. [1] http://php.net/filter [2] http://framework.zend.com/manual/en/zend.filter.html [3] http://stubbles.net/wiki/Docs/Validators -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] general time question
On Jan 20, 2008 8:36 PM, Jochem Maas [EMAIL PROTECTED] wrote: now for the juicy bit - you have *no* garantee that the system clock and/or the timezone setting on the client machine is anything like correct. actually the chances that it is not are quite high - disregarding idiots, just think of people who have to screw their clock/TZ to accomodate some other application and more likely, people on the road, using laptops ... I don't bother to change my TZ or clock just because I went to see a friend somewhere far away from home .. do you? A very important point to expand on this is also that clocks easily go out of sync, even in this day and age. For example, I have one box that somehow loses (on average) seven minutes over a three-week span. Probably something wrong with the hardware, I'm sure, and I keep it running just because it's a puzzle for me. However, while it may be an extreme case, it's by no means a rare case. Unless everyone keeps in sync with the same atomic clock, you'll always have wide variances. And even if they do sync up, they would have to do so frequently (i.e. - daily). -- /Dan Daniel P. Brown Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since Nineteen-Seventy-[mumble]. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST/GET into variables
Eric Butera schreef: ... then from client space you would just say InputFilter::filterInput(); then, subsequently you can use $_POST and $_GET directly with the assumption that the input has been escaped. BAD! assuming $_GET/$_POST are sanitized and escaped is always wrong. stick cleaned/validated request data in a new/designated container. additionally you escape data according to the context in which the escaped data will be used - if you perform mysql related escaping on some central bunch of data then things will go pear-shaped if at anytime that same data is subsequently used for other kind of output (e.g. to screen) (note that putting data into a DB is consider output from the point of view of your script) Look up extract(). This is a horrible idea you're trying to do though. I'll second that. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: [PHP] change php variable depending on selection
-- Forwarded message -- From: Nathan Nobbe [EMAIL PROTECTED] Date: Jan 21, 2008 10:43 AM Subject: Re: [PHP] change php variable depending on selection To: stp [EMAIL PROTECTED] On Jan 21, 2008 9:42 AM, stp [EMAIL PROTECTED] wrote: I'm sorry…..I've got the conversion of the actual feed itself already sorted out…… when I talk feed below, I am just referring to the *link*, i.e. for Yahoo Finance, the *link* would be http://finance.yahoo.com/rss/topstories. The only thing I am missing (besides half a brain to figure this out on my own) is the $rssFeeds variable and how to set that so that when the user selects Yahoo Finance from the drop down menu the $rssFeeds variable would be http://finance.yahoo.com/rss/topstories;. I guess the variable would be something along the following: $rssFeeds=grab the link from my table associated with the blogname the user selects in the dropdown menu please keep all responses to list topics on the list for the benefit of others. you need to build an array with the values from your database. suppose, the fields in your database have column names feedName and feedUrl, then you will do something like this to build the array (assuming table name is RSS_FEEDS): // connect to the database using mysql_connect() if($resultSet = mysql_query('SELECT feedName, feedUrl FROM RSS_FEEDS')) { $rssFeeds = mysql_fetch_array($resultSet); } once youve done that, you can modify the code that builds the select box in the example i posted: ?php foreach($rssFeeds as $curFeedName = $curFeedValue) { ? option value=?=$curFeedName? ?=$curFeedValue? /option ?php } ? will become ?php foreach($rssFeeds as $curFeed) { ? option value= ?=$curFeed['feedUrl']? ?=$curFeed['feedName']? /option ?php } ? then, when the user makes a selection, the value of the $selectedValue variable (from the example script) will be the url of the feed they would like to see. -nathan
[PHP] Resetting drop-downlists in input-fields for texts
I'm developing a traning page for basic math. The answers are entered by the user in simple text input fields and the same page is returned (after having been processed by php) to the user with indications of correctness or error on each answer. If the AutoComplete feature is turned on a droplist with previous entries are displayed in the answer fields, even if new exercises are generated. This is quite distracting. Is there any way I can block this feature from my php-code, even if it is turned on in the users browser? Tor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Hi Peter. Is this what you want to do. Copy this into a *.php page, and then look at it with your browser. I just refactored one of my heredoc queries to handle your problem. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en head titleSQL Regex Tester/title /head body ?php echo Version 1 br /; $this_table = 'MSS TABLE NAME'; $this_id = 5; $sql = OUT select * from $this_table where ID = $this_id OUT; echo Contents of \$sql: br /$sql; echo br /br / Version 2 br /; $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name1].[Column Name 2]; echo Contents of \$sql: br /$sql; echo br /br / Version 3 br /; $this_table = 'MSS TABLE NAME'; $this_id = 5; $sql = OUT SELECT DISTINCT [Table Name].[Column.Name], [Table Name1].[Column Name 2] OUT; echo Contents of \$sql: br /$sql; echo br /br / Version 4 br /; $tbl_name = [Table Name]; $col_name = [Column Name]; $tbl_name1 = [Table Name1]; $col_name2 = [Column Name 2]; $sql = OUT SELECT DISTINCT $tbl_name.$col_name, $tbl_name1.$col_name2 OUT; echo Contents of \$sql: br /$sql; echo br /br / Version 5 br /; $sql_query = SELECT DISTINCT; $tbl_name = [Table Name]; $col_name = [Column Name]; $tbl_name1 = [Table Name1]; $col_name2 = [Column Name 2]; $tbl_name = strtolower($tbl_name); $col_name = strtolower($col_name); $tbl_name1 = strtolower($tbl_name1); $col_name2 = strtolower($col_name2); $sql = OUT $sql_query $tbl_name.$col_name, $tbl_name1.$col_name2 OUT; echo Contents of \$sql: br /$sql; echo br /br / Version 6 br /; $sql_query = SELECT DISTINCT; $tbl_name = [Table Name]; $col_name = [Column Name]; $tbl_name1 = [Table Name1]; $col_name2 = [Column Name 2]; // convert to lower case $tbl_name = strtolower($tbl_name); $col_name = strtolower($col_name); $tbl_name1 = strtolower($tbl_name1); $col_name2 = strtolower($col_name2); // remove '[]' characters $tbl_name = trim($tbl_name, []); $col_name = trim($col_name, []); $tbl_name1 = trim($tbl_name1, []); $col_name2 = trim($col_name2, []); // replace space with '_' character $tbl_name = preg_replace('/\s/', '_', $tbl_name); $col_name = preg_replace('/\s/', '_', $col_name); $tbl_name1 = preg_replace('/\s/', '_', $tbl_name1); $col_name2 = preg_replace('/\s/', '_', $col_name2); $sql = OUT $sql_query $tbl_name.$col_name, $tbl_name1.$col_name2 OUT; echo Contents of \$sql: br /$sql; ? /body /html The above code is not optimal, but it works OK. I use the heredoc construct to build my sql query strings. Saves using all those single and double quote characters. http://uk2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc HTH Keith Roberts - Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk All email addresses are challenge-response protected with TMDA [http://tmda.net] - On Mon, 21 Jan 2008, Peter wrote: To: php-general@lists.php.net From: Peter [EMAIL PROTECTED] Subject: Re: [PHP] regex Well actually not a real lot so far. I'm just trial and error(lots of that) at the moment. I've only been 'playing with php for about a month or so. $file = phptest1.txt; $rep = array (tbl_ , _%, bool default 0, bool default 1, '?'); $wih = array (, _pc, bool DEFAULT FALSE, bool DEFAULT TRUE, ); if (is_file($file)) : $fh = fopen($file, r+) or die(File does not exist); while (! feof($fh)) : $line = fgets($fh,4096); $str = strtolower($line); $str_fixed = str_replace($rep, $wih, $str); print $str_fixed . br /; endwhile; Then as far as the regexp part for replacing the space inbetween [blah blah blah] with _ goes it was a case of try delete try delete etc. I may need to break the string into an array but that in its self adds its own problems. Think one of my problems is Im try to run before I can crawl with php, postgre regex etc. Also its fun trying to workout things when all the books you come across are php/mysql. Came across an old message in my trawl of the news group that 'may' help going to give that a try as soon as I get the time. (it was more to do with replacing | with space between but it maybe convertable) Keith Roberts [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Can yo upost the code you have got to do the conversion so far please? Regards Keith - Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk All email addresses are challenge-response protected with TMDA [http://tmda.net] - On Mon, 21 Jan 2008, Peter wrote: To: php-general@lists.php.net From: Peter [EMAIL PROTECTED] Subject: [PHP] regex I am trying to
Re: [PHP] performance/load testing ...
On Jan 21, 2008 5:50 AM, Jochem Maas [EMAIL PROTECTED] wrote: Ron Rademaker schreef: Jochem Maas wrote: Ron Rademaker schreef: Hi Jochem, Apache comes with an nice ab tool which stands for apache benchmarking. You can use this to benchmark stuff like concurrent requests. indeed, I know ab, but it doesn't allow for a very realistic request 'spread' - at least as far as I know. Indeed it doesn't, but you appear to want to figure out what optimization works best. You don't need realistic spread for that, even more I think you shouldn't want realistic spread for that but something comparable instead. If anything, the result of ab are very useful for comparing results. hmm, you have a point - I guess I'll get stuck in. I was hoping for a bit more detailed info on mimicking real-world site usage, e.g. maybe using access logs as a source of url data? Ron Jochem Maas wrote: hi guys, I need to do some performance testing for a site of mine. I want to compare performance of various combinations of using APC, Squid, Apache/LightHTTPD mod_php/fastcgi. all very well I can build the various setups but I'm stuck as to how to go about recreating realistic load on the machine in question. I don't want to have to go out and buy some commercial software. STFW is making my head spin. Does anyone have any tips, urls, advice as to how to start going about creating something like a 'test suite' for testing high load performance of a website? TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Maybe look at http://www.acme.com/software/http_load/ You can configure a big text file of urls for it to hit randomly and such. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST/GET into variables
On Jan 21, 2008 10:19 AM, Eric Butera [EMAIL PROTECTED] wrote: I don't think making a single generic function to iterate over every value in the GET/POST arrays is a very good idea. Each field on a form can contain very different pieces of data that should be handed quite differently. I know you did point out that this is just an example, but nonetheless your class is intended to iterate over everything with a generic solution. i think applying trim() to all input is appropriate. Say you have three fields: name, email, and comments textarea. On the back end your script should know that the three different fields have different character limits and they should also be validated differently. The email should be checked to make sure it is a valid email address. The two other fields can have constraints like the name field has to be between 4 characters and a max of 64. Then the comments has a minimum of 1 and a max of 65535. How do you accomplish this with one blanket function without passing in a massive array of options. the class i supplied could easily be extended to accept a such a configuration array, which i see no problem with either. its the same approach taken by one of the functions in the filter extension you mentioned. http://us2.php.net/manual/en/function.filter-input-array.php this was not designed to be some end-all-be-all solution, it was merely an example which illustrated primarily how to convert an array of values into first class variables. i was also unaware of the extract() function. These libraries have many eyes on them and are tested pretty well. To forego all this work and start your own really requires a bigger effort than most people realize. probly, using existing, working tools is the best choice for most cases. taking code from somebody writing it at 2 in the morning might not be so smart ;) really, i was just trying to answer the question at hand, i believe i did that. [1] http://php.net/filter [2] http://framework.zend.com/manual/en/zend.filter.html [3] http://stubbles.net/wiki/Docs/Validators thank you for the references, in particular, i was unaware of the filter extension, ill give that a closer look. -nathan
Re: [PHP] Resetting drop-downlists in input-fields for texts
On Jan 21, 2008 10:31 AM, Tor Vidvei [EMAIL PROTECTED] wrote: I'm developing a traning page for basic math. The answers are entered by the user in simple text input fields and the same page is returned (after having been processed by php) to the user with indications of correctness or error on each answer. If the AutoComplete feature is turned on a droplist with previous entries are displayed in the answer fields, even if new exercises are generated. This is quite distracting. Is there any way I can block this feature from my php-code, even if it is turned on in the users browser? The only way I can think of that would allow you to do it is to dynamically-name the fields in the form. By doing so, AutoComplete won't be able to recognize the fields, and you should be in good shape. In the example I'm sending, keep in mind that input should still be sanitized properly, and it's by no means as a copy-and-paste-for-production script. ? session_start(); if($_POST isset($_SESSION['target'])) { /*This is just here for demonstration. Do your processing as you'd like with the POST data here. There are two methods shown. Note the use of the curly brackets and square brackets, as well as the order in which they're typed.*/ /* Method 1: for() for($i=0;$icount(${$_SESSION['target']});$i++) { echo ${$_SESSION['target']}[$i].br /\n; } */ /*Method 2: foreach() Further handling would be needed to make the variables valid, because $0, $1, $2, etc., are not valid variables. Again, this is only for demonstration purposes.*/ foreach(${$_SESSION['target']} as $p = $v) { echo $p.: .$v.br /\n; } } // Define the unique field name for the form, based on Epoch time. $_SESSION['target'] = field_.time(); // Adding the brackets after the name will print properly // in HTML to designate the POST fields as an array. $html_field = $_SESSION['target'].[]; ? form method=post action=?=$_SERVER['PHP_SELF'];? / Field 1: input type=text name=?=$html_field;? /br / Field 2: input type=text name=?=$html_field;? /br / Field 3: input type=text name=?=$html_field;? /br / input type=submit value=Post Now / /form -- /Dan Daniel P. Brown Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since Nineteen-Seventy-[mumble]. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resetting drop-downlists in input-fields for texts
On 1/21/08, Tor Vidvei [EMAIL PROTECTED] wrote: I'm developing a traning page for basic math. The answers are entered by the user in simple text input fields and the same page is returned (after having been processed by php) to the user with indications of correctness or error on each answer. If the AutoComplete feature is turned on a droplist with previous entries are displayed in the answer fields, even if new exercises are generated. This is quite distracting. Is there any way I can block this feature from my php-code, even if it is turned on in the users browser? Tor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think this HTML is IE specific, form autocomplete=off ... /form Not sure if you can do it on a tag by tag basis or not, nor what versions it might be limited by. David
Re: [PHP] Digital Downloads and Scale(solved)
Chris, Jochem, Nathan, Jason, Paul, Thanks for the suggestions and information. This is great, gives me a good place to start. Best, -dg
Re: [PHP] Digital Downloads and Scale(solved)
Daneane schreef: Chris, Jochem, Nathan, Jason, Paul, Thanks for the suggestions and information. This is great, gives me a good place to start. let us know how you get on - chances are you'll learn some tricks other may find handy :-) Best, -dg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Peter wrote: I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Naturally I have only used part of sql statement and table, column names have been changed. (Think the one I'm trying on is 2000+ characters. So its not a case of set number of words/numbers between [] it could be 2 or it could be 4 etc) Anyone workout what I am talking about and can help would be appreciated. Peter Something along the lines of this? ?php error_reporting(E_ALL); ini_set('display_errors', 1); $sql = SELECT DISTINCT [Table Name].[Column Name], . [Table Name 1].[Column Name 2]; echo {$sql}br /\n; preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER); $change = array(); foreach ( $matches AS $match ) { $change[$match[0]] = str_replace(' ', '_', $match[1]); } echo 'pre'.print_r($change,1).'/pre'; echo str_replace(array_keys($change), $change, $sql); -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] a better way to do a data import?
I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Thanks!
[Fwd: Re: [PHP] POST/GET into variables]
rectified ;-) Originele bericht On Jan 21, 2008 11:51 AM, Jochem Maas [EMAIL PROTECTED] wrote: yeah - you'll get used to it, mostly. it happens to everyone that they seem to be getting replies to things they didn't write - I was responding to the OP in this case - adding to your advice in affect. sorry for the confusion. It's no problem. :) Defending my honor off-list! :D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unable to override status code in certain installations..?
RavenWorks schreef: Well, just for the sake of anybody in my situation finding this thread in the future -- the workaround is to use this: Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ /redirectTest2/verify.php?page=$1%{QUERY_STRING} [L] just to add, there is an alternative way to append query string: RewriteRule ^(.+)$ /redirectTest2/verify.php?page=%{REQUEST_URI} [QSA,L] just a thought. instead of ErrorDocument 404 /redirectTest2/verify.php It seems to perform the same job, but because it's just mod_rewrite, it won't show up as a 404 whatsoever, which means that even on servers that refuse to let PHP's headers override Apache's error code, you're able to send whatever status header you want. RavenWorks wrote: It's the exact same situation as this bug: http://bugs.php.net/bug.php?id=24177 except, that bug was fixed back in PHP 4... In my case, the server that works is running PHP 5.2.2, and the server that DOESN'T work is running PHP 5.2.3! So either it's a bug that cropped up (again) after 5.2.2, or there's another factor here.. (For instance, the server on which it doesn't work is running Apache 1.3.37, and the server that handles it correctly is running Apache 2.2.4.) At least knowing that it's (likely) a bug, and not an obscure config setting, is something. If no-one else has any other suggestions, I guess I'll submit a bug report? Richard Lynch wrote: On Wed, January 9, 2008 4:35 pm, RavenWorks wrote: I'm currently trying to create a system where a custom 404 ErrorDocument in PHP is able to 301 Redirect the browser in certain cases. This works fine on some servers, however, on some other servers the PHP script seems to be unable to replace the 404 header. Correctly overrides with '200' status: http://fidelfilms.ca/redirectTest/ Unable to override default '404' status: http://fraticelli.info/redirectTest/ Those two pages will look the same in a browser window, but one returns 404 and one returns 200 (as it should, because of the header() call) -- check with whatever browser plugin you prefer for reading HTTP headers, such as Live HTTP Headers for Firefox. Returning the correct status code is important because we're migrating a site from one domain to another, and we don't want to lose ranking in search engines. (In the examples above, I return 200 as a test, but in practice this will be used to 301 all visitors -- and search engines -- to the new domain.) My question is this: What causes PHP to be able to override the ErrorDocument status on some servers and not others? Is it caused by PHP's behavior or Apache? Is this a configurable option, or was the behavior permanently changed in a given version of either? I think you are falling prey to a PHP bug. You should be able to find it in: http://bugs.php.net You could also check the ChangeLogs: http://php.net/ChangeLog-5.php http://php.net/ChangeLog-4.php I could be wrong, as my memory is rather vague on this one, and it's always possible that you have similar/same symptoms with an entirely different issue. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a better way to do a data import?
On Jan 21, 2008 12:35 PM, blackwater dev [EMAIL PROTECTED] wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Thanks! If it is a memory error perhaps you could just do a select of the primary key in your existing recordset first. Then you could iterate over each of the new records to be inserted and say if !isset(new record pk) then insert. This way the only thing in memory is the current primary keys and a single new record. This might not work though. If that doesn't work, perhaps you could know that your primary key is auto incrementing. On each update just insert records that are greater than the previous max value? One possible other solution. I have one data set that I have to update each night from an XML feed. I just rip through the file and insert the records with a given timestamp. Then once I am complete I delete all the previous records with a timestamp that is less than the current insert. This is for a very specific thing though and might not be right for your needs. Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a better way to do a data import?
On Mon, 2008-01-21 at 12:35 -0500, blackwater dev wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Does Postgres support any method of temporarily disabling keys/indexing? Indexing is what causes the inserts to take a while. MySQL can optimize an import by locking the table and allowing the keys/indexes to be temporarily disabled. You'll see the following lines in recent MySQL database dumps surrounding the inserts: /*!4 ALTER TABLE `xxx` DISABLE KEYS */; INSERT ... INSERT ... /*!4 ALTER TABLE `xxx` ENABLE KEYS */; Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] a better way to do a data import?
I think that's possible, so I'll give it a shot. For some reason, even with straight inserts my php script is dying around 180,000 rows. Basically, I took out all the compare/update code so now I grab the row from the db and if there isn't one, do an insert. I've wiped my db so should do straight inserts so I'm not sure what's taking up the memory. private function processFile($table, $key){ $this-openFileForReading(); //foudn in GLFile class while (!feof($this-fileHandle)) { $file_data = fgets($this-fileHandle); $this-insert($table, $key, $file_data); } $this-closeFile(); } private function insert($table, $key, $data){ if (strlen($data)10) return false; $data=$this-db-escape_string($data); //this is the data we will use should we need to do an insert $insert_data = str_replace(\, ', $data); //this is a hack we need to change the separator of the file //we need this because we need to put the data into an array and if //we simply use the comma, then it splits address fields $data = str_replace(\,\, ~, $data); $data = str_replace(\,,$data); //let's remove the double quotes $this-setDelimiter(~); $dataToArray=$this-stringToArray($data); //set it back for other functions $this-setDelimiter(,); //get the id, we trust it is the first column $key_data=$dataToArray[0]; //does the value exist in the database already? $sql=select * from prelim_$table where $key='$key_data'; $handle=$this-db-select($sql); if ($this-db-row_count($handle)0){ $textData=array(); $colsToUpdate=; $dataRow=; $dataRow=$this-db-fetch_row($handle); //now that we have the data, let's merge the row from the //file with the column names $textData=array_combine($this-carrierColumns, $dataToArray); //cast some values that are strings in the text file $textData['cars1']=(int) $textData['cars1']; $textData['car_amount']=(int) $textData['car_amount']; $textData['total_work']=trim($textData['total_work']); $textData['business_zip']=trim($textData['business_zip']); //clean up some old db data $dataRow['rfc_number']=trim($dataRow['rfc_number']); $dataRow['business_zip']=trim($dataRow['business_zip']); $colsToUpdate=array_diff($textData,$dataRow); //if we have columns to update, do it if (count($colsToUpdate)0){ $colset=; foreach ($colsToUpdate as $column=$value){ $colset.=$column='$value',; } //strip last comma $colset=substr($colset, 0, -1); $sql=update prelim_$table set $colset where $key='$key_data'; $this-db-write($sql); } $dataRow=NULL; $colsToUpdate=NULL; $colset=NULL; $textData=NULL; } else{ //insert the row $sql=insert into prelim_$table values (; $sql.=trim($insert_data); $sql.=);; $this-db-write($sql); } } On Jan 21, 2008 12:55 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2008-01-21 at 12:35 -0500, blackwater dev wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Does Postgres support any method of temporarily disabling keys/indexing? Indexing is what causes the inserts to take a while. MySQL can optimize an import by locking the table and allowing the keys/indexes to be temporarily disabled. You'll see the following lines in recent MySQL database dumps surrounding the inserts: /*!4 ALTER TABLE `xxx` DISABLE KEYS */; INSERT ... INSERT ... /*!4 ALTER TABLE `xxx` ENABLE KEYS */; Cheers,
Re: [PHP] a better way to do a data import?
On Jan 21, 2008 1:08 PM, blackwater dev [EMAIL PROTECTED] wrote: I think that's possible, so I'll give it a shot. For some reason, even with straight inserts my php script is dying around 180,000 rows. Basically, I took out all the compare/update code so now I grab the row from the db and if there isn't one, do an insert. I've wiped my db so should do straight inserts so I'm not sure what's taking up the memory. private function processFile($table, $key){ $this-openFileForReading(); //foudn in GLFile class while (!feof($this-fileHandle)) { $file_data = fgets($this-fileHandle); $this-insert($table, $key, $file_data); } $this-closeFile(); } private function insert($table, $key, $data){ if (strlen($data)10) return false; $data=$this-db-escape_string($data); //this is the data we will use should we need to do an insert $insert_data = str_replace(\, ', $data); //this is a hack we need to change the separator of the file //we need this because we need to put the data into an array and if //we simply use the comma, then it splits address fields $data = str_replace(\,\, ~, $data); $data = str_replace(\,,$data); //let's remove the double quotes $this-setDelimiter(~); $dataToArray=$this-stringToArray($data); //set it back for other functions $this-setDelimiter(,); //get the id, we trust it is the first column $key_data=$dataToArray[0]; //does the value exist in the database already? $sql=select * from prelim_$table where $key='$key_data'; $handle=$this-db-select($sql); if ($this-db-row_count($handle)0){ $textData=array(); $colsToUpdate=; $dataRow=; $dataRow=$this-db-fetch_row($handle); //now that we have the data, let's merge the row from the //file with the column names $textData=array_combine($this-carrierColumns, $dataToArray); //cast some values that are strings in the text file $textData['cars1']=(int) $textData['cars1']; $textData['car_amount']=(int) $textData['car_amount']; $textData['total_work']=trim($textData['total_work']); $textData['business_zip']=trim($textData['business_zip']); //clean up some old db data $dataRow['rfc_number']=trim($dataRow['rfc_number']); $dataRow['business_zip']=trim($dataRow['business_zip']); $colsToUpdate=array_diff($textData,$dataRow); //if we have columns to update, do it if (count($colsToUpdate)0){ $colset=; foreach ($colsToUpdate as $column=$value){ $colset.=$column='$value',; } //strip last comma $colset=substr($colset, 0, -1); $sql=update prelim_$table set $colset where $key='$key_data'; $this-db-write($sql); } $dataRow=NULL; $colsToUpdate=NULL; $colset=NULL; $textData=NULL; } else{ //insert the row $sql=insert into prelim_$table values (; $sql.=trim($insert_data); $sql.=);; $this-db-write($sql); } } On Jan 21, 2008 12:55 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2008-01-21 at 12:35 -0500, blackwater dev wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Does Postgres support any method of temporarily disabling keys/indexing? Indexing is what causes the inserts to take a while. MySQL can optimize an import by locking the table and allowing the keys/indexes to be temporarily disabled. You'll see the following lines in
Re: [PHP] password hashing and crypt()
My apologies Robert, Gmail sucks. I'm bouncing this back to the list, where it belonged in the first place. Feel free to make corrections if I've mischaracterized what you wrote. Good luck with that, btw, but don't expect me to engage. Robert Cummings wrote: And THAT does remind me of my MUD server programming :) So it would seem, by supplying a user defined salt you can ensure compatibility with legacy systems that used the older (and largely deprecated) crypt() system. In fact, the description given by PHP worries me a little. In fact, it looks like you are saying that a 13-char hash is better than a 34-char hash, and with your zz $salt exposed to anyone who can tell hash from grits. No, I'm not at all saying that a 13-char hash is better than a 34 char hash. I'm saying that you get different types of encryption depending on how you use crypt, then I illustrated the point. Tying your example(s) to older (read: broken) encryption mechanisms. Then I tied that back to older code I've worked on that produces the encryption variety experienced when supplying a user defined salt... this is then used to make the case that legacy support can be obtained via the user defined salt. If we are dealing with how the Server handles the scripts, why is legacy a factor in the first place? Fit your scripts to the server, this is not some burger joint where you get it your way. And don't try to go international on me, the rest of the world had 128-bit encryption and was free to use it before the US populace could legally possess it for international transactions. Do you remember the Munitions Act? It says, Some operating systems support more than one type of encryption. So? Did you mean to say, control is needed on which type is used? I haven't looked into the crypt() function supplied by PHP beyond having read the initial manual for it and producing examples of output. That sounds like I don't know. So your earlier statement ultimately means I don't know??? Obviously, the defining the salt and not defining the salt have profound differences on the result produced (as illustrated). Per your examples, it's the difference between 13-char (hard) and 34-char(harder) differences. And with your 13-char example giving the $salt away in the first two columns (the scenario is a cracker who accessed your user/pass table and is trying to find matches), it doesn't take that cracker long to recognize equal values above and below the divisor. Solve for what is left. So this was a roundabout way of saying, verify the encryption mechanism? How does that make the random $salt less valid than the user-supplied $salt? No, You should have said yes and quit while you thought you were ahead. that was me saying that there is certainly a good reason to use a user defined salt-- legacy compatibility. The random salt is useless if you need to create a crypt()'d string that will match the crypt()'d string created by a C program 10 years ago-- Given that the scenario is a cracker who has your user/pass ID table, that was never a stated goal, purpose or anything. and so in this context, Okay, you win. I can't provide enough real world data to illustrate exactly how wrong you are, in your view because, in your view all this real world data does not get parsed properly. Myself and this is what you were talking around but wouldn't embrace, I think the $salt and encryption method both count for a lot. Given the same encryption method, why would a user-supplied $salt necessarily be better than a random $salt? Answer that only, if you can and expect a reply. --Doc it is true that the random salt is less valid than the custom supplied salt. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password hashing and crypt()
On Mon, 2008-01-21 at 14:37 -0500, Mike Potter wrote: You should have said yes and quit while you thought you were ahead. I'm not trying to get ahead... I didn't know I was competing. Are we competing? I thought I was just answering posts. that was me saying that there is certainly a good reason to use a user defined salt-- legacy compatibility. The random salt is useless if you need to create a crypt()'d string that will match the crypt()'d string created by a C program 10 years ago-- Given that the scenario is a cracker who has your user/pass ID table, that was never a stated goal, purpose or anything. and so in this context, Okay, you win. I can't provide enough real world data to illustrate exactly how wrong you are, in your view because, in your view all this real world data does not get parsed properly. ??? Myself and this is what you were talking around but wouldn't embrace, I think the $salt and encryption method both count for a lot. Given the same encryption method, why would a user-supplied $salt necessarily be better than a random $salt? Answer that only, if you can and expect a reply. I never said it would. I didn't even come close to saying a user defined salt would be better than a random salt given that the encryption method is the same. From what hat did you pull that? I merely indicated reasons why the user defined salt was necessary. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] More frustration with MySQL and PHP
Today, I found a bug in my software which I was originally happy to find since that means there's one less that I have to worry about... 3 hours later while trying to figure out how to fix it I wish I never found it! Here's the deal, I have a file that exports the records in the database to excel, which works perfectly, except for 1 small thing... If you search the database first, it exports just those records. Basically what I need to do is allow people the choice of either exporting just certain search criteria, or the entire database without having to logout/login each time. I have tried using HTTP_REFERER to grab weither the user is coming from search.php (My search script) or directly from the index.php site which would mean they want the entire database. Nothing I have done has been successful, I either get just the search criteria exported, or I get the entire database depending on which version I try it from. Anyone have any ideas? -- 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] More frustration with MySQL and PHP
On Jan 21, 2008 2:57 PM, Jason Pruim [EMAIL PROTECTED] wrote: Today, I found a bug in my software which I was originally happy to find since that means there's one less that I have to worry about... 3 hours later while trying to figure out how to fix it I wish I never found it! Here's the deal, I have a file that exports the records in the database to excel, which works perfectly, except for 1 small thing... If you search the database first, it exports just those records. Basically what I need to do is allow people the choice of either exporting just certain search criteria, or the entire database without having to logout/login each time. I have tried using HTTP_REFERER to grab weither the user is coming from search.php (My search script) or directly from the index.php site which would mean they want the entire database. Nothing I have done has been successful, I either get just the search criteria exported, or I get the entire database depending on which version I try it from. Anyone have any ideas? -- 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 Is there any obvious reason why you cant say export.php?set=all or export.php?set=search and make your export work off that? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008 11:57 AM, Jason Pruim [EMAIL PROTECTED] wrote: Today, I found a bug in my software which I was originally happy to find since that means there's one less that I have to worry about... 3 hours later while trying to figure out how to fix it I wish I never found it! Here's the deal, I have a file that exports the records in the database to excel, which works perfectly, except for 1 small thing... If you search the database first, it exports just those records. Basically what I need to do is allow people the choice of either exporting just certain search criteria, or the entire database without having to logout/login each time. I have tried using HTTP_REFERER to grab weither the user is coming from search.php (My search script) or directly from the index.php site which would mean they want the entire database. Nothing I have done has been successful, I either get just the search criteria exported, or I get the entire database depending on which version I try it from. Anyone have any ideas? Just set a form var (or add a GET variable to your link) from your search.php page that says that you only want the searched records, something like: input type=hidden name=onlySearch value=1 / And then, in your export script, check for the existence of that variable before doing your query: ?php if (isset($_REQUEST['onlySearch']) and ($_REQUEST['onlySearch'] == 1)) { doSearchExport(); } else { doFullExport(); } ? HTH- James -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008, at 3:04 PM, James Ausmus wrote: On Jan 21, 2008 11:57 AM, Jason Pruim [EMAIL PROTECTED] wrote: Today, I found a bug in my software which I was originally happy to find since that means there's one less that I have to worry about... 3 hours later while trying to figure out how to fix it I wish I never found it! Here's the deal, I have a file that exports the records in the database to excel, which works perfectly, except for 1 small thing... If you search the database first, it exports just those records. Basically what I need to do is allow people the choice of either exporting just certain search criteria, or the entire database without having to logout/login each time. I have tried using HTTP_REFERER to grab weither the user is coming from search.php (My search script) or directly from the index.php site which would mean they want the entire database. Nothing I have done has been successful, I either get just the search criteria exported, or I get the entire database depending on which version I try it from. Anyone have any ideas? Just set a form var (or add a GET variable to your link) from your search.php page that says that you only want the searched records, something like: input type=hidden name=onlySearch value=1 / And then, in your export script, check for the existence of that variable before doing your query: ?php if (isset($_REQUEST['onlySearch']) and ($_REQUEST['onlySearch'] == 1)) { doSearchExport(); } else { doFullExport(); } ? HTH- James Hi James, I like you idea of setting it up with functions but with my meager knowledge of coding in php at all, functions are still a little out of my realm of comfort. But I will definitely be looking into it. For now, and for completeness, I have used Eric Butera's suggestion of adding a $_GET variable to pull from based on wether you are wanting the entire database, or just the search criteria. -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 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] More frustration with MySQL and PHP
On Jan 21, 2008, at 3:02 PM, Eric Butera wrote: On Jan 21, 2008 2:57 PM, Jason Pruim [EMAIL PROTECTED] wrote: Today, I found a bug in my software which I was originally happy to find since that means there's one less that I have to worry about... 3 hours later while trying to figure out how to fix it I wish I never found it! Here's the deal, I have a file that exports the records in the database to excel, which works perfectly, except for 1 small thing... If you search the database first, it exports just those records. Basically what I need to do is allow people the choice of either exporting just certain search criteria, or the entire database without having to logout/login each time. I have tried using HTTP_REFERER to grab weither the user is coming from search.php (My search script) or directly from the index.php site which would mean they want the entire database. Nothing I have done has been successful, I either get just the search criteria exported, or I get the entire database depending on which version I try it from. Anyone have any ideas? -- 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 Is there any obvious reason why you cant say export.php?set=all or export.php?set=search and make your export work off that? The only reason is I hadn't even thought of that... Now with that small change it works just fine! I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) -- 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] More frustration with MySQL and PHP
On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P -- 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] More frustration with MySQL and PHP
Jason Pruim [EMAIL PROTECTED] wrote: On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P He sure is ... and he's right too!! ;) A number of us are on here for both sharing the wealth and learning as we grow along. Years ago I was in your shoes, functions were something I didn't want anything to do with. Now though, I am finding a reason to write functions that I can use to handle a myriad number of things without having to code the same things over and over again. And I use the same functions for anything I write, so that as I grow a function or site, all of the function pages are updated and everything is where I need it. But even with all of that, sometimes the easiest solution is the simplest. ;) Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008, at 3:47 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:28 -0500, Jason Pruim wrote: On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P Quit responding, you're diluting my post wealth! :) Now I just need to find a way to increase the content of my posts. Best bet I guess would be to not trim the posts to which I reply :) Then again, endless rambling could help too... while honing my writing skill... WOOT! Two birds with that stone. Talking about stones, someone mentioned to me once a perplexing question whereby God was asked if he could create a stone he could not lift... well I... crap, list cops are at my door. I'll be write back!!! I did not realize that we were being judged not just on the merit of the fact that we know how to send a electronic-mail, but also on the length of said electronic-mail... Would that not give favor to people who appear to like to hear them selves talk (Or type in this case since I can not just call a simple txttospeach(Speak this electronic mail so that all may hear the glory that is my voice!);) and can get into long winded discussions about the theory of programming and how everything in computers works in a theoretical world? Or on the other hand, it could also lend it's self to people who go off on tangents about certain posts, or start talking about programming in Rocks. -- 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] More frustration with MySQL and PHP
On Jan 21, 2008 3:47 PM, Robert Cummings [EMAIL PROTECTED] wrote: Now I just need to find a way to increase the content of my posts. Just reply to everyone with random Wikipedia articles. You can even say it is on topic because it is generated with PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008 3:52 PM, Jason Pruim [EMAIL PROTECTED] wrote: Would that not give favor to people who appear to like to hear them selves talk (Or type in this case since I can not just call a simple txttospeach(Speak this electronic mail so that all may hear the glory that is my voice!);) and can get into long winded discussions about the theory of programming and how everything in computers works in a theoretical world? Actually, you can do text to speech in PHP. ;-P I wrote a PHP TTS module last year, so you can call txt2wav(). Tedd and some others have used it. It still needs work, and I'd hoped to have the new version done by the first of the year, but I missed. Until I get it a bit more stable, it's only on http://www.pilotpig.net/, with an old version at SourceForge. -- /Dan Daniel P. Brown Senior Unix Geek and #1 Rated Year's Coolest Guy By Self Since Nineteen-Seventy-[mumble]. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
On Jan 21, 2008, at 3:33 PM, Wolf wrote: Jason Pruim [EMAIL PROTECTED] wrote: On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P He sure is ... and he's right too!! ;) A number of us are on here for both sharing the wealth and learning as we grow along. Years ago I was in your shoes, functions were something I didn't want anything to do with. Now though, I am finding a reason to write functions that I can use to handle a myriad number of things without having to code the same things over and over again. And I use the same functions for anything I write, so that as I grow a function or site, all of the function pages are updated and everything is where I need it. But even with all of that, sometimes the easiest solution is the simplest. ;) I love the idea of functions, and think they will/do work great. The only problem is I haven't had time to learn how to write them to use them :) I need to find a new project that I can write for my company so I can learn about functions! :) -- 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] More frustration with MySQL and PHP
On Mon, 2008-01-21 at 15:28 -0500, Jason Pruim wrote: On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P Quit responding, you're diluting my post wealth! :) Now I just need to find a way to increase the content of my posts. Best bet I guess would be to not trim the posts to which I reply :) Then again, endless rambling could help too... while honing my writing skill... WOOT! Two birds with that stone. Talking about stones, someone mentioned to me once a perplexing question whereby God was asked if he could create a stone he could not lift... well I... crap, list cops are at my door. I'll be write back!!! Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More frustration with MySQL and PHP
Don't be scared of functions, no magic or mystery there, all you are doing is putting your code in a function like so: function add($a, $b) { return $a + $b; } ..for example and calling it like so: $a = 12; $b = 100; $sum = add(12, 13); ...etc etc, not too much more to learn than that and now I can call add() in many places... On Jan 21, 2008 8:47 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2008-01-21 at 15:28 -0500, Jason Pruim wrote: On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: I try so hard to NOT rely on the wealth of info available here, but you guys don't make it easy!! :) The only good thing to do with wealth is share. Now you're just trying to add to your post count! :P Quit responding, you're diluting my post wealth! :) Now I just need to find a way to increase the content of my posts. Best bet I guess would be to not trim the posts to which I reply :) Then again, endless rambling could help too... while honing my writing skill... WOOT! Two birds with that stone. Talking about stones, someone mentioned to me once a perplexing question whereby God was asked if he could create a stone he could not lift... well I... crap, list cops are at my door. I'll be write back!!! Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Jim Lucas wrote: Peter wrote: I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Something along the lines of this? ?php error_reporting(E_ALL); ini_set('display_errors', 1); $sql = SELECT DISTINCT [Table Name].[Column Name], . [Table Name 1].[Column Name 2]; echo {$sql}br /\n; preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER); $change = array(); foreach ( $matches AS $match ) { $change[$match[0]] = str_replace(' ', '_', $match[1]); } echo 'pre'.print_r($change,1).'/pre'; echo str_replace(array_keys($change), $change, $sql); Thanks Keith and Jim once I wake up I'll give both methods a try and let you know how I go. (Just having my morning coffee atm) I know I wont find the perfect converter as ms access lets you use to many 'bad' characters in column names. aah well only need to change about 600 queries. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] a better way to do a data import?
what about uploading the entire file into a [semi]temp table..then doing cross table comparisons to load your main table with the data? bastien Date: Mon, 21 Jan 2008 13:08:27 -0500 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: Re: [PHP] a better way to do a data import? I think that's possible, so I'll give it a shot. For some reason, even with straight inserts my php script is dying around 180,000 rows. Basically, I took out all the compare/update code so now I grab the row from the db and if there isn't one, do an insert. I've wiped my db so should do straight inserts so I'm not sure what's taking up the memory.private function processFile($table, $key){ $this-openFileForReading(); //foudn in GLFile class while (!feof($this-fileHandle)) { $file_data = fgets($this-fileHandle); $this-insert($table, $key, $file_data); } $this-closeFile(); } private function insert($table, $key, $data){ if (strlen($data)10) return false; $data=$this-db-escape_string($data); //this is the data we will use should we need to do an insert $insert_data = str_replace(\, ', $data); //this is a hack we need to change the separator of the file //we need this because we need to put the data into an array and if //we simply use the comma, then it splits address fields $data = str_replace(\,\, ~, $data); $data = str_replace(\,,$data); //let's remove the double quotes $this-setDelimiter(~); $dataToArray=$this-stringToArray($data); //set it back for other functions $this-setDelimiter(,); //get the id, we trust it is the first column $key_data=$dataToArray[0]; //does the value exist in the database already? $sql=select * from prelim_$table where $key='$key_data'; $handle=$this-db-select($sql); if ($this-db-row_count($handle)0){ $textData=array(); $colsToUpdate=; $dataRow=; $dataRow=$this-db-fetch_row($handle); //now that we have the data, let's merge the row from the //file with the column names $textData=array_combine($this-carrierColumns, $dataToArray); //cast some values that are strings in the text file $textData['cars1']=(int) $textData['cars1']; $textData['car_amount']=(int) $textData['car_amount']; $textData['total_work']=trim($textData['total_work']); $textData['business_zip']=trim($textData['business_zip']); //clean up some old db data $dataRow['rfc_number']=trim($dataRow['rfc_number']); $dataRow['business_zip']=trim($dataRow['business_zip']); $colsToUpdate=array_diff($textData,$dataRow); //if we have columns to update, do it if (count($colsToUpdate)0){ $colset=; foreach ($colsToUpdate as $column=$value){ $colset.=$column='$value',; } //strip last comma $colset=substr($colset, 0, -1); $sql=update prelim_$table set $colset where $key='$key_data'; $this-db-write($sql); } $dataRow=NULL; $colsToUpdate=NULL; $colset=NULL; $textData=NULL; } else{ //insert the row $sql=insert into prelim_$table values (; $sql.=trim($insert_data); $sql.=);; $this-db-write($sql); } } On Jan 21, 2008 12:55 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2008-01-21 at 12:35 -0500, blackwater dev wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Does Postgres support any method of temporarily disabling keys/indexing? Indexing is what causes the inserts to take a while. MySQL can optimize an import by locking the table and allowing the keys/indexes to be temporarily disabled. You'll see the following lines in recent MySQL database dumps surrounding the inserts: /*!4 ALTER TABLE `xxx` DISABLE KEYS */; INSERT ... INSERT ... /*!4 ALTER TABLE `xxx` ENABLE KEYS */; Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... _
Re: [PHP] avoid server folder reading
On Jan 20, 2008 6:13 AM, Richard Heyes [EMAIL PROTECTED] wrote: If your server's default file is index.php, you could use the following in an index.php file: ?php header('Location: /'); ? You really shouldn't use relative paths in a header location. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 14.30 Location The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI. Location = Location : absoluteURI An example is: Location: http://www.w3.org/pub/WWW/People.html Note: The Content-Location header field (section 14.14) differs from Location in that the Content-Location identifies the original location of the entity enclosed in the request. It is therefore possible for a response to contain header fields for both Location and Content-Location. Also see section 13.10 for cache requirements of some methods. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mssql and latin characters
On Jan 20, 2008 9:53 PM, Leticia Larrosa [EMAIL PROTECTED] wrote: Hello I have a MSSql 2000 database that have stored data with the follow special characters: ó, í, Ñ, á, é, ú. When I see the data through any MsSql Client I see exactly those characters. The Collation of database is: SQL_Latin1_General_CP1_CI_AS I can't change the method of insert data in database. When I get (with MSSQL PHP extension) data that have some of those characters, I get weird characters instead. For example: A data that in database appears as Girón is obtained by PHP as Gir¢n The problem with the encoding of browser is discarded, because wherever I saw the data appears with weird characters. The code I use to get the data is: ?php mssql_connect('server','user','pass'); mssql_select_db('db'); $r = mssql_query(select some_column from some_table); $d = mssql_fetch_assoc($r); echo $d['some_column']; ? My PHP is 4.4.3, and my SO is XP. Other people ask the same as I'm and get no answer proper are: http://www.psicofxp.com/forums/desarrollo-web.264/226703-php-mssql-y-acento s.html http://www.psicofxp.com/forums/desarrollo-web.264/226703-php-mssql-y-acentos .html http://www.bdat.net/cuestiones_php/php3/0702.html http://www.bdat.net/cuestiones_php/php3/0702.html http://www.forosdelweb.com/f18/problemas-con-caracteres-especiales-acentos- php-mssql-server-364345/ http://www.forosdelweb.com/f18/problemas-con-caracteres-especiales-acentos-p hp-mssql-server-364345/ http://markmail.org/message/7rksvz44sj2te5sl http://markmail.org/message/7rksvz44sj2te5sl http://www.phpbuilder.com/board/archive/index.php/t-10208269.html http://www.phpbuilder.com/board/archive/index.php/t-10208269.html Thanks in advanced. Leticia Larrosa __ Participe en Universidad 2008. 11 al 15 de febrero del 2008. Palacio de las Convenciones, Ciudad de la Habana, Cuba http://www.universidad2008.cu Hi Leticia, You should be using utf-8, really. What you're dealing with are encoding issues. 8bit character sets just can't hold all known characters, so people invented lots of them to make up for this. See my links below for an in depth look. Maybe, just maybe, we can trick the browser into showing your text right. Below the header and the meta tag are the key parts to it. Try this: ?php header(Content-Type: text/html; charset=iso-8859-1); ? html head meta http-equiv=content-type content=text/html; charset=iso-8859-1 /head body i18n ftw! /body /html You might also take a look at: http://www.microsoft.com/sql/technologies/php/default.mspx Also please read this: http://www.phpwact.org/php/i18n/charsets. And this too: http://talks.php.net/show/wereldveroverend-ffm2004 Have fun! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upgrade to PHP5 and having issues with mysql
Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Any thoughts or pointers on what I am doing wrong here? I've never had an issue before but I never had to compile PHP with mysql support since it was always part of the install. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] password hashing and crypt()
Nathan Nobbe wrote: hi all, recently ive been debating a bit about the use of the crypt() function and the best practice thereof, im hoping you can help to clarify this for me. so, the crypt function http://www.php.net/manual/en/function.crypt.php has a second parameter, $salt, which, if not supplied will be automatically generated and presumably become a prefix or suffix of the returned string. now, the article on the phpsec website http://phpsec.org/articles/2005/password-hashing.html recommends to externally create a salt and to store that in a separate field in the database, which would then be used for subsequent password verification. theoretically, however, if the password is generated without a user supplied salt, there is a salt already embedded in the password anyway. so, i have the following questions 1. is the phpsec technique bloated or unnecessary 2. is it better to create a user supplied salt, and why or why not 3. is crypt() 'intended' to be used w/o a user provided salt, since it is a stable algorithm crypt has some issues which I haven't seen anyone else mention. The salt is actually contained in the crypted string as the first two characters, there's no need to store it separately. ?php $string = '12345678'; echo crypt($string, 'ab') . \n; ab1iBa.N.U2C6 echo crypt($string, 'cd') . \n; cdsmm9tFWz3CI The next problem (more importantly) is that crypt only looks at the first 8 characters when generating a hash. It doesn't matter how big you make the string, it's the same as chopping it off at 8 characters. echo crypt(str_repeat($string, 40), 'cd') . \n; cdsmm9tFWz3CI The man page explains this (I think): http://linux.die.net/man/3/crypt However if you use md5 or sha1 or something else, then yes store the salt separately because that is *not* part of the hash that gets returned. -- 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] a better way to do a data import?
blackwater dev wrote: I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. // clone the table. create temporary table x as select * from othertable limit 1; in mysql: load data infile '/path/to/csv' into table 'x'; (http://dev.mysql.com/doc/refman/4.1/en/load-data.html) in postgres: \copy x from '/path/to/csv' (no semi-colon on the end). analyze; // make sure you do this otherwise the next step is going to take forever. step2: delete stuff from the temp table that already exists: delete from x where id in (select id from othertable); or some such variant. step3: insert left over stuff into real table. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] understanding memory allocation
Hi all, Does anyone understand the difference between memory_get_usage and memory_get_peak_usage with and without the parameter? I don't understand how the allocations could be so far apart. eg (small script that takes a minute to run): $ php -f file.php Peak usage (true): 4,608.0 Peak usage (false): 8,040.87891 The number is just memory_get_peak_usage($param)/1024 with $param true/false. Which one is right? How do I tell? Thanks. -- 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] regex
Jim Lucas wrote: Peter wrote: I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, Something along the lines of this? ?php error_reporting(E_ALL); ini_set('display_errors', 1); $sql = SELECT DISTINCT [Table Name].[Column Name], . [Table Name 1].[Column Name 2]; echo {$sql}br /\n; preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER); $change = array(); foreach ( $matches AS $match ) { $change[$match[0]] = str_replace(' ', '_', $match[1]); } echo 'pre'.print_r($change,1).'/pre'; echo str_replace(array_keys($change), $change, $sql); Jim You are a genius! Worked like a charm. I ran the string thru strlower and strreplace first then thru your code and it ended up exactly as I required it (all table/columns lower case, no % $ in column names etc). Thank you very much. Peter (Keith I havent tried yours as yet) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: a better way to do a data import?
blackwater dev [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a text file that contains 200k rows. These rows are to be imported into our database. The majority of them will already exists while a few are new. Here are a few options I've tried: I've had php cycle through the file row by row and if the row is there, delete it and do a straight insert but that took a while. Now I have php get the row from the text file and then to array_combine with a default array I have in the class so I can have key value pairs. I then take that generated array and do array_diff to the data array I pulled from the db and I then have the columns that are different so I do an update on only those columns for that specific row. This is slow and after about 180,000 rows, php throws a memory error. I'm resetting all my vars to NULL at each iteration so am not sure what's up. Anyone have a better way to do this? In MySQL, I could simply a replace on each row...but not in postgres. Thanks! Couldn't you just use PHP to rewrite the 200k row text file from just text, to actual insert commands? Once you have that, most mysql interfaces have an import ability where you can give it a file which is a list of commands (insert, update, etc.) and it will run them itself. That should be much faster. - Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resetting drop-downlists in input-fields for texts
David Giragosian [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 1/21/08, Tor Vidvei [EMAIL PROTECTED] wrote: I'm developing a traning page for basic math. The answers are entered by the user in simple text input fields and the same page is returned (after having been processed by php) to the user with indications of correctness or error on each answer. If the AutoComplete feature is turned on a droplist with previous entries are displayed in the answer fields, even if new exercises are generated. This is quite distracting. Is there any way I can block this feature from my php-code, even if it is turned on in the users browser? Tor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think this HTML is IE specific, form autocomplete=off ... /form Not sure if you can do it on a tag by tag basis or not, nor what versions it might be limited by. David This is only if you are using IE's autocomplete, I believe google and a ton of third party toolbars have auto complete/ form auto fill in features. - Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upgrade to PHP5 and having issues with mysql
Tom Ray [Lists] wrote: Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Did you get any errors when configure ran? I'm not sure if it will stop configure working when it can't find a library you want to compile in or if it just ignores the error and keeps going. -- 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] Upgrade to PHP5 and having issues with mysql
Chris wrote: Tom Ray [Lists] wrote: Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Did you get any errors when configure ran? I'm not sure if it will stop configure working when it can't find a library you want to compile in or if it just ignores the error and keeps going. No errors during the ./configure part only when I run make -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best Approach
Hello fellow members of this list, There is a couple of rutinary tasks that our servers (different platforms) perform during the night. Early during the day, we have to check that every task was performed correctly and without errors. Actually, we do this by hand, going first to server A (AIX platform), and verifying that the error logs files have a size of zero (0), which means that there were no errors to report on the logs, verify that some files have been written to a specific directory and so on. As I told you before, this is done by hand, many ls commands, greps and mores here and there!! On the other hand, I have to do this on a another Windows 2003 server!! So, Im thinking on creating a web page on PHP that performs all this tasks for me, and my fellow co-workers. But, all my experience with PHP is about working with data on MySQL server, wrting files to a harddisk, sending e-mails with or without attachments and so on. Is PHP a correct approach to solve this tedious problem?? Can I access a servers and get the results of a ls command for instance?? Best Regards, __ Miguel Guirao Aguilera, Linux+, ITIL Sistemas de Información Informática R8 - TELCEL Ext. 7540
Re: [PHP] Upgrade to PHP5 and having issues with mysql
Tom Ray [Lists] wrote: Chris wrote: Tom Ray [Lists] wrote: Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Did you get any errors when configure ran? I'm not sure if it will stop configure working when it can't find a library you want to compile in or if it just ignores the error and keeps going. No errors during the ./configure part only when I run make What happens if you configure --with-mysqli not --with-mysql ? Just wondering if it makes any diff.. it shouldn't really I don't think. -- 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] Best Approach
Miguel Guirao wrote: Hello fellow members of this list, There is a couple of rutinary tasks that our servers (different platforms) perform during the night. Early during the day, we have to check that every task was performed correctly and without errors. Actually, we do this by hand, going first to server A (AIX platform), and verifying that the error logs files have a size of zero (0), which means that there were no errors to report on the logs, verify that some files have been written to a specific directory and so on. As I told you before, this is done by hand, many ls commands, grep’s and more’s here and there!! On the other hand, I have to do this on a another Windows 2003 server!! So, I’m thinking on creating a web page on PHP that performs all this tasks for me, and my fellow co-workers. But, all my experience with PHP is about working with data on MySQL server, wrting files to a harddisk, sending e-mails with or without attachments and so on. Is PHP a correct approach to solve this tedious problem?? Can I access a servers and get the results of a ls command for instance?? If you run a series of commands in sequence, you can write a batch script or shell script to do the same. Then get cron or windows to run that script. cron at least can mail the results of a command and/or script to a specified email address, not sure about scheduled tasks in windows. -- 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] Best Approach
sure, why notyou can exec most of the commands and log all of the results to a file that you can email yourself bastien Date: Mon, 21 Jan 2008 17:55:11 -0600 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] Best Approach Hello fellow members of this list, There is a couple of rutinary tasks that our servers (different platforms) perform during the night. Early during the day, we have to check that every task was performed correctly and without errors. Actually, we do this by hand, going first to server A (AIX platform), and verifying that the error logs files have a size of zero (0), which means that there were no errors to report on the logs, verify that some files have been written to a specific directory and so on. As I told you before, this is done by hand, many ls commands, grep’s and more’s here and there!! On the other hand, I have to do this on a another Windows 2003 server!! So, I’m thinking on creating a web page on PHP that performs all this tasks for me, and my fellow co-workers. But, all my experience with PHP is about working with data on MySQL server, wrting files to a harddisk, sending e-mails with or without attachments and so on. Is PHP a correct approach to solve this tedious problem?? Can I access a servers and get the results of a ls command for instance?? Best Regards, __ Miguel Guirao Aguilera, Linux+, ITIL Sistemas de Información Informática R8 - TELCEL Ext. 7540 _ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] scandir() in automount/autofs
I configured autofs in my fedora so that when I plug any usb stick in /dev/sda1 it automatically mounts in /mnt/auto/usb0 There is two lines where the problem arise. $util-run_command(ls -1 /mnt/auto/usb0 | wc -l);// it shows 13 when I plug my usb stick. $list = scandir(/mnt/auto/usb0 ); // here $list is null This script is in a php file which is running by apache. the $util object is not actually running the command but it is inserting the command in a queue. There is daemon who has root access processing the queue. It means the command in $util-run_command() is executing with root privilege. this command mounts and get the total amount of file/folder very nicely But when I run the second line I see there is no file. How can I fill the list with those file list. It may look that the problem is regarding permission. But I don't think so. Becasue I use the same command I mean the same 2 lines with /mnt/cdrom, and it works very nicely It works, $util-run_command(ls -1 /mnt/cdrom | wc -l);// it shows 200 in my CD rom drive $list = scandir(/mnt/cdrom); // here I get full list of files/folders Why its happening? I want the $list to be filled. Also I need directory and file information so that I can make another list like array(array('Type'='DIR','Name'='music'),array('Type'='DIR','Name'='music1'),array('Type'='FIL','Name'=' elvis.mp3'),array('Type'='FIL','Name'='elvis2.mp3'),...); -- shout at http://me.cmyweb.net/ comment on http://talk.cmyweb.net/ All time available for Hire/Contract/Full Time :)
Re: [PHP] Upgrade to PHP5 and having issues with mysql
Chris wrote: Tom Ray [Lists] wrote: Chris wrote: Tom Ray [Lists] wrote: Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Did you get any errors when configure ran? I'm not sure if it will stop configure working when it can't find a library you want to compile in or if it just ignores the error and keeps going. No errors during the ./configure part only when I run make What happens if you configure --with-mysqli not --with-mysql ? Just wondering if it makes any diff.. it shouldn't really I don't think. Yeah it doesn't still have issues with it. I need to upgrade to PHP5 since some of the new OpenSRS stuff needs it but this is being a damn pain,. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upgrade to PHP5 and having issues with mysql
On Mon, 2008-01-21 at 18:01 -0500, Tom Ray [Lists] wrote: Hey- I'm trying to install PHP5 with mysql support and I keep running into the same problem over and over again. I run the configuration with this: --with-mysql=/usr/local/mysql and without fail I get this every time: ext/mysql/php_mysql.o: In function `zif_mysql_create_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1227: undefined reference to `mysql_create_db' ext/mysql/php_mysql.o: In function `zif_mysql_drop_db': /home/tech/upgrades/php-5.2.5/ext/mysql/php_mysql.c:1266: undefined reference to `mysql_drop_db' collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] Error 1 What am I doing wrong here? I'm running mysql 5.0.45 located at /usr/local/mysql which would my my lib directory at /usr/local/mysql/lib I have updated my ld.so.conf file to point to that and I'm still running into issues here. Any thoughts or pointers on what I am doing wrong here? I've never had an issue before but I never had to compile PHP with mysql support since it was always part of the install. What's your ld.so.conf pointing to for MySQL? It should be pointing to: /usr/local/mysql/lib/mysql And not: /usr/local/mysql/lib Presuming that /usr/local/mysql/ contains the following directories as expected: bin/ include/ info/ lib/ libexec/ man/ mysql-test/ share/ sql-bench/ Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] forms class
Why isnt this cleaning my form $_POST's class forms { var $UserInputClean; // Forms to variables function forms() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $curPostKey = forms::CleanInput($curPostVal); } } // Debug print_r($_POST); } // Clean XSS function CleanInput($UserInput) { $allowedtags = strongemaulliprehrblockquoteimgspan; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup .|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| [EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($text, $allowedtags); $UserInput = nl2br($UserInput); return $this-UserInputClean; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms class
On Mon, 2008-01-21 at 23:15 -0500, nihilism machine wrote: Why isnt this cleaning my form $_POST's class forms { var $UserInputClean; // Forms to variables function forms() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $curPostKey = forms::CleanInput($curPostVal); That should probably be something along the lines: $_POST[$curPostKey] = forms::CleanInput( $curPostVal ); } } // Debug print_r($_POST); } // Clean XSS function CleanInput($UserInput) { $allowedtags = strongemaulliprehrblockquoteimgspan; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup .|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| [EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($text, $allowedtags); $UserInput = nl2br($UserInput); return $this-UserInputClean; WTF? BAD MONKEY!!! This function is called statically and so $this is NOT available. You probably meant to do the following though: return $UserInput; } } Other comments for you... Don't use hard tabs, use spaces (preferrably 4). Switch to vertically aligned braces it makes it easier for me to read your code ;) if( $foo ) { } Cheers, Rob -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form cleaning class
now my debug shows that with the following code, all of the $_POST['whatever'] values are blank. class forms { var $UserInput; // Forms to variables function forms() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = forms::CleanInput($curPostVal); } } // Debug print_r($_POST); } // Clean XSS function CleanInput($UserInput) { $allowedtags = strongemaulliprehrblockquoteimgspan; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup .|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| [EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($text, $allowedtags); $UserInput = nl2br($UserInput); return $UserInput; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form cleaning class
On Mon, 2008-01-21 at 23:39 -0500, nihilism machine wrote: now my debug shows that with the following code, all of the $_POST['whatever'] values are blank. class forms { var $UserInput; // Forms to variables function forms() { if (count($_POST) 0) { foreach($_POST as $curPostKey = $curPostVal) { $_POST[$curPostKey] = forms::CleanInput($curPostVal); } } // Debug print_r($_POST); } // Clean XSS function CleanInput($UserInput) { $allowedtags = strongemaulliprehrblockquoteimgspan; $notallowedattribs = array(@javascript:|onclick|ondblclick| onmousedown|onmouseup .|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown| [EMAIL PROTECTED]); $changexssto = ''; $UserInput = preg_replace($notallowedattribs, $changexssto, $UserInput); $UserInput = strip_tags($text, $allowedtags); I think $text should be $UserInput :) $UserInput = nl2br($UserInput); return $UserInput; } } Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Tool for programmer team
What is a good tool to coordinate a team of programmers efficiently? To give each one a different part of the project is a start, but it needs to get combined at some points to be a working project. Not to debug code you have written was a hint, to see actually bugs as a bug and not as a feature. Some hinted let programmer be on different places, others say put them together on a big table, ... Where can I find more information about that subject? bye R
Re: [PHP] Tool for programmer team
It depends. If the project built up of slightly different modules, putting the coders on a big, white table seems to be a good idea. But if the modules are completely different, you should separate them, so each of them can be focused on their own subject. In this case, you have to have some people to make the whole project as one, seeing other programmers' works to combine. There are many tool you can use to manage the project. (I personally like open tools, like OpenProj which compatible with Microsoft Project, and if you want to have version controlling, I can suggest Microsoft Visual SourceSafe, or JEDI VCS). Each of them can handle a variety of subjects. OpenProj can organize jobs, and resources. Microsoft VSS and JEDI VCS are version controlling systems, which can handle the code itself, you can check-out modules, make changes, then check-in, so others can use your module as well. (and if you screwed something, you can change back to a previous version). I hope you can use these advices. And I think, your question is not definitely PHP question ... :) SanTa - Original Message - From: Ronald Wiplinger [EMAIL PROTECTED] To: php-general php-general@lists.php.net Sent: Tuesday, January 22, 2008 8:40 AM Subject: [PHP] Tool for programmer team What is a good tool to coordinate a team of programmers efficiently? To give each one a different part of the project is a start, but it needs to get combined at some points to be a working project. Not to debug code you have written was a hint, to see actually bugs as a bug and not as a feature. Some hinted let programmer be on different places, others say put them together on a big table, ... Where can I find more information about that subject? bye R -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php