[PHP-DB] RE: [PHP] "Nested Set Model" or "modified preorder tree traversal" [SOLVED]
Since I couldn't find any short and sweet drop in code for this, I made my own. Here it is in case anyone else finds it helpful. Should be pretty straight forward. I use my own mysql wrapper functions, but you can pretty much figure out what they do and S&R your own. Hopefully this works as an attachement. D.Vin > -Original Message- > From: Daevid Vincent [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 22, 2006 12:42 PM > To: 'Curt Zirzow'; php-general@lists.php.net > Subject: RE: [PHP] "Nested Set Model" or "modified preorder > tree traversal" > > Peter Brawley on the mySQL list pointed me at: > http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html > > Which uses mySQL 5's procedures and such. > I haven't implemented this yet, but it appears to be what I > wanted for the > most part. > > > -Original Message- > > From: Curt Zirzow [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, February 21, 2006 10:58 PM > > To: php-general@lists.php.net > > Subject: Re: [PHP] "Nested Set Model" or "modified preorder > > tree traversal" > > > > On Tue, Feb 21, 2006 at 09:38:53PM -0800, Daevid Vincent wrote: > > > I've been searching the web for the past few hours trying > > to find a simple > > > drop-in class or functions to implement "Nested Set Model" > > or "modified > > > preorder tree traversal". > > > > I actually fell in love of this method of doing trees when I > > discovered it about a year ago, when researching a fast way to do > > a parent child retrieval. > > > > > > > > I've found several tutorials and related links: > > > > > > > > http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > > > http://www.sitepoint.com/article/hierarchical-data-database > > > > > > > > http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tut > > orial-ferrara2 > > > &id=3453&open=1&anc=0&view=1 > > > http://simon.incutio.com/archive/2003/06/19/storingTrees > > > http://istherelifeafter.com/joecelko.html > > > > http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp > > > > oh i have to add some of these to my list, i didn't have a couple > > of them. > > > > > > > > I even found some outdated PEAR DB_NestedSet class from > > 2003 that seemed way > > > to overly complicated. And some other PHP4_Mysql3MPTTA > > class on PHP Classes > > > that was equally complicated and written for ancient PHP4 > > and mySQL 3!! > > > > yeah, i kind of got that feeling with the PEAR class as well, i > > think it was designed that way to be as flexible as possible. I'm > > not familiar with the other class, i tend to avoid anything from > > PHP Classes. > > > > > > > > Hasn't anyone else done this before (recently)? > > > Did everyone just write their own code every time? > > > Anyone have some easy to use code that allows for: > > > Add, delete, update/rename, select, show tree, bread crumb > > display, etc. > > > > It would be nice to have a tool to manage the functionality. There > > will always be the issue with any common tool that is built for > > this purpose is how do you relate the table that defines the nested > > with the table that actually holds the data. > > > > I believe that why the PEAR and other classes you came across > > seemed to be overly complicated. I have found that it is easier to > > write my own management (as awful as that sounds) for the job at > > hand. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHPSession problem - help needed
Hi there everyone, I recently installed PHP 5 on my windows dev machine and it works great BUT I can't get sessions to work correctly and so my database logins won't work from my programming - which on a dev machine isn't good. Can anyone see something that is wrong in the sessions part of my PHP config file below? Any help would be greatly appreciated as it's stopping me fixing a members area bug I have in my database login script. Chris [Session] ; Handler used to store/retrieve data. session.save_handler = files ; Argument passed to save_handler. In the case of files, this is the path ; where data files are stored. Note: Windows users have to change this ; variable in order to use PHP's session functions. ; ; As of PHP 4.0.1, you can define the path as: ; ; session.save_path = "N;/path" ; ; where N is an integer. Instead of storing all the session files in ; /path, what this will do is use subdirectories N-levels deep, and ; store the session data in those directories. This is useful if you ; or your OS have problems with lots of files in one directory, and is ; a more efficient layout for servers that handle lots of sessions. ; ; NOTE 1: PHP will not create this directory structure automatically. ; You can use the script in the ext/session dir for that purpose. ; NOTE 2: See the section on garbage collection below if you choose to ; use subdirectories for session storage ; ; The file storage module creates files using mode 600 by default. ; You can change that by using ; ; session.save_path = "N;MODE;/path" ; ; where MODE is the octal representation of the mode. Note that this ; does not overwrite the process's umask. session.save_path = "/tmp" ; Whether to use cookies. session.use_cookies = 1 ; This option enables administrators to make their users invulnerable to ; attacks which involve passing session ids in URLs; defaults to 0. ; session.use_only_cookies = 1 ; Name of the session (used as cookie name). session.name = PHPSESSID ; Initialize session on request startup. session.auto_start = 0 ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime = 0 ; The path for which the cookie is valid. session.cookie_path = / ; The domain for which the cookie is valid. session.cookie_domain = localhost ; Handler used to serialize data. php is the standard serializer of PHP. session.serialize_handler = php ; Define the probability that the 'garbage collection' process is started ; on every session initialization. ; The probability is calculated by using gc_probability/gc_divisor, ; e.g. 1/100 means there is a 1% chance that the GC process starts ; on each request. session.gc_probability = 1 session.gc_divisor = 100 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime = 1440 ; NOTE: If you are using the subdirectory option for storing session files ; (see session.save_path above), then garbage collection does *not* ; happen automatically. You will need to do your own garbage ; collection through a shell script, cron entry, or some other method. ; For example, the following script would is the equivalent of ; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes): ; cd /path/to/sessions; find -cmin +24 | xargs rm ; PHP 4.2 and less have an undocumented feature/bug that allows you to ; to initialize a session variable in the global scope, albeit register_globals ; is disabled. PHP 4.3 and later will warn you, if this feature is used. ; You can disable the feature and the warning separately. At this time, ; the warning is only displayed, if bug_compat_42 is enabled. session.bug_compat_42 = 1 session.bug_compat_warn = 1 ; Check HTTP Referer to invalidate externally stored URLs containing ids. ; HTTP_REFERER has to contain this substring for the session to be ; considered as valid. session.referer_check = ; How many bytes to read from the file. session.entropy_length = 0 ; Specified here to create the session id. session.entropy_file = ;session.entropy_length = 16 ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. session.cache_limiter = nocache ; Document expires after n minutes. session.cache_expire = 180 ; trans sid support is disabled by default. ; Use of trans sid may risk your users security. ; Use this option with caution. ; - User may send URL contains active session ID ; to other person via. email/irc/etc. ; - URL that contains active session ID may be stored ; in publically accessible computer. ; - User may access your site with the same session ID ; always using URL stored in browser's history or bookmarks. session.use_trans_sid = 0 ; Select a hash function ; 0: MD5 (128 bits) ; 1: SHA-1 (160 bits) session.has
Re: [PHP-DB] Mail Function
opps sorry for the typos "you cant have"
Re: [PHP-DB] Mail Function
You can have 'blah'.} else { .'blah' because that is what you currently have.
Re: [PHP-DB] Mail Function
Mark Bomgardner wrote: I have been racking my brain for the better part of a day with a simple mail function. I am trying to generate a list of events from MySQL and then use the php Mail function to email the list in an html email to a mailing list. I keep getting a parse error on a section that I can not figure out why. ok, this is a general PHP question not realy a php-db type but 'sall good ;) a) the parse error is likely form a rogue quote (in the html perhaps) making a syntax error, hard to say with out the actual error b) are you sure mail() can tell that that is html and create the appropriate multi part MIME message? Highly doubtful since all mail() does is pipe the data to sendmail, I'd recommend using a valid MIME/SMTP tool like Perl's Mail::Sender::Easy module (http://search.cpan.org/perldoc?Mail::Sender::Easy) You can easily use Perl's DBI to do your MySQL query so there really is no need to try to hack up PHP's lame mail() function to do something it simply can't. HTH -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mail Function
I have been racking my brain for the better part of a day with a simple mail function. I am trying to generate a list of events from MySQL and then use the php Mail function to email the list in an html email to a mailing list. I keep getting a parse error on a section that I can not figure out why. The code is attached Markb http://www.w3.org/TR/html4/loose.dtd";> Up Coming Training Upcoming Training Event Sponsored by The Kansas Law Enforcement Training Center Listed below, you’ll find an assortment of Specialized Training classes being offered by the Kansas Law Enforcement Training Center during the months of March and April. Of special interest are the Ethics Instructor class being offered March 13 – 17; Field Training Officer class being offered March 13 – 15 in Dodge City; Crime Scene and Arson Photography class offered March 16 – 17. These classes should have a significant impact on those officers attending, providing new insight and expertise to your agency. Start Date Project Number Class Title Location '. do { if($row_Recordset1['special'] =='Y'){ .' '.date("m/d/Y", strtotime($row_Recordset1['Sdate'])).' '.$row_Recordset1['pnumber'].' '.$row_Recordset1['title'].' .'$row_Recordset1['city'].' '. }else{ .' '.date("m/d/Y", strtotime($row_Recordset1['Sdate'])).' '.$row_Recordset1['pnumber'].' '.$row_Recordset1['title'].' '.$row_Recordset1['city'].' '. } } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)).' '.mysql_free_result($Recordset1).'') ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
err columns.. sorry.. On Wednesday 01 March 2006 10:45 am, Micah Stevens wrote: > Ahh, good point, yes, keep in mind you may have some index rows.. > > On Wednesday 01 March 2006 10:18 am, [EMAIL PROTECTED] wrote: > > Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of > > all totally 100% unique records. > > > > If you had an auto_increment column though, you'd want to exclude it from > > the list. > > > > -TG > > > > = = = Original message = = = > > > > SELECT DISTINCT * FROM `tablename` > > > > On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: > > > My dear beloved friends, > > > > > > I have a catalog of products that a product provider gave, sadly for > > > me, in this CSV file there are many duplicated rows. > > > I edited the file in my Linux system with the "uniq -u" command, and it > > > worked somewhat fine, it eliminated some duplicated rows, originally > > > the file had 24K rows, and now it has been reduced to 15k rows. > > > > > > Anyhow, there are still duplicated rows, and since this is a catalog, > > > it should not have duplicated rows!!! > > > Now the catalog has been has been loaded into the DB. > > > > > > How can I continue eliminating duplicated rows? > > > As far as I remember the is a sentence in SQL to only show ONE row of > > > duplicated rows, maybe if I do a select using this sentence and then > > > put this new recordset in another table, it will work!! > > > > > > Any ideas? > > > > > > --- > > > Miguel Guirao Aguilera > > > Logistica R8 TELCEL > > > Tel. (999) 960.7994 > > > > > > > > > Este mensaje es exclusivamente para el uso de la persona o entidad a > > > quien esta dirigido; contiene informacion estrictamente confidencial y > > > legalmente protegida, cuya divulgacion es sancionada por la ley. Si el > > > lector de este mensaje no es a quien esta dirigido, ni se trata del > > > empleado o agente responsable de esta informacion, se le notifica por > > > medio del presente, que su reproduccion y distribucion, esta > > > estrictamente prohibida. Si Usted recibio este comunicado por error, > > > favor de notificarlo inmediatamente al remitente y destruir el mensaje. > > > Todas las opiniones contenidas en este mail son propias del autor del > > > mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. > > > de C.V. o alguna de sus empresas controladas, controladoras, afiliadas > > > y subsidiarias. Este mensaje intencionalmente no contiene acentos. > > > > > > This message is for the sole use of the person or entity to whom it is > > > being sent. Therefore, it contains strictly confidential and legally > > > protected material whose disclosure is subject to penalty by law. If > > > the person reading this message is not the one to whom it is being sent > > > and/or is not an employee or the responsible agent for this > > > information, this person is herein notified that any unauthorized > > > dissemination, distribution or copying of the materials included in > > > this facsimile is strictly prohibited. If you received this document > > > by mistake please notify immediately to the subscriber and destroy the > > > message. Any opinions contained in this e-mail are those of the author > > > of the message and do not necessarily coincide with those of Radiomovil > > > Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and > > > subsidiaries companies. No part of this message or attachments may be > > > used or reproduced in any manner whatsoever. > > > > ___ > > Sent by ePrompter, the premier email notification software. > > Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Ahh, good point, yes, keep in mind you may have some index rows.. On Wednesday 01 March 2006 10:18 am, [EMAIL PROTECTED] wrote: > Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all > totally 100% unique records. > > If you had an auto_increment column though, you'd want to exclude it from > the list. > > -TG > > = = = Original message = = = > > SELECT DISTINCT * FROM `tablename` > > On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: > > My dear beloved friends, > > > > I have a catalog of products that a product provider gave, sadly for me, > > in this CSV file there are many duplicated rows. > > I edited the file in my Linux system with the "uniq -u" command, and it > > worked somewhat fine, it eliminated some duplicated rows, originally the > > file had 24K rows, and now it has been reduced to 15k rows. > > > > Anyhow, there are still duplicated rows, and since this is a catalog, it > > should not have duplicated rows!!! > > Now the catalog has been has been loaded into the DB. > > > > How can I continue eliminating duplicated rows? > > As far as I remember the is a sentence in SQL to only show ONE row of > > duplicated rows, maybe if I do a select using this sentence and then put > > this new recordset in another table, it will work!! > > > > Any ideas? > > > > --- > > Miguel Guirao Aguilera > > Logistica R8 TELCEL > > Tel. (999) 960.7994 > > > > > > Este mensaje es exclusivamente para el uso de la persona o entidad a > > quien esta dirigido; contiene informacion estrictamente confidencial y > > legalmente protegida, cuya divulgacion es sancionada por la ley. Si el > > lector de este mensaje no es a quien esta dirigido, ni se trata del > > empleado o agente responsable de esta informacion, se le notifica por > > medio del presente, que su reproduccion y distribucion, esta > > estrictamente prohibida. Si Usted recibio este comunicado por error, > > favor de notificarlo inmediatamente al remitente y destruir el mensaje. > > Todas las opiniones contenidas en este mail son propias del autor del > > mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. > > de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y > > subsidiarias. Este mensaje intencionalmente no contiene acentos. > > > > This message is for the sole use of the person or entity to whom it is > > being sent. Therefore, it contains strictly confidential and legally > > protected material whose disclosure is subject to penalty by law. If the > > person reading this message is not the one to whom it is being sent > > and/or is not an employee or the responsible agent for this information, > > this person is herein notified that any unauthorized dissemination, > > distribution or copying of the materials included in this facsimile is > > strictly prohibited. If you received this document by mistake please > > notify immediately to the subscriber and destroy the message. Any > > opinions contained in this e-mail are those of the author of the message > > and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de > > C.V. or any of its control, controlled, affiliates and subsidiaries > > companies. No part of this message or attachments may be used or > > reproduced in any manner whatsoever. > > ___ > Sent by ePrompter, the premier email notification software. > Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Haha.. oh yeah.. DISTINCT works too.. in this case you'd get a list of all totally 100% unique records. If you had an auto_increment column though, you'd want to exclude it from the list. -TG = = = Original message = = = SELECT DISTINCT * FROM `tablename` On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: > My dear beloved friends, > > I have a catalog of products that a product provider gave, sadly for me, in > this CSV file there are many duplicated rows. > I edited the file in my Linux system with the "uniq -u" command, and it > worked somewhat fine, it eliminated some duplicated rows, originally the > file had 24K rows, and now it has been reduced to 15k rows. > > Anyhow, there are still duplicated rows, and since this is a catalog, it > should not have duplicated rows!!! > Now the catalog has been has been loaded into the DB. > > How can I continue eliminating duplicated rows? > As far as I remember the is a sentence in SQL to only show ONE row of > duplicated rows, maybe if I do a select using this sentence and then put > this new recordset in another table, it will work!! > > Any ideas? > > --- > Miguel Guirao Aguilera > Logistica R8 TELCEL > Tel. (999) 960.7994 > > > Este mensaje es exclusivamente para el uso de la persona o entidad a quien > esta dirigido; contiene informacion estrictamente confidencial y legalmente > protegida, cuya divulgacion es sancionada por la ley. Si el lector de este > mensaje no es a quien esta dirigido, ni se trata del empleado o agente > responsable de esta informacion, se le notifica por medio del presente, que > su reproduccion y distribucion, esta estrictamente prohibida. Si Usted > recibio este comunicado por error, favor de notificarlo inmediatamente al > remitente y destruir el mensaje. Todas las opiniones contenidas en este > mail son propias del autor del mensaje y no necesariamente coinciden con > las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, > controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no > contiene acentos. > > This message is for the sole use of the person or entity to whom it is > being sent. Therefore, it contains strictly confidential and legally > protected material whose disclosure is subject to penalty by law. If the > person reading this message is not the one to whom it is being sent and/or > is not an employee or the responsible agent for this information, this > person is herein notified that any unauthorized dissemination, distribution > or copying of the materials included in this facsimile is strictly > prohibited. If you received this document by mistake please notify > immediately to the subscriber and destroy the message. Any opinions > contained in this e-mail are those of the author of the message and do not > necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of > its control, controlled, affiliates and subsidiaries companies. No part of > this message or attachments may be used or reproduced in any manner > whatsoever. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Assuming you're using MySQL, instead of using INSERT INTO, you can use REPLACE INTO instead. If you have unique keys on that table, the new record will overwrite existing records with the same unique keys instead of creating a new one. http://dev.mysql.com/doc/refman/5.0/en/replace.html --Ade. Miguel Guirao wrote: > My dear beloved friends, > > I have a catalog of products that a product provider gave, sadly for me, in > this CSV file there are many duplicated rows. > I edited the file in my Linux system with the "uniq -u" command, and it > worked somewhat fine, it eliminated some duplicated rows, originally the > file had 24K rows, and now it has been reduced to 15k rows. > > Anyhow, there are still duplicated rows, and since this is a catalog, it > should not have duplicated rows!!! > Now the catalog has been has been loaded into the DB. > > How can I continue eliminating duplicated rows? > As far as I remember the is a sentence in SQL to only show ONE row of > duplicated rows, maybe if I do a select using this sentence and then put > this new recordset in another table, it will work!! > > Any ideas? > > --- > Miguel Guirao Aguilera > Logistica R8 TELCEL > Tel. (999) 960.7994 > > > Este mensaje es exclusivamente para el uso de la persona o entidad a quien > esta dirigido; contiene informacion estrictamente confidencial y legalmente > protegida, cuya divulgacion es sancionada por la ley. Si el lector de este > mensaje no es a quien esta dirigido, ni se trata del empleado o agente > responsable de esta informacion, se le notifica por medio del presente, que > su reproduccion y distribucion, esta estrictamente prohibida. Si Usted > recibio este comunicado por error, favor de notificarlo inmediatamente al > remitente y destruir el mensaje. Todas las opiniones contenidas en este mail > son propias del autor del mensaje y no necesariamente coinciden con las de > Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, > controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no > contiene acentos. > > This message is for the sole use of the person or entity to whom it is being > sent. Therefore, it contains strictly confidential and legally protected > material whose disclosure is subject to penalty by law. If the person > reading this message is not the one to whom it is being sent and/or is not an > employee or the responsible agent for this information, this person is herein > notified that any unauthorized dissemination, distribution or copying of the > materials included in this facsimile is strictly prohibited. If you received > this document by mistake please notify immediately to the subscriber and > destroy the message. Any opinions contained in this e-mail are those of the > author of the message and do not necessarily coincide with those of > Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates > and subsidiaries companies. No part of this message or attachments may be > used or reproduced in any manner whatsoever. > > -- Ade Olonoh - Independent Software Developer http://ade.olonoh.com | http://blog.olonoh.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
Depends on how you determine if something's a duplicate or not. For example, if it's just one column that can be used, you can do something like this: select ItemName, count(ItemName) from ItemListTable group by ItemName having count(ItemName) > 1 That'll show you if "ItemName" is repeated. Then you can go back through and just search for "ItemName" and remove the ones you don't want. You can do pretty much the same thing as above but CONCATenating multple columns if that's what you need to do to determine uniqueness. I know you're dealing with 15k rows still, so you probably want something a little more automated. Without more info though, it's hard to say exactly what can be done. Hope that helps a little bit. -TG = = = Original message = = = My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the "uniq -u" command, and it worked somewhat fine, it eliminated some duplicated rows, originally the file had 24K rows, and now it has been reduced to 15k rows. Anyhow, there are still duplicated rows, and since this is a catalog, it should not have duplicated rows!!! Now the catalog has been has been loaded into the DB. How can I continue eliminating duplicated rows? As far as I remember the is a sentence in SQL to only show ONE row of duplicated rows, maybe if I do a select using this sentence and then put this new recordset in another table, it will work!! Any ideas? --- Miguel Guirao Aguilera Logistica R8 TELCEL Tel. (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Duplicate rows
SELECT DISTINCT * FROM `tablename` On Wednesday 01 March 2006 7:24 am, Miguel Guirao wrote: > My dear beloved friends, > > I have a catalog of products that a product provider gave, sadly for me, in > this CSV file there are many duplicated rows. > I edited the file in my Linux system with the "uniq -u" command, and it > worked somewhat fine, it eliminated some duplicated rows, originally the > file had 24K rows, and now it has been reduced to 15k rows. > > Anyhow, there are still duplicated rows, and since this is a catalog, it > should not have duplicated rows!!! > Now the catalog has been has been loaded into the DB. > > How can I continue eliminating duplicated rows? > As far as I remember the is a sentence in SQL to only show ONE row of > duplicated rows, maybe if I do a select using this sentence and then put > this new recordset in another table, it will work!! > > Any ideas? > > --- > Miguel Guirao Aguilera > Logistica R8 TELCEL > Tel. (999) 960.7994 > > > Este mensaje es exclusivamente para el uso de la persona o entidad a quien > esta dirigido; contiene informacion estrictamente confidencial y legalmente > protegida, cuya divulgacion es sancionada por la ley. Si el lector de este > mensaje no es a quien esta dirigido, ni se trata del empleado o agente > responsable de esta informacion, se le notifica por medio del presente, que > su reproduccion y distribucion, esta estrictamente prohibida. Si Usted > recibio este comunicado por error, favor de notificarlo inmediatamente al > remitente y destruir el mensaje. Todas las opiniones contenidas en este > mail son propias del autor del mensaje y no necesariamente coinciden con > las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, > controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no > contiene acentos. > > This message is for the sole use of the person or entity to whom it is > being sent. Therefore, it contains strictly confidential and legally > protected material whose disclosure is subject to penalty by law. If the > person reading this message is not the one to whom it is being sent and/or > is not an employee or the responsible agent for this information, this > person is herein notified that any unauthorized dissemination, distribution > or copying of the materials included in this facsimile is strictly > prohibited. If you received this document by mistake please notify > immediately to the subscriber and destroy the message. Any opinions > contained in this e-mail are those of the author of the message and do not > necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of > its control, controlled, affiliates and subsidiaries companies. No part of > this message or attachments may be used or reproduced in any manner > whatsoever. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Subject: Where did my Hard Returns go?
At 14:00 01/03/2006, you wrote: Message-ID: <[EMAIL PROTECTED]> From: "Jeff Broomall" <[EMAIL PROTECTED]> To: Date: Wed, 1 Mar 2006 09:00:03 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_NextPart_000_0014_01C63D0E.87271600" Subject: Where did my Hard Returns go? I created an edit_task page that allows the user to edit tasks for the database. I entered some text and used some hard returns. But when I went to view the tasks (using a PHP script if it matters), the hard returns didn't "take." None of em. All of the text is jumbled together. I checked within the MySQL database and noticed the Hard Returns show in the database (at least while using phpMyAdmin). Must have something to do with PHP? Where did I go wrong??? No, it must not have something to do with PHP. View the source of your web page. You'll see those hard returns are recovered verbatim from the database. Web browsers *only* respect returns (newlines) in elements formatted as or when using a fixed pitch font in CSS. You need to nl2br($result_string) if you want to get HTML characters in the stream - browsers use not newlines to display line breaks. I thought everybody knew that ;-)) Cheers - Neil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Duplicate rows
My dear beloved friends, I have a catalog of products that a product provider gave, sadly for me, in this CSV file there are many duplicated rows. I edited the file in my Linux system with the "uniq -u" command, and it worked somewhat fine, it eliminated some duplicated rows, originally the file had 24K rows, and now it has been reduced to 15k rows. Anyhow, there are still duplicated rows, and since this is a catalog, it should not have duplicated rows!!! Now the catalog has been has been loaded into the DB. How can I continue eliminating duplicated rows? As far as I remember the is a sentence in SQL to only show ONE row of duplicated rows, maybe if I do a select using this sentence and then put this new recordset in another table, it will work!! Any ideas? --- Miguel Guirao Aguilera Logistica R8 TELCEL Tel. (999) 960.7994 Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta dirigido; contiene informacion estrictamente confidencial y legalmente protegida, cuya divulgacion es sancionada por la ley. Si el lector de este mensaje no es a quien esta dirigido, ni se trata del empleado o agente responsable de esta informacion, se le notifica por medio del presente, que su reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio este comunicado por error, favor de notificarlo inmediatamente al remitente y destruir el mensaje. Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos. This message is for the sole use of the person or entity to whom it is being sent. Therefore, it contains strictly confidential and legally protected material whose disclosure is subject to penalty by law. If the person reading this message is not the one to whom it is being sent and/or is not an employee or the responsible agent for this information, this person is herein notified that any unauthorized dissemination, distribution or copying of the materials included in this facsimile is strictly prohibited. If you received this document by mistake please notify immediately to the subscriber and destroy the message. Any opinions contained in this e-mail are those of the author of the message and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries companies. No part of this message or attachments may be used or reproduced in any manner whatsoever. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Where did my Hard Returns go?
Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation. http://php.he.net/manual/en/function.list.php Watch out for those "language constructs" which look to us like functions. Probably related to some folks preferring to write: if (... instead of if(... -Original Message- From: Philip Pryce [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 01, 2006 11:19 AM To: php-db@lists.php.net Subject: Re: [PHP-DB] Where did my Hard Returns go? You can't assign a value to a function! that is actually incorrect, the list(); function assigns a value to a functions vars. -- ~Philip Pryce -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Where did my Hard Returns go?
list() is a language construct. On Wednesday 01 March 2006 9:18 am, Philip Pryce wrote: > You can't assign a value to a function! > that is actually incorrect, the list(); function assigns a value to a > functions vars. > > -- > ~Philip Pryce -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Where did my Hard Returns go?
You can't assign a value to a function! that is actually incorrect, the list(); function assigns a value to a functions vars. -- ~Philip Pryce
RE: [PHP-DB] Where did my Hard Returns go?
Put nl2br() around the field in the table that you saved newlines nl2br($row['theTableFieldWithTheNewlines']) maybe ' . nl2br($row['task_usaction']) . ' -Original Message- From: Jeff Broomall [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 01, 2006 10:34 AM To: Jeff Broomall Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Where did my Hard Returns go? As for an update... Through trial-and-error, I've determined the following don't work... Attempt 1: nl2br($result) = mysql_query ($query); // Run the query. Attempt 2: $result = mysql_query ($query); // Run the query. $result = nl2br($result) Attempt 3: $bg = '#ee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#ee' ? '#ff' : '#ee'); // Switch the background color. echo nl2br( ' Edit ' . $row['task_task_no'] . ' ' . $row['icaotask_no'] . ' ' . $row['task_usaction'] . ' '); Now, attempt 3 kind of worked. It did insert the \n but it almost doubled the size of the table. IOW, instead of 13 rows (the correct number of rows), it stated the table off with 12 empty rows (alternating between the two color shades) and then displayed the 13 correct rows. Perhaps this was the proper placement of nl2br but there is something in the other code that screwed up the presentation??? Thanks. Jeff - Original Message - From: "Jeff Broomall" <[EMAIL PROTECTED]> To: Sent: Wednesday, March 01, 2006 9:00 AM Subject: [PHP-DB] Where did my Hard Returns go? Good morning. I created an edit_task page that allows the user to edit tasks for the database. I entered some text and used some hard returns. But when I went to view the tasks (using a PHP script if it matters), the hard returns didn't "take." None of em. All of the text is jumbled together. I checked within the MySQL database and noticed the Hard Returns show in the database (at least while using phpMyAdmin). Must have something to do with PHP? Where did I go wrong??? Thanks. --Jeff -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Where did my Hard Returns go?
You can't assign a value to a function! That's why attempt 1 didn't work. Well, that and: The value returned by mysql_query is NOT a string, it's a pointer to the values returned. You must fetch the string first to get the column values out. This is why your third attempt was the only one that actually had a chance of working. However, nl2br doesn't insert any \n's, it inserts a tag for every \n. (actually ). I think that's what you meant, but it's helpful to be specific. If it's displaying 25 rows (12 + 13), then that's likely how many rows are being returned by the database, you can check this by doing something like this: echo "Number of rows returned by query: ".mysql_num_rows($result).""; before the table. If that displays 25, then your issue isn't your code, but extra data in the table, which is what I suspect the problem is. You also didn't close your while loop, but that's just a copy/paste error I bet. You can also create the table with border=1 and this will let you see actual rows in the table, This loop will create 1 row for every row that's returned fromthe database, hinting at your issue. Hope that helps, -Micah On Wednesday 01 March 2006 8:34 am, Jeff Broomall wrote: > As for an update... > > Through trial-and-error, I've determined the following don't work... > > Attempt 1: > > nl2br($result) = mysql_query ($query); // Run the query. > > Attempt 2: > > $result = mysql_query ($query); // Run the query. > $result = nl2br($result) > > Attempt 3: > > $bg = '#ee'; // Set the background color. > while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { > $bg = ($bg=='#ee' ? '#ff' : '#ee'); // Switch the > background color. > echo nl2br( ' >$row['task_id'] . '">Edit > ' . $row['task_task_no'] . ' > ' . $row['icaotask_no'] . ' > ' . $row['task_usaction'] . ' > > > > '); > > Now, attempt 3 kind of worked. It did insert the \n but it almost > doubled the size of the table. IOW, instead of 13 rows (the correct > number of rows), it stated the table off with 12 empty rows > (alternating between the two color shades) and then displayed the 13 > correct rows. > > Perhaps this was the proper placement of nl2br but there is something > in the other code that screwed up the presentation??? > > Thanks. > > Jeff > - Original Message - > From: "Jeff Broomall" <[EMAIL PROTECTED]> > To: > Sent: Wednesday, March 01, 2006 9:00 AM > Subject: [PHP-DB] Where did my Hard Returns go? > > > Good morning. > > I created an edit_task page that allows the user to edit tasks for the > database. I entered some text and used some hard returns. > > But when I went to view the tasks (using a PHP script if it matters), > the hard returns didn't "take." None of em. All of the text is > jumbled together. > > I checked within the MySQL database and noticed the Hard Returns show in > the database (at > least while using phpMyAdmin). > > Must have something to do with PHP? Where did I go wrong??? > > Thanks. > > --Jeff -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Where did my Hard Returns go?
As for an update... Through trial-and-error, I've determined the following don't work... Attempt 1: nl2br($result) = mysql_query ($query); // Run the query. Attempt 2: $result = mysql_query ($query); // Run the query. $result = nl2br($result) Attempt 3: $bg = '#ee'; // Set the background color. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $bg = ($bg=='#ee' ? '#ff' : '#ee'); // Switch the background color. echo nl2br( ' Edit ' . $row['task_task_no'] . ' ' . $row['icaotask_no'] . ' ' . $row['task_usaction'] . ' '); Now, attempt 3 kind of worked. It did insert the \n but it almost doubled the size of the table. IOW, instead of 13 rows (the correct number of rows), it stated the table off with 12 empty rows (alternating between the two color shades) and then displayed the 13 correct rows. Perhaps this was the proper placement of nl2br but there is something in the other code that screwed up the presentation??? Thanks. Jeff - Original Message - From: "Jeff Broomall" <[EMAIL PROTECTED]> To: Sent: Wednesday, March 01, 2006 9:00 AM Subject: [PHP-DB] Where did my Hard Returns go? Good morning. I created an edit_task page that allows the user to edit tasks for the database. I entered some text and used some hard returns. But when I went to view the tasks (using a PHP script if it matters), the hard returns didn't "take." None of em. All of the text is jumbled together. I checked within the MySQL database and noticed the Hard Returns show in the database (at least while using phpMyAdmin). Must have something to do with PHP? Where did I go wrong??? Thanks. --Jeff -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Where did my Hard Returns go?
Jeff Broomall schrieb: Good morning. I created an edit_task page that allows the user to edit tasks for the database. I entered some text and used some hard returns. But when I went to view the tasks (using a PHP script if it matters), the hard returns didn't "take." None of em. All of the text is jumbled together. I checked within the MySQL database and noticed the Hard Returns show in the database (at least while using phpMyAdmin). Must have something to do with PHP? Where did I go wrong??? Thanks. --Jeff HTML doesn't care about "Hard Returns". I think you should transform them into . -> nl2br($text) Hope that helps, Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Where did my Hard Returns go?
Good morning. I created an edit_task page that allows the user to edit tasks for the database. I entered some text and used some hard returns. But when I went to view the tasks (using a PHP script if it matters), the hard returns didn't "take." None of em. All of the text is jumbled together. I checked within the MySQL database and noticed the Hard Returns show in the database (at least while using phpMyAdmin). Must have something to do with PHP? Where did I go wrong??? Thanks. --Jeff