[PHP] mysql:fixing gaps in id-key fields
hi, it happens to me quite often that after testing a mysql table or after deleting several rows that there are gaps in the numeration of my 'id field' (key). i always use the same field type for my 'id field:' id int(255) unsigned NOT NULL auto_increment, what is the best way to quickly correct the numeration in my id field, so that gaps are removed and the numeration is correct again? by 'gaps', i'm referring to when this auto_increment field has listings like 1 2 3 7 8 9 13 i have an sql snippet like this: ALTER TABLE mail_form2 ADD new_id INT UNSIGNED NOT NULL AUTO_INCREMENT, ADD INDEX (new_id); but this always creates the new key as the very last column in the table. also, i have to delete my original key first, or i get an error-message. isn't there a fast & simple way to correct a key-index? many thanks, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MySQL: copying entire columns
hi, i've created a mysql table from an excel csv dump and the field-order is not the way i want it. could someone possibly give me a hint on how i can create a copy of an entire column, place it in the position where i want in my table, and then delete the original column? i'm using phpMyAdmin and there doesn't appear to be any way to restructure my table--so i've gotta resort to sql. mucho gracias, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Excel and PHP in Unix
hi, i just wanted to put in a plug for my own code to generate dynamic Excel or Word files here. it's ultra easy to use: http://sourceforge.net/projects/php-doc-xls-gen/ thanks, tom Pavel Jartsev wrote: > > Iván Toda Caraballo wrote: > > > Hello, > > > > I am using the Unix version of PHP, and i would write some information from > > the HTML in a Excel file. I was made this using COM functions in a Windows > > version of PHP and it works. But COM functions are only available on the > > Windows version of PHP. > > > > I want to know how I can write a Excel file but using a Unix version of > > PHP. > > > > Thanks! > > > > Maybe this helps a little: > > http://sourceforge.net/projects/psxlsgen/ > > -- > Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL: copying entire columns
hi, miles: i think you helped me hit on something big here. each time i've been using INSERT statements in my php code, i've been addressing the field names in exactly the order they appear in my mysql table. ie: i've been using $sql = "Insert into $table_name(Name, Address, Phone) values('$Name','$Address','$Phone')"; where the columns appear in this order. but i think i finally realized that this (all in the wrong order) would work as well--if that's what you mean: $sql = "Insert into $table_name(Address, Phone, Name) values('$Address','$Phone','$Name')"; if this is true, it'll save me a lot of useless time trying to reorder my tables. thanks much, tom Miles Thompson wrote: > > Tom > > It's a relational database, field column position does not matter. One > Date's 121 rules, if I remember correctly. > > In terms of human readability, it sometimes matters. Check the MySQL > manual, I think there's an example of this under the ALTER TABLE command. > > But really, position doesn't matter, exept to fulfill a human sense of > "tidiness". > > Cheers - Miles Thompson > > At 01:53 PM 11/30/2001 +0100, Tom Churm wrote: > >hi, > > > >i've created a mysql table from an excel csv dump and the field-order is > >not the way i want it. could someone possibly give me a hint on how i > >can create a copy of an entire column, place it in the position where i > >want in my table, and then delete the original column? > > > >i'm using phpMyAdmin and there doesn't appear to be any way to > >restructure my table--so i've gotta resort to sql. > > > >mucho gracias, > > > >tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] max # of characters for links to work in emails?
hi, i'm working on an eCard project and somehow need to find out what the reasonable limit is on characters for urls in email bodies (normal text, not mime). i know that some mail clients will cut off urls that are too long or else throw a line break in the middle of them--thus rendering them 'unclickable'. and this is exactly what i wanna avoid. anyone have any advice to offer in this area? muchos gracias, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] comparing 2 mysql tables
hi, i've got 2 different MySQL tables. i need to check which entries in the text-field 'User' in one table are NOT present in the 'User' field in the other table. then i need to either save this array to a textfile or otherwise prepare it for creating a new, third table. any hints on how this kind of comparison operation can be accomplished? many thanks, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MySQL: Updating ID auto_increment fields
howdy, this should be simple but i don't know it. i use the following mysql table field as the Key for my tables: "id int(10) unsigned NOT NULL auto_increment," now, when i have to clean up items in my tables, like when users have sent off a .html form multiple times and i want to delete duplicate submissions, how can i quickly & easily update all of the 'id' fields in the entire table, to reflect the numeration change? now, using phpmyadmin, if i go in and delete a few entries, the id's have gaps in them.. mucho gracias, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] 2 General MySQL Questions
hi, i'm awared that this is not exactly the correct forum for these questions. please humor me this one time: 1) can anyone refer me please to a public, postable MySQL newsgroup? i've found a few MySQL newsgroups, but none of them allows posting. it would be great if you could also tell me the name of the (public) newsgroup server hosting the group. if you don't know of a newsgroup, how about a good (digest-capable) mailing list? i've tried the MySQL general mailing list, but they don't offer a 'digest' option and i can't handle getting hundreds of posts a day in my inbox. 2) who can refer me to a good intermediate tutorial to better learn MySQL syntax? again, i've been to mysql.com, but i find the structure & format of the site somehow daunting (not as user-friendly as the annotated manual at php.net). thanks muchly, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] substr() in MySQL SELECT?
hi, could someone please tell me why this doesn't work? i thought that string functions could be used in select statements? i dunno... SELECT User, SendDate FROM my_form WHERE substr(SendDate, 0, 2)=19; and i've tried the damn thing with brackets around all different parts. thanks much, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] substr() in MySQL SELECT?
hi, don: thanks a lot for the tip. and thanks even more for echoing the poor tone i used in my post--i will try to avoid writing such posts in the future. after looking at the documentation (many connection problems today), i was able to write this, like i wanted: SELECT User, SendDate FROM $table_name WHERE (Answer=0)&&( abs((SUBSTRING(SendDate, 1, 2)) - $NowDay) > 7 ) thanks again, tom Don Read wrote: > > On 19-Sep-2001 Tom Churm wrote: > > hi, > > > > could someone please tell me why this doesn't work? i thought that > > string functions could be used in select statements? i dunno... > > > > SELECT User, SendDate FROM my_form > > WHERE substr(SendDate, 0, 2)=19; > > > > and i've tried the damn thing with brackets around all different parts. > > > > Try to figure out the damn difference between PHP substr() & SQL SUBSTRING(). > > > thanks much, > > > > your welcome, > -- > Don Read [EMAIL PROTECTED] > -- It's always darkest before the dawn. So if you are going to >steal the neighbor's newspaper, that's the time to do it. -- Tom Churm . Pixelpark AG. . . . . . . . . . . . . . . . . . . Online Developer E-Marketing Rotherstrasse 8 . 10245 Berlin . Germany phone: + 49 30 5058 -1696 . fax: -1756 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Array Elements & While Loops
hi, my problem is this: i'm using a while loop to check elements in an Array for valid email syntax. if $User[0] is a valid email address but $User[1] is not, the code for $User[0] is still executed before the die statement. i need my loop to finish checking ALL array elements for validity, and to then die BEFORE any further code is executed. here's what i have now (it doesn't work): //loop to check for bad email addresses: $j = 0; $flag = 0; while ($j < count($User)){ if (($User[$j]!="")&&!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $User[$j])) { $flag = 1; $errorNo = $j + 1; } //die if flag is 1 if ($flag = 1) { die ("Email #$errorNo is not a valid e-mail address!Please return and correct this."); } else { continue... } any suggestions would be great! thanks much, tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Array Elements & While Loops
hi, _lallous: i've tried it with "==" and it still doesn't work: code for the valid variables is executed before my die() function is called. thanks, though, tom _lallous wrote: > > > if ($flag = 1) { > > die ("Email #$errorNo is not a valid e-mail > > should be: > > if ($flag == 1) // notice the double-equal signs > > "Tom Churm" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > hi, > > > > my problem is this: i'm using a while loop to check elements in an > > Array for valid email syntax. if $User[0] is a valid email address but > > $User[1] is not, the code for $User[0] is still executed before the die > > statement. i need my loop to finish checking ALL array elements for > > validity, and to then die BEFORE any further code is executed. here's > > what i have now (it doesn't work): > > > > //loop to check for bad email addresses: > > $j = 0; > > $flag = 0; > > while ($j < count($User)){ > > if > > > (($User[$j]!="")&&!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9- > ]+)*$", > > $User[$j])) > > { > > $flag = 1; > > $errorNo = $j + 1; > > } > > //die if flag is 1 > > if ($flag = 1) { > > die ("Email #$errorNo is not a valid e-mail > > address! > href='javascript:window.history.back();'>Please return and correct > > this."); > > } > > else { > > continue... > > } > > > > any suggestions would be great! > > > > thanks much, > > > > tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]