Re: [PHP-DB] Database question
A really good starting-level textbook is Fabian Pascal's Practical issues in database management. My warm recommendation. It will give you a decent theoretical understanding as well as helping you designing your DB in order to avoid the most usual design mistakes. You will find there VERY important design stuff that you won't find in web tutorials. Ignatius Reilly - Original Message - From: Shiloh Madsen To: [EMAIL PROTECTED] Sent: Wednesday, August 21, 2002 1:34 AM Subject: [PHP-DB] Database question I was wondering if there were any good documents out there about good database design...I know the basics of creating tables, setting data types and such, and now i want to know how to use it to the best effect...generating logical, streamlined tables, etc. As a side-related note, i have a few tables now that call for some data which could be quite lengthly, say 3-6 paragraphs worth of text. what would be the best data style and length for this kind of field?
Re: [PHP-DB] Charts...
AFAI, to make really nice, Excel-style, dynamical charts, the best way is to export your MySQL data into a SVG string (a XML document), which can be viewed directly by the client browser (at least with IE5+) Someday MySQL will have a SELECT ... OUTPUT XML capability... I am currently looking for SVG templates for making dynamical plot and line charts; I haven't found much on the web. Can anyone help? Thanks Ignatius Reilly - Original Message - From: James Hatridge To: PHP_DB Sent: Wednesday, August 21, 2002 8:01 PM Subject: [PHP-DB] Charts... Hi all.. I'm using SuSE 8.0, mysql, and PHP4. Is it possible to make charts with a database? If so, how about a hint on it? Thanks JIM -- Jim Hatridge Linux User #88484 -- BayerWulf Linux System # 129656 The Recycled Beowulf Project Looking for throw-away or obsolete computers and parts to recycle into a Linux super computer -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Indepth Tutorial... need help.
For a SQL tutorial, I would recommend that you get yourself a copy of Joe Celko's SQL for smarties. Best investment I ever made. Everything you need to know is there. Bon courage! - Original Message - From: Matt Zur [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 03, 2002 3:08 PM Subject: Re: [PHP-DB] Indepth Tutorial... need help. Right well that's what I'm asking I need a tutorial and haven't found a good one. -Matt Rasmus Lerdorf wrote: Most of this stuff is actually just SQL and has little to do with PHP. So look for an SQL tutorial. From the PHP side all you need to know is mysql_connect(), mysql_select_db(), mysql_query() and mysql_fetch_row().'' All queries are sent to the database via mysql_query(). It doesn't matter to PHP if you are adding, deleting, modifying, searching, sorting, filtering, or whatever. You just put the SQL code in the mysql_query() call. -Rasmus On Tue, 3 Sep 2002, Matt Zur wrote: Can someone point me in the direction of an online tutorial for php mysql that covers the following: - Teaches me how to use php to access mysql - Creating a db that is structured to be efficient - How to add, modify, and delete records in a database - How to search for records - How to filter records - How to sort records, by a certain field, alphabetical, descending etc. - Indexes - how to create them, how to keep the updated with changes in the db a beginners look to in-depth approach. Yes I've visited PHP.net, and mysql.com. I need a dumbed down version that pretty much holds my hand and is very detailed. I've searched the net for a while now, and all the tutorials I have found... although simple... they don't go in-depth and move on to more advanced features. Any help at all will be greatly appreciated. -Matt -- Matt Zur [EMAIL PROTECTED] http://www.zurnet.com Need a Web Site??? - Visit... www.zurnet.com 1997 - 2002 - 5th Anniversary!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Matt Zur [EMAIL PROTECTED] http://www.zurnet.com Need a Web Site??? - Visit... www.zurnet.com 1997 - 2002 - 5th Anniversary!!! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] One last step
Try SELECT name, COUNT(*) AS nb FROM mytable GROUP BY name ORDER BY nb DESC Ignatius RClark [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hello all, I have a MySQL database with some 2 million rows in it. I am counting all of the different names in one column. How to I get these to come out in descending order, with the most numbers of one event at the top and going down from there? Thanks in advance, Ron Clark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Original Message - From: RClark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 03, 2002 4:27 PM Subject: [PHP-DB] One last step Hello all, I have a MySQL database with some 2 million rows in it. I am counting all of the different names in one column. How to I get these to come out in descending order, with the most numbers of one event at the top and going down from there? Thanks in advance, Ron Clark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Upload csv file into mysql
Hi Dr, try: LOAD DATA INFILE myfile.csv INTO TABLE mytable FIELDS TERMINATED BY , LINES TERMINATED BY \r\n ; of course, the structure of your CSV file must match exactly that of your table. hth - Original Message - From: Dr. Indera [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 04, 2002 6:20 AM Subject: [PHP-DB] Upload csv file into mysql Hello, Is there a way to upload data in a csv file into a mysql table? Thanks Indera -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Upload csv file into mysql
You have to create your CSV by escaping the real data commas (eg 1\,250\,260) when creating your CSV file - \ usually works, but you can choose sth else if you have \ actual data characters (usually not recommended!). and add ESCAPED BY \ to your LOAD statement HTH Ignatius - Original Message - From: Karel Pøíbramský [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; [EMAIL PROTECTED]; Dr. Indera [EMAIL PROTECTED] Sent: Wednesday, September 04, 2002 10:33 AM Subject: RE: [PHP-DB] Upload csv file into mysql Hi this is very helpful to me what if i have TABLE (id_item, rate1, rate2, rate3, rate4) and CSV file like foll id_item,rate1,rate2 1,250,260 2,270,280 5,290,290 ? thx kaja S prátelským pozdravem Karel Príbramský AbiaNet, s.r.o.-www.abianet.cz--- -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 04, 2002 9:51 AM To: [EMAIL PROTECTED]; Dr. Indera Subject: Re: [PHP-DB] Upload csv file into mysql Hi Dr, try: LOAD DATA INFILE myfile.csv INTO TABLE mytable FIELDS TERMINATED BY , LINES TERMINATED BY \r\n ; of course, the structure of your CSV file must match exactly that of your table. hth - Original Message - From: Dr. Indera [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 04, 2002 6:20 AM Subject: [PHP-DB] Upload csv file into mysql Hello, Is there a way to upload data in a csv file into a mysql table? Thanks Indera -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Form question.......
Another way is to refresh the page everytime the user has filled a field in and moves to another: FORM name=myform INPUT type =text name=field1 value= onchange=javascript:submit_field( 1 ) INPUT type=hidden name=field_to_check value= SCRIPT language=JavaScript function submit_field( i ) { document.myform.field_to_check.value = field + i ; document.myform.submit() ; } /SCRIPT The idea is that the onchange event is triggered when the user has input something and moves her mouse cursor somewhere else in the form. The javascript passes to the server the name of the field that is to be checked server-side. Supposes you have a consistent naming convention for fields, but you can easily adapt the js function ... Still, Rodrigo's idea of server-side checking every field one at a time does not seem much user-friendly to me. Better normally validate all POST-ed fields server-side upon form submit. - Original Message - From: Cal Evans [EMAIL PROTECTED] To: Rodrigo [EMAIL PROTECTED]; PHP [EMAIL PROTECTED] Sent: Thursday, September 05, 2002 2:58 PM Subject: RE: [PHP-DB] Form question... That's a toughie. I've done it once where I used a small popup window (opening it with JavaScript) to go to the server, perform the query to retrieve the information, stuff it into a JavaScript array and then return the array to the calling page and close the window. It works but the user will see a small window pop-up. Other than that, it is possible to use a Java Applet to do it as well. HTH, =C= * * Cal Evans * The Virtual CIO * http://www.calevans.com * -Original Message- From: Rodrigo [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 04, 2002 7:30 PM To: PHP Subject: [PHP-DB] Form question... Hi, i have a question, it may be dumb, but i´m very new with php and mysql, i need help. how can i check a form when i change from one field to another I want make a condition.if the number i typed is allready in the database, not just when i finish filling out the hole form...clickin in submit and then make the conditionshelp heheheh -- -- Rodrigo Corrêa [EMAIL PROTECTED] Obs: Sorry about the english, i´m from Brazil...so my english isn´t good -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php - checkboxes - mysql
Try something like this: INPUT type=checkbox name=?php echo( $row['name'] ) ; ? value=1 ?php echo( $row['homeno'] == 0 ? : checked ) ; ? (value is a dummy value - HTML will POST the name=value pair only if checked.) HTH Ignatius - Original Message - From: Chris [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 09, 2002 11:03 PM Subject: [PHP-DB] php - checkboxes - mysql Greetings, I am just starting with php and need some help/code example for setting checkbox values from mysql. My setup is the following: The mysql database holds data and checkbox values in respective columes. For example name address phone homeno workno pagerno Chris 555-1212 1 0 0 1 = checkbox should be checked 0 = checkbox should not be checked On the webpage side I would have name, address and phone number textboxes, and then 3 checkboxes for the homeno, workno and pagerno. When the page loads I would like to have the checkboxes be automatically checked or left uncheck based on the mysql query to the db. I do not want to do any grouping or anything, just query mysql for the homeno value, set it, then check the workno value, set it, etc.. Any help is GREATLY appreciated. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Trying to speed up php output from mysql
Does your process hang or simply is too long? Perhaps the limiting factor is not the writing speed, but a memory requirement problem. Try to compute how long it should take: - do your row processing after a SELECT ... LIMIT 1000 clause - time how long it takes, and extrapolate Then you will know. Ignatius - Original Message - From: Phin Pope [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, September 17, 2002 1:04 PM Subject: [PHP-DB] Trying to speed up php output from mysql Hi, I've got a script that I've written that writes out a xml file from mysql via php. The file should contain 250,000 xml style records, but it takes so long to generate the file the process has to be stopped before complete. I can't use mysqldump because of some of the processing that is required on the fields after they are extracted. Is there a faster way to write to a file than fwrite() or any other bright ideas? Phin \\\___/// \\ - - // ( @ @ ) +oOOo-(_)-oOOo-+ | phin pope - [EMAIL PROTECTED] | | Created for the benefit of all life | | Web Development and Creative Insight | | Webnetism Tel: +44 1452 855222 | +-Oooo-+ oooO ( ) ( )) / \ ((_/ \_) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.389 / Virus Database: 220 - Release Date: 16/09/2002 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] joining 2 tables - help please..
Try: SELECT C.category_name, SUM( IF( ISNULL( P.product_ID ),0, 1) ) AS total FROM category AS C LEFT JOIN product AS P ON C.category_ID = P.category_ID GROUP BY C.category_ID Ignatius - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 18, 2002 10:09 AM Subject: [PHP-DB] joining 2 tables - help please.. I have 2 tables as follows: product table | product_id | name | category_id | 1| coffee| 2 | 3| orange|1 | 5| mango|1 | 2| tea |2 and category table |category_id | category_name | |2| drinks| |1| fruit | |4| desert| |5| main | I want to get how many product in each category using sql statement, but I keep getting NULL for the one that doesn;t have product link. I want to get result from all category like this: drinks (2), fruit(2), desert(0), main(0). Help please... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL update help
When in doubt, bracket : $sql = UPDATE $table SET pages = '{$PHP_SELF}' WHERE session = '{$holy_cow}'; Less cute, but more readable. Ignatius - Original Message - From: Dave Smith [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, September 21, 2002 2:07 AM Subject: Re: [PHP-DB] SQL update help Jeffrey is right, but here's an easier way: $sql = UPDATE $table SET pages = '$PHP_SELF' WHERE session = '$holy_cow'; Be sure you use double-quotes to build the string (so that all variables get interpolated) and single-quotes within. Any non-numeric value has to be quoted for an SQL statement to work properly. Good luck! --Dave [EMAIL PROTECTED] wrote: if you put quotes around the variable $PHP_SELF it should work...try this. UPDATE $table SET pages = '.$PHP_SELF.' WHERE session = $holy_cow hth -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Flush database
why not simply store the server time at log in in the DB after a successful log in together with the IP address; and at the next log in request perform a SQL time difference comparison? Ignatius - Original Message - From: wade [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, September 27, 2002 10:53 PM Subject: [PHP-DB] Flush database I am storing IP addresses in a database, but after an hour has passed I want to delete all the IP addresses from that database. I want to do this based on the server time. Example.. Someone comes to my web page, I store their IP address in my database. So now I write a PHP script that says if that IP returns to my page within an hour, they can't view my page. If they come back after an hour has passed they can view the contents of that page. but only after an hour has passed. Can anyone help me with the syntax or functions that will clear the database after an hour of waiting has passed? Is this possible? Any suggestions, logic or any help on this matter will be greatly appreciated. Thank you -- Should you have any questions, comments or concerns, feel free to call me at 318-338-2033. Thank you for your time, Wade Kelley, Design Engineer Bayou Internet...(888) 30-BAYOU...http://www.bayou.com Mississippi Internet...(800) MISSISSIPPI...http://www.mississippi.net Vicksburg Online...(800) MISSISSIPPI...http://www.vicksburg.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] results of query
It depends what you want to do with it. To display it in HTML, you can write them in a 2-D array: myarray[$i][$j], where $i is the row nb and $j the column nb, and write two nested loops. To export them to Access, CSV, ... you can issue your query through Access ODBC. You can then save as a CSV. Very simple and effective. Ignatius - Original Message - From: Edward Peloke [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 10:07 PM Subject: [PHP-DB] results of query What does everyone typically use to display the results of a query. For example, I have a database that has a series of subjects and grades. If I select * from the table, I want a nice way for the data to be displayed. In cold fusion, I can simply use a grid that dynamically fills in. Can I do this with php? Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Javascript
I have met this problem before. The only solution I have found is to assign 0 values to the INPUT tags: input type=text name=field1 addChange=add(); value=0 HTH Ignatius - Original Message - From: Shahmat Dahlan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 11, 2002 11:34 AM Subject: [PHP-DB] Javascript My question might have anything to do with PHP but I have the following scenario: Say I have four fields field1 : field2 : field3 : field4 : And a total sum field, which is a total sum of the value of the expression, totalsum = field1 + field2 + field3 + field4 Total sum : XXX You would need to use Javascript to extract the value of field1, field2, field3, field4, initiated by the Javascript onChange event. The HTML codes should look like this: input type=text name=field1 addChange=add(); input type=text name=field2 addChange=add(); input type=text name=field3 addChange=add(); input type=text name=field4 addChange=add(); input type=text name=totalsum So the add function snippet that I have: function add() { var thisform=document.forms[0]; var field1=thisform.field1.value; var field2=thisform.field2.value; var field3=thisform.field3.value; var field4=thisform.field4.value; var totalqty=field1+field2+field3+field4; thisform.totalsum.value=totalqty; } But all I got is a NaN which means Not A Number. I understand that you solve this by using the parseInt Javascript function. But still all i get is a NaN value. Would appreciate if someone could help me out on this. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Javascript
Thanks for the tip. Well, my problem came from that parseInt() did not do the expected job. Like in: field1 = parseInt( thisform.field1.value ) + parseInt( thisform.field2.value ) ; If you happen to know the reason, I would love to know. Ignatius - Original Message - From: Simon Taylor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 11, 2002 4:03 PM Subject: RE: [PHP-DB] Javascript The reason for this is these fields are regarded as text and unless you specify number(variable) it may treat it as text.. When Field1='0' Field2='1' Field3='2' Field1+Field2+Field3 = '012' If you use Field1=Number('0') Field2=Number('1') Field3=Number('2') Field1+field2+field3 = 3 Cheers Simon -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED]] Sent: 11 October 2002 15:48 To: Shahmat Dahlan; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Javascript I have met this problem before. The only solution I have found is to assign 0 values to the INPUT tags: input type=text name=field1 addChange=add(); value=0 HTH Ignatius - Original Message - From: Shahmat Dahlan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 11, 2002 11:34 AM Subject: [PHP-DB] Javascript My question might have anything to do with PHP but I have the following scenario: Say I have four fields field1 : field2 : field3 : field4 : And a total sum field, which is a total sum of the value of the expression, totalsum = field1 + field2 + field3 + field4 Total sum : XXX You would need to use Javascript to extract the value of field1, field2, field3, field4, initiated by the Javascript onChange event. The HTML codes should look like this: input type=text name=field1 addChange=add(); input type=text name=field2 addChange=add(); input type=text name=field3 addChange=add(); input type=text name=field4 addChange=add(); input type=text name=totalsum So the add function snippet that I have: function add() { var thisform=document.forms[0]; var field1=thisform.field1.value; var field2=thisform.field2.value; var field3=thisform.field3.value; var field4=thisform.field4.value; var totalqty=field1+field2+field3+field4; thisform.totalsum.value=totalqty; } But all I got is a NaN which means Not A Number. I understand that you solve this by using the parseInt Javascript function. But still all i get is a NaN value. Would appreciate if someone could help me out on this. Regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL REGEXP functionality... any way to make this easier?
If you want to generalize the process to a n-set, a recursion method is clearly required. XSLT looks the best candidate to me to do this. I will tackle it when I find some time. Cheers Ignatius - Original Message - From: Xepherys [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, October 10, 2002 8:26 AM Subject: [PHP-DB] MySQL REGEXP functionality... any way to make this easier? Right now, a sample query I might have would be... SELECT * FROM ospd WHERE word REGEXP '^([a]?[p]?[e]?)$|^[p]?[a]?[e]?$|^[a ]?[e]?[p]?$|^[p]?[e]?[a]?$|^[e]?[p]?[a]?$|^[e]?[a]?[p]?$'; where basically I need to query every combination of a, p and e. This is a pain, but for only three letter is not so bad. As you can see, this could become unruly with larger numbers of letters. Each instance of a letter can only occur once. However, a letter may be duplicated and used once for each instance. Hence the statement steps through... it could also be something like... SELECT * FROM ospd WHERE word REGEXP '^[a]?[a]?[e]?$|^[a]?[e]?[a]?$||^[e]?[a]?[a]?$'; more easily written because one letter is used twice and can occure once for each instance. Please let me know if you have any ideas. Jesse [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] desperate need for MySQL host
I know and use a very good one, if you can understand French: www.ovh.net Free PHP, MySQL, XSLT support. Ignatius - Original Message - From: Seabird [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, October 15, 2002 9:46 PM Subject: [PHP-DB] desperate need for MySQL host Hi everyone, as a pilot in difficult times, I'm not in the position to pay for my webhosting. My solution that I have right now is less then desirable, as I have either PHP support and no ads, or PHP and MySQL (limit one DB) with pop-up ads. I'm looking for a place that is willing to provide me with minimum space to host 2 DB's with outside acces so that I can use it via my PHP provider. No Warez, No Porn, No Illegal things. Just some airline and airport Db's. Pls, due to my situation, don't refer me to paid hosting (no matter how cheap). I appreciate the thought you put in. Jacco Attitude is Everything! But Remember, Attitudes are Contagious! Is Yours worth Catching -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Variable won't be passed from HTTP address bar
Try instead: if( $_POST['action'] ==test ){ echo Test;} HTH Ignatius - Original Message - From: Michel Bakkenes - bakkenes.net [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 18, 2002 1:26 PM Subject: [PHP-DB] Variable won't be passed from HTTP address bar Ok.. I'm not a newbie I thought.. I do have experience with PHP, but I never suffered from this error. I used on my own redhat 8.0 server the following test-script: if($action==test){ echo Test;} I tried it to run with: 127.0.0.1/index.php?action=test It doesn't print anything. (which means I even can't print hello world :P) Oh, other variable constructions like $bla = blah . echo $bla etc. do work.. With regards, Michel Bakkenes J2ee developer Infolook BV Zevenbergen, The Netherlands -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Custom Sort Order in MySQL
You can use an auxiliary lookup table: FK_mygraderank - Secret1 A+ 2 ... Now join this table to your SELECT query on FK_mygrade, add 'rank' to the SELECT items, and ORDER BY rank HTH Ignatius - Original Message - From: Steve Vernon [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, October 19, 2002 9:46 PM Subject: [PHP-DB] Custom Sort Order in MySQL Hiya, Just wondering what is the best way to get some data out of a database in cutom order. They all have grades like A*, A, B, C and some are grade Secret. If I sort them by grade secret is at the bottom, I would like this at the top. I realise I could get all the Secret's, then A*, then A as seperate calls, but id prefer to get them all in the correct order as I belive this will be faster. Any help would be very much appreciated. Thanks! Steve -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] printing an array
Hi, usually, one issues an HTML row for each row of the query result. BTW, don't forget TR elements! But your query results has only one row, and your table has 4 columns. Can you explain in more detail what you want to do? Ignatius - Original Message - From: Chris Grigor [EMAIL PROTECTED] To: PHP Gen [EMAIL PROTECTED] Cc: PHP DB [EMAIL PROTECTED] Sent: Thursday, October 24, 2002 10:07 AM Subject: [PHP-DB] printing an array Hey there all Im sure that someone out there can answer this question.. I have a problem, how can I print each element in an array so that is returned into a table? eg table width=100% th width=25% nowrap Test1 /th th width=25% nowrap Test2 /th th width=25% nowrap Test3 /th th width=25% Test4 /th ?php include(common.inc); $link_id = mysql_connect($dbhost, $username, $password) or die (Connection Failed); mysql_select_db($db); $query = select Routine_Tests_Count from CDT_Routine_Tests where Ref_num = '$ref_num' order by Routine_Tests_Link; $result = mysql_query($query, $link_id) or die (Query on $dbhost failed); while ($row = mysql_fetch_object($result)) { print td$row-CDT_Routine_Count/td;--- (This value holds the Results of test1 test 2 etc that I need to print into the table) } mysql_free_result($result); ? /table Any help with this or direction would be appreciated ! Regards Chris -- Chris Grigor -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Enum table entry
Hi, in some cases, you might prefer to use a multiple SELECT element; this can give you a much more compact user interface (though you probably won't use it if you have 40 options ...) It goes like this: SELECT multiple name=action[] size=5 OPTION value=0 selected=selected--all--/OPTION OPTION value=1conjuration/OPTION OPTION value=2abjuration/OPTION ... OPTION value=ndivination/OPTION /SELECT will pass an associative array $_POST['action'] ( 1 = conjuration, ..., n = divination ) Here I use the value 0 to select all - this calls a simple script to generate the sequence 1,2, ...,n that will be written into the DB. (In general it is nice to provide a all checkbow when you have a long list.) I use a set( '1','2', ..., 'n') MySQL datatype to store the thing. The data appears physically as 1,2,...,n. Quite convenient. Probably a bit more economical than storing a varchar (says the MySQL documentation ...) HTH Ignatius - Original Message - From: John Nichel [EMAIL PROTECTED] To: Tom Rogers [EMAIL PROTECTED] Cc: Shiloh Madsen [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, October 19, 2002 9:15 AM Subject: [PHP-DB] Re: [PHP] Enum table entry You know, I didn't even think about serializing the array. I have a table set up for spells, one for schools, and a linking table using the spell id and the school id(s). I could have done without the linking table. Some of you people are pretty freakin' smart. :) One note though, when you pull the serialized data out, you may have to stripslashes before unserialize... $school = unserialize ( stripslashes ( $row['school'] ) ); Tom Rogers wrote: Hi, Saturday, October 19, 2002, 2:48:14 PM, you wrote: SM Have a question that im trying to figure out how to resolve. I have a field type in mysql that is of the enum type. Unless youre familiar with Dungeons and Dragons, you wont get what the values SM mean, but hopefully youll get the gist anyway. I have a column labelled school which holds an enum data type comprised of the values 1 through 40. From the website front end, where the data is SM being entered, i want to display, ideally a series of checkboxes, otherwise a list which would allow a user to select multiple items in that will translate into this enum field. For instance, a SM series of checkboxes with items such as abjuration, conjuration, divination, and others, which will all have a numeric value which gets plugged into the enum field. for instance, if a user SM selected abjuration, and divination, it would be plugged into sql as 1, 3 (or however enum data is input into its column). That being the case how do i utilize php to get this to work? what kind SM of form elements etc... The problem im seeing with checkboxes are that they are discreet and dont group together, so i cant get all the data to go into one column in mysql. Hopefully i havent SM horribly confused the issue and some kind soul out there can tell me how to send this data across. As a double nice thing...how would you write it to pull the data back out...ie, convert 1, 3 to SM show abjuration, divination? Thanks for the help in advance. I have never used enum type but I am sure it is not what you want as it will only store one item from a predefined list not a list of items. What you need to do is create an array of the selected items, serialize() it to store in the database in a varchar or mediumtext if it going to get big. Then when you read it back unserialize and loop through all the options setting checked if it is in the array. To keep the checkboxes grouped name them like this: input type=checkbox name=school[1] input type=checkbox name=school[2] input type=checkbox name=school[3] That will show up as an array under $_POST['school'] so you can serialize it as is and store it. ? if(isset($_POST['school'])) $school = serialize($_POST['school']); ? Playback is simple too ? $school = unserialize($row['school']); for($i = 1;$i 41;$i++){ echo 'input type=checkbox name=school['.$i.']'; if(isset($school[$i])) echo ' checked'; echo ''; } Un-checked boxes are not returned in the post and checked ones return Yes I think. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting rows where column has changed?
How often in a day must you do this? Every 5mn? Ignatius - Original Message - From: Leif K-Brooks [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, October 27, 2002 7:33 AM Subject: [PHP-DB] Getting rows where column has changed? I'm trying to make a page to help in detecting people using automatic refresher programs. In the table that stores user info, there is a column called lastseen which says when the user was last seen. I'm trying to: 1. Select all lastseen colmns that are less than 5 minutes old 2. Wait 2 seconds 3. Select lastseen columns that have changed since step 1, and display that info Any ideas on how to do this? Is it even possible? Thanks... -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date and time issues
If you are using MySQL, you may profitably investigate the function DATE_ADD( date, INTERVAL ) Ignatius J. Reilly - Original Message - From: Frederik Feys [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 10:32 PM Subject: [PHP-DB] Date and time issues Hi all, I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick today's date and add XXX days to it. Its setup to validate membership period. Now my column is of date type. Aswell, I want to pick current time and add 1 hour to it. Here aswell, sessions expire after one hour. Can anybody help me? Thanks Fred My code: $time = getdate(); $yr = $time[year]; $mn = $time[mon]; $dy = $time[mday]; if (subscr_type==1) { //these users van only work 1 hour $exp_time=time()+3600; $new_exp_day = getdate(); } else if (subscr_type==3) { //3 months subscription(here time doesn't really matter) $offset = 90; } else if (subscr_type==12) { //1 year subscriptions $offset = 365; } $new_exp_day = strftime(%Y-%m-%d,mktime(0,0,0,$mn,$dy+$offset,$yr)); -- Frederik Feys [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Idea as to why this query won't work as expected?
AND/ OR precedence mistake. Your query will return all the rows for which order_status='Not Shipped' Probably what you want is: select * FROM OrderTable WHERE submitted=1 AND dateinserted='1036386000' AND dateinserted='1036502796' AND ( order_status='Shipped' OR order_status='Not Shipped' ) HTH Ignatius J. Reilly - Original Message - From: Aaron Wolski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 05, 2002 2:59 PM Subject: [PHP-DB] Idea as to why this query won't work as expected? Hi All, I have a query like: select * FROM OrderTable WHERE submitted=1 AND dateinserted='1036386000' AND dateinserted='1036502796' AND order_status='Shipped' OR order_status='Not Shipped' Now.. if I omit the AND order_status='Shipped' OR order_status='Not Shipped' part the query works fine and only returns 2 results (as expected). However, with the inclusion of the previous I get all the results (currently 8) returned. It seems to be ignoring everything before AND order_status='Shipped' OR order_status='Not Shipped'. Any clues? Much thanks! Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sort by date
Good point. Tell me and I forget, show me and I remember, involve me and I understand Ignatius - Original Message - From: Snijders, Mark [EMAIL PROTECTED] To: 'Marco Tabini' [EMAIL PROTECTED]; Terry Romine [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 4:22 PM Subject: RE: [PHP-DB] sort by date why does everybody always gives the answers?? why not a hint, or where to search that they can learn something about it??? -Original Message- From: Marco Tabini [mailto:marcot;inicode.com] Sent: woensdag 6 november 2002 16:08 To: Terry Romine Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] sort by date Ok, going out on a limb here... have you tried something like select e.id, title, location, address, contact, category, event_time, urllink, descript, min(event_date) from eventTable e inner join dateTable d on e.id = d.id group by e.id ? Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmer Come visit us at http://www.phparch.com! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array() question
John is right. In fact one routinely calls two different $result(s) when coding nested loops: while( $details = mysql_fetch_array( $result ) ) { while ( $Email = mysql_fetch_array( $result2 ) ) .. } } when executing the next instance of your loop: while( $details = mysql_fetch_array( $result ) and $Email = mysql_fetch_array( $result2 ) ), each mysql_fetch_array will push both pointers (on your two result resources) by one position. if your result sets do not have the same number of rows, the shorter one will choke before the longer one is finished. therefore you will finish the loop not having called all results from the long resource. My 0.02 Belgian francs Ignatius - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: '1LT John W. Holmes' [EMAIL PROTECTED]; 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 7:24 PM Subject: RE: [PHP-DB] mysql_fetch_array() question :) see why I love mailing lists! :) It must have been their logic then, I respectfully retract everything I said, sorry Graeme! Why do I have to work, I could spend my days researching this stuff before I post! Thanks John! -- Josh -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Wednesday, November 06, 2002 1:21 PM To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query(select * from main limit 1) or die(mysql_error()); $r2 = mysql_query(select * from apft limit 1) or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo brhr; print_r($row2); ---John Holmes... - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB]
Re: [PHP-DB] Structure Question...
You have to create a table: CREATE TABLE product_categ ( FK_productID definition, FK_categID definition ) and list all relationships productID belongs to categID Ignatius - Original Message - From: Doug Coning [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, November 07, 2002 7:51 PM Subject: [PHP-DB] Structure Question... Hi everyone, I'd like to know how you would set up the following: I've set up a MySQL database with 600 products. I set it up where each product belongs to a category. However, now we want to take it further where different products can now belong to more than 1 category. How would you create this? 1. Would you duplicate the records for items that belong to more than 1 category and change the categories in those duplicated records? 2. Would you enter multiple categories into 1 column? 3. Would you create a different database that tracks categories and creat a many to many relationship? Thanks, Doug Coning -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Extracting column names from a db
A mix-up in your loop. Try: while ( $row = mysql_fetch_array( $result ) ) { echo $row['Field'] ; } (you may just as well use the field names provided by SHOW COLUMNS - more readable than numerical indexes) HTH Ignatius - Original Message - From: David Rice [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, November 10, 2002 4:18 PM Subject: [PHP-DB] Extracting column names from a db I need to write a script that will extract the names of the columns in my database eg. user_id, username can anyone help as to how to do this! I have tried ** *** mysql_select_db(filterseveuk) or die(mysql_error()); $query = SHOW COLUMNS FROM .$table. ; $result = mysql_query ( $query ) or die( mysql_error () ); $numrows = mysql_num_rows ($result); $row = mysql_fetch_array ($result); for($x=0; $x = $numrows; $x++){ echo $row[$x] ; } ** *** this doesn't work the way i want it to and gives me the output ** *** user_idint(11)PRIauto_increment Warning: Undefined offset: 6 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 7 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 8 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 9 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 10 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 11 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 12 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 13 in /home/filterseveuk/public_html/admin/index.php on line 30 Warning: Undefined offset: 14 in /home/filterseveuk/public_html/admin/index.php on line 30 _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php array max value pr. year
Hi Martin, I am sure that many would love to help you, but really you must explain your problem more clearly! Can you give more details? Ignatius - Original Message - From: Martin Allan Jensen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 11, 2002 10:24 AM Subject: [PHP-DB] php array max value pr. year Hi evryonei have a problem that i hope you can help me with. Here it goes! I have two arrays one called y adn one called v Togeather they hold a year(Y) and a value(V) The array looks like this: v: 10 20 40 60 320 780 890 920 y: 2002 2002 2002 2002 2002 2003 2003 2003 - V represents a climping value Y represents the year of the value So the values 10, 20, 40, 60, 320 etc. grows until a new year is reachet. And then it schould start again in the new year. So MAXIMUM ONE VALUE PER YEAR How can i make it return this out of the earlier menchent array : (Arrays) Y: 2002 2003 V: 320 920 So much thanks peoplei tried now for two days and i just can't come up with anything... P.S. Sorry for my bad english! Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] arrays db
Why don't you want to do this with SQL? Ignatius - Original Message - From: Martin Allan Jensen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 11, 2002 2:48 PM Subject: [PHP-DB] arrays db Okey people, i try again!! I have a table in a mysql database that holds this: +++++--+ | id | maaler | aflaest| vaerdi | pris | +++++--+ | 21 | 11 | 2002-01-01 | 15160 | 0.00 | | 22 | 11 | 2002-02-01 | 15180 | 0.00 | | 23 | 11 | 2002-03-01 | 15200 | 0.00 | | 24 | 11 | 2002-04-01 | 15240 | 0.00 | | 25 | 11 | 2002-05-01 | 15250 | 0.00 | | 27 | 10 | 2002-11-14 |210 | 0.00 | | 30 | 10 | 2002-12-19 |230 | 0.00 | +++++--+ Each maaler have it's own start registration witch is: ++--+---+ | id | nummer | start | ++--+---+ | 10 | 56456| 200 | | 11 | 02 | 15150 | ++--+---+ I then made a script that takes start for each maaler if it have any registrations. Then it does this: if its first field then it takes the vaerdi(THE VALUE) and - it with the start (THE STARTREGISTRATION) For the next fields it takes the vaerdi - the last vaerdi. My problem is that after the script has ran it have lets say 20 yeas 2002 (the registration year called aflaest in the table) and lets say two 2003. I only need ONE value vaerdi per year, witch is the one it just calculated in a loop. But it have all the values and years in the array. How do i only take ONE value per year in PHP NOT SQL?? I really hope this is discriping enough!! THANKS ALL! Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-WIN] update tablename
You can not do it directly. You have to create a new table as a copy of the old one: CREATE TABLE new_table SELECT * FROM old_table Your problem will be that the MySQL PHP user will probably not have the CREATE rights. Ignatius Rodrigo San Martin [EMAIL PROTECTED] wrote in message news:20021112113152.9310.qmail;pb1.pair.com... Hi. I want to change a tablename in my database. How do i do that? I want to do it from a webpage so i need to use php. -- Rodrigo San Martin Institutt for datateknologi og informatikk http://www.idi.ntnu.no/~rodrigo -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] array sorting
Just loop through the first index, then search on the second index: while ( list( $key, $value ) = each( $my_arr ) ) { // now $value is your ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130 [5] = 220 [6] = 320 ) array // sort your array by values sort( $value ) ; // get the last value $last_value = array_pop( $value ) ; // do something with this value... } But it seems to me there still misses a link between your two series of data (years, values) So try to get an array where keys are years, not numerical indexes? HTH Ignatius - Original Message - From: Martin Allan Jensen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 12, 2002 1:37 PM Subject: [PHP-DB] array sorting Hi everyone... I got a bit longer now.. But i have some trouble sorting my arrays I get this array returned. Array ( [0] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130 [5] = 220 [6] = 320 ) [1] = Array ( [0] = 10 [1] = 40 [2] = 50 [3] = 80 [4] = 130 [5] = 220 [6] = 320 [7] = 440 [8] = 570 ) [2] = ) I ain't good at it, but i guess this is a two dimesioned array... The question is now, i need to get the highest values of each sub array witch would be 320 570 in THIS CASE ?? Thanks so much!! Martin Allan Jensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] HTML Forms question...
Great piece of advice Mike. Thanks. Far from obvious. I was stuck with this problem since a few days. Will that also apply to n-dimensional array, like: document.form[system[]][0][1] ? Ignatius - Original Message - From: Ford, Mike [LSS] [EMAIL PROTECTED] To: 'Rich Gray' [EMAIL PROTECTED]; NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, November 19, 2002 7:35 PM Subject: RE: [PHP-DB] HTML Forms question... -Original Message- From: Rich Gray [mailto:[EMAIL PROTECTED]] Sent: 20 November 2002 01:13 If you name the checkbox as name=system[] then PHP will automatically create an array of the checkbox values which can be subsequently accessed via $_POST['system'][n] - be warned however that the '[]' can screw up any JavaScript code that refers to the checkbox object... G' -- not this old chestnut again! It only screws up your JavaScript if you don't write your JavaScript to allow for it. It's really very simple: *by* *definition* in JavaScript, the notation a.b is *identical* to a[b] Thus, if you have a single checkbox named with name=system, then you can access it in either of these ways: document.form.system document.form[system] By extension, if you have multiple checkboxes all named with name=system[], you can refer to them as: document.form[system[]][0] document.form[system[]][1] document.form[system[]][2] etc... I know this works because I've been using it for years (even before I started programming with PHP!). Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] $_get 2 variables
http://localhost/myscript.php?var1=blahvar2=blah2 Ignatius - Original Message - From: Gavin Amm [EMAIL PROTECTED] To: Php-Db (E-mail) [EMAIL PROTECTED] Sent: Wednesday, November 20, 2002 7:30 AM Subject: [PHP-DB] $_get 2 variables Hi, I'm wanting to retrieve data from my database using 2 conditions in the WHERE clause. How do i pick up 2 different variables from the URL? i can get just 1 variable easily (eg: http://localhost/myscript.php?var1=blah) My question essentially is: what string do do i need to type into the URL to pick up the 2 variables like this: $var1 = $_GET['var1']; $var2 = $_get['var2']; Do I need to start messing around with strings? or is there an easy way? Thanks, Gav This e-mail and any attachments are intended solely for the named addressee, are confidential and may contain legally privileged information. The copying or distribution of them or of any information they contain, by anyone other than the addressee, is prohibited. If you received this e-mail in error, please notify us immediately by return e-mail or telephone +61 2 9413 2944 and destroy the original message. Thank you. As Email is subject to viruses we advise that all Emails and any attachments should be scanned by an up to-date Anti Virus programme automatically by your system. It is the responsibility of the recipient to ensure that all Emails and any attachments are cleared of Viruses before opening. KSG can not accept any responsibility for viruses that maybe contained here in. Please advise KSG by return Email if you believe any Email sent by our system may contain a virus. It should be noted that most Anti Virus programmes can not scan encrypted file attachments (example - documents saved with a password). Thus extra care should be taken when opening these files. Liability limited by the Accountants Scheme, approved under the Professional Standards Act 1994 (NSW). Level 4 54 Neridah StreetPO Box 1290 CHATSWOOD NSW 2067 CHATSWOOD NSW 2057 Ph: +61 2 9413 2944 Fax: +61 2 9413 9901 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] standart variabels melfunction
Martin, what you are experiencing is the normal way to call form variables. There is no problem. You should use register_globals=Off whenever possible. better security. Ignatius - Original Message - From: Beau Lebens [EMAIL PROTECTED] To: 'Martin Allan Jensen' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 20, 2002 5:46 AM Subject: RE: [PHP-DB] standart variabels melfunction [php.ini] register_globals=On Beau // -Original Message- // From: Martin Allan Jensen [mailto:[EMAIL PROTECTED]] // Sent: Wednesday, 20 November 2002 12:41 PM // To: [EMAIL PROTECTED] // Subject: [PHP-DB] standart variabels melfunction // // // Hi all, // // I have a problem with my settings of Apache and PHP i think.. // // When i call for example ($PHP_SELF) instead of // ($_SERVER[PHP_SELF]) i get no output, just like when i call the url // www.servername.tld/test.php?mode=test // And i want to call the mode like this: // print($mode); // I just get a empty string. // But when i call: // print($_GET[mode]); // I get the real output... // // I tried to walk troug the hole php.ini the httpd.conf // file, but nothing came up, so i relly hope that you can help // me out here...! // // Sorry if it's a little off topic.. // // And THANKS A LOT!! // // Regards // Martin Allan Jensen // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: Selecting not on DB
You could create an auxiliary table nb_1_10 containing a field nb with all integers from 1 to 10 Then perform a SELECT join: SELECT nb_1_10.* FROM ABC, nb_1_10 WHERE nb_1_10.nb NOT IN ABC.number AND some condition that returns only one row from ABC - like here (1,4,6,10) Ignatius - Original Message - From: milisphp [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, November 21, 2002 5:29 AM Subject: [PHP-DB] FW: Selecting not on DB Hi there, I have a problem that I cannot seem to solve. I'm using MySql and query it using PHP. I have create table ABC with field called number containing (1,4,6,10) How is to select all number form 1 to 10 which are not in that field so the output somehow like this : ++ | Number | ++ | 2 | | 3 | | 5 | | 7 | | 8 | | 9 | ++ Thanks, Hansen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Undefined Constant
Well, is there an input field in your form whose name corresponds to .?= $row[price]; ? ? It is more likely that if you have a dynamic form your fields will be called by a ID identifier, like INPUT name=1012price is 12 EUR Where 12 is the price of grommet with ID 1012 in your DB So perhaps your javascript generator echoes the wrong field names... HTH Ignatius - Original Message - From: Tyler Whitesides [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 27, 2002 8:24 AM Subject: [PHP-DB] Undefined Constant Hi, Although I have been working with PHP for a while, working with Databases is something that I am only so so at. This code is supposed to grab the price from the database given the auto_increment id is inside of $casing. I am trying to get the $row[price] to echo so that Javascript recieves a string, converts it to an integer, and later on in the code, gives the user a total. Any ideas? Thanks, Tyler ? $grab = select * from parts where id = '$casing';; //This is line 17 $get = mysql_query($grab); $row = mysql_fetch_row($get); ? var casing = parseInt(form1.?= $row[price]; ?.value); ? $grab = select * from parts where id = '$processor';; $get = mysql_query($grab); $row = mysql_fetch_row($get); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help with date
If you use MySQL: SELECT DATE_ADD( $my_date, INTERVAL n DAY ) AS new_date ; Ignatius - Original Message - From: Dankshit [EMAIL PROTECTED] To: PHP [EMAIL PROTECTED]; PHP1 [EMAIL PROTECTED] Sent: Thursday, November 28, 2002 6:06 PM Subject: [PHP-DB] Help with date How can i add days to a date?? Equipe Pratic Sistemas Rodrigo Corrêa Fone: (14) 441-1700 [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql - enum
DESCRIBE tbl_name col_name Ignatius - Original Message - From: Bastian Vogt [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 02, 2002 1:41 PM Subject: [PHP-DB] mysql - enum Hi, is it possible to get all possible values of an enum-field from a mysql-table in php? The values might be changed in the database. Now I've got an select-field in my php-app where the user can select each value of the enum-field for a new record befor saving... Thanks for any reply, Bastian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] displaying duplicate records...
I do not understand your first question. Your query in effect shows duplicates. To prevent future duplicates, you can do it in two ways: 1. with MySQL: create a unique index on what should be unique, most likely the email (it looks like your business logic implies one entry per email) in fact you would not have this problem if you had defined email as PRIMARY KEY But you will have to remove the duplicates first - an unpleasant job. AFAIK, there is no easy way to do it with MySQL (or SQL in general). You have to do it procedurally by calling the entire table row by row. 2. Procedurally: validate user data before entry in the DB HTH Ignatius - Original Message - From: Marco Alting [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 04, 2002 11:47 AM Subject: [PHP-DB] displaying duplicate records... I have a database which allows people to upload info and foto's. There's a unique ID field, but some people tend to upload their info more than once (its a contest site). What I'm able to do is to see how may duplicates there are using the following statement: $query=SELECT COUNT(*) as cnt, voornaam,achternaam,leeftijd,ID,email FROM modellen GROUP BY email HAVING cnt 1; But this only gives me numbers. Does anyone know how to display every record that has multiple duplicate ? Or is there an elegant way to stop people from entering their info more than once? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] displaying duplicate records...
Well, seeing n rows or only one does not make you any happier, because you can not issue a DELETE statement that will delete only (n-1) entries. If your table is small enough, you may try to delete duplicates manually with a graphical interface such as Access or DBTools. But test first, as it may very well delete all n rows (in fact it SHOULD if it implements SQL properly...) Your PHP script should test first whether the proposed entry exists, with a query like: SELECT * FROM my_table WHERE unique_field = '{$_POST['unique_field']}' (As a rule, you must validate thoroughly ALL entries before inserting into your DB.) you can test over if ( mysql_num_rows( $result) ) if there is already an entry. In such case, redirect to your script with an appropriate error message. If you are reluctant to validate data, you can send the INSERT query and interpret an error as an attempt to create a duplicate (provided you had first created the appropriate UNIQUE index). Very dirty and not recommended. HTH Ignatius - Original Message - From: Marco Alting [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 04, 2002 12:57 PM Subject: Re: [PHP-DB] displaying duplicate records... What I ment was that when using the GROUP by, you will see one of the duplicates, and if you output the 'cnt' value you would see how many times it has a duplicate. But I want to see all duplicate records in a table, so I can add a delete button to the row. If I have the email address as a PRIMARY i would very much like to know how I would handle the input by the user when it is send to the database. I assume it will generate an error upon submission. How do I go about letting the user know they have entered an already existing address? Ignatius Reilly [EMAIL PROTECTED] wrote in message 030801c29b8b$8bd88ee0$015a@server">news:030801c29b8b$8bd88ee0$015a@server... I do not understand your first question. Your query in effect shows duplicates. To prevent future duplicates, you can do it in two ways: 1. with MySQL: create a unique index on what should be unique, most likely the email (it looks like your business logic implies one entry per email) in fact you would not have this problem if you had defined email as PRIMARY KEY But you will have to remove the duplicates first - an unpleasant job. AFAIK, there is no easy way to do it with MySQL (or SQL in general). You have to do it procedurally by calling the entire table row by row. 2. Procedurally: validate user data before entry in the DB HTH Ignatius - Original Message - From: Marco Alting [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 04, 2002 11:47 AM Subject: [PHP-DB] displaying duplicate records... I have a database which allows people to upload info and foto's. There's a unique ID field, but some people tend to upload their info more than once (its a contest site). What I'm able to do is to see how may duplicates there are using the following statement: $query=SELECT COUNT(*) as cnt, voornaam,achternaam,leeftijd,ID,email FROM modellen GROUP BY email HAVING cnt 1; But this only gives me numbers. Does anyone know how to display every record that has multiple duplicate ? Or is there an elegant way to stop people from entering their info more than once? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] I got this idea...
Well, we can only offer very general guidelines at this stage. What you can do is write a script that: - call all the URLs showing paintball prices (btw what is a paintball?) - extract the product name and price. this will require a specific REGEX for each URL called, and regular testing vs change of page design. the only difficult part is just this: writing and testing custom REGEXes. In fact, why not actually create a DB and run the script every night (or more often) as a scheduled task to update the DB? HTH Ignatius - Original Message - From: Mike Delorme [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 05, 2002 3:02 AM Subject: [PHP-DB] I got this idea... Hi! I am knew around here, and a newcomer to PHP, but I know enough. I have = this idea, and I have gone through all the ways that I know off to work = it, but they dont work. I am a paintball player and I get fustrated = because there are too many web sites out there that sell paintball = marker, and gear and things. I would like to take them all, let a client = search for a spacific thing, and have the search results come up with = the url to that product, and list them by price. Now, the not-so-easy = way would be to make a DB and put all the prices in and just list the by = price. Except that would be a very hard, time consuming work. And, I = would have to update the db often. I am sure there is an esyer way, but = I dont know what it is. Thanks for your help! Michael Delorme www.hybridfusion.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] calling function on submit instead of going to a new script
Simply append a parameter to the URL: action=same_page.php?selector=1 your script will take various actions based on a switch: switch $_POST['selector'] { case 1 : etc. Ignatius ___ - Original Message - From: Gavin Amm [EMAIL PROTECTED] To: Php-Db (E-mail) [EMAIL PROTECTED] Sent: Thursday, December 05, 2002 6:31 AM Subject: [PHP-DB] calling function on submit instead of going to a new script Hi, I'm using some form fields on a page to pick up existing data from a MySQL database, make any changes, and update the database when i hit submit. I've picked up the data ok, now i want to process the update... How do i call a function(?) on the same page rather than use another page through action=somescript.php? what i'd like to do (in seudo-code) is: form action=myfunction() ... input type=submit /form myfunction(){ process update send user back to homepage } cheers, Gav This e-mail and any attachments are intended solely for the named addressee, are confidential and may contain legally privileged information. The copying or distribution of them or of any information they contain, by anyone other than the addressee, is prohibited. If you received this e-mail in error, please notify us immediately by return e-mail or telephone +61 2 9413 2944 and destroy the original message. Thank you. As Email is subject to viruses we advise that all Emails and any attachments should be scanned by an up to-date Anti Virus programme automatically by your system. It is the responsibility of the recipient to ensure that all Emails and any attachments are cleared of Viruses before opening. KSG can not accept any responsibility for viruses that maybe contained here in. Please advise KSG by return Email if you believe any Email sent by our system may contain a virus. It should be noted that most Anti Virus programmes can not scan encrypted file attachments (example - documents saved with a password). Thus extra care should be taken when opening these files. Liability limited by the Accountants Scheme, approved under the Professional Standards Act 1994 (NSW). Level 4 54 Neridah StreetPO Box 1290 CHATSWOOD NSW 2067 CHATSWOOD NSW 2057 Ph: +61 2 9413 2944 Fax: +61 2 9413 9901 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Newline help...
If you're on a Window$ system, try \r\n instead of \n Ignatius - Original Message - From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 05, 2002 5:28 PM Subject: [PHP-DB] Newline help... I must be stupid, because I cannot for the life of me figure out why I am not getting newlines from some very simply 'echo' statements. Here is the portion of the code below, and I am getting everything run together on a single line: ?php do { echo $list['id-sys'] . \n; $sys = split('-', $list['id-sys']); echo $sys[1]\n; } while ($list = mysql_fetch_assoc($result)); I am truly stumped by this. It is quite frustrating that something as simple as a newline can misbehave. I have been searching for this on the PHP site, newsgroups, and in a couple of books I have and yet I am still stumped. Help please. Thanks. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] test
Test successful. Congratulations. Ignatius You can't trust the Russians. They have no word for 'détente'. - Original Message - From: Art Chevalier [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 05, 2002 8:38 PM Subject: [PHP-DB] test test -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Function questions...
I would replace $query = SELECT * FROM accounts WHERE verifyurl='$safe_verify_string'; by $query = SELECT * FROM accounts WHERE verifyurl='{$safe_verify_string}'; to force interpolation of variable $safe_verify_string HTH Ignatius - Original Message - From: NIPP, SCOTT V (SBCSI) [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 06, 2002 6:04 PM Subject: [PHP-DB] Function questions... I am trying to convert something that I have working in a PHP script to be a function in a library type of file. The code contained in the function works fine in another script, but I am currently getting no output from the function. I have a question about the nature of functions that may help clear up my problems. Do 'echo' commands within functions actually work to directly display information? I have only used functions up to this point that use the 'return' command to pass a variable back to the script that called the function. I am pretty confused on how to actually use a function that formats data to be displayed. This is my primary source of confusion. Below is the function that is giving me trouble: function CheckboxList($query) { $result1 = mysql_query($query); do { $sys = split('-', $list['id-sys']); if ($cnt == 1) { $cnt = 2; echo trtd width=\161\input name=\system[]\ type=\checkbox\ value=\$sys\; echo $sys./td; } elseif ($cnt == 2) { $cnt = 3; echo trtd width=\161\input name=\system[]\ type=\checkbox\ value=\$sys\; echo $sys./td; } elseif ($cnt == 3) { $cnt = 4; echo trtd width=\161\input name=\system[]\ type=\checkbox\ value=\$sys\; echo $sys./td; } elseif ($cnt == 4) { $cnt = 1; echo trtd width=\161\input name=\system[]\ type=\checkbox\ value=\$sys\; echo $sys./td/tr; } } while ($list = mysql_fetch_assoc($result1)); } Here is also the way I am calling this function: snip... $query = SELECT * FROM accounts WHERE verifyurl='$safe_verify_string'; snip... CheckboxList($query); snip... Is there something wrong with the way in which I am calling this function? Thanks in advance for all the help. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Array
Try: $query = INSERT INTO anagrafe (codice,nome, cognome, codicefiscale) VALUES (' .strtoupper($codicefiscale) .','{$NOME}',' .strtoupper($cognome) .',' .strtoupper($co dicefiscale) .', etc then mysql_query ( $query ) ; Ignatius - Original Message - From: Antonio Bernabei [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 06, 2002 7:12 PM Subject: Re: [PHP-DB] MySQL Array Hi, I want to insert the upper case of the strings written in the forn, so I put on the php file called these lines $NOME=strtoupper($nome); mysql_query (INSERT INTO anagrafe (codice,nome, cognome, codicefiscale) VALUES ('strtoupper($codicefiscale)','$NOME','strtoupper($cognome)','strtoupper($co dicefiscale)', ... but if $codice if for example abc in field codice I don't get ABC but uppercase(abc) while if $nome is mario in the filed nome I get MARIO Can I avoid to write extra lines for the conversion? Thanks Antonio -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CREATE TABLE QUERY PHP/MySQL
Very likely you have to GRANT the CREATE permission to your PHP user account. Also investigate the CREATE TEMPORARY TABLE grant status available since version 4+. Very convenient. Ignatius - Original Message - From: Jonathan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 06, 2002 10:00 PM Subject: [PHP-DB] CREATE TABLE QUERY PHP/MySQL This is the first time I am trying to create a table in MySQL based on user input. Here is the scenario, The user will enter in the name of a stage, e.g. Harley Davidson. I then look for the first space (to indicate the first word), make it into lower case and then do the following: $new_stage_name = stage_.$var; This will give $new_stage_name the value of stage_harley. That works fine. Now I want to run the following query: $SQL = CREATE TABLE .$new_stage_name. (set values and their properties); If I run this query using PHPMyAdmin, minus the var of course, the table is created. When I run it in my code, nothing happens. I do a die($SQL) to see the final outcome of the query and it's correct and is what I am using to run the query in PHPMyAdmin. This is what my code is doing: I have class RecordSet which makes the db connection and its constructor takes the $SQL as an arg. So, $SQL = what is listed above; $objRecordSet = new RecordSet($SQL); //I used this all the time with all kinds of other Select, Insert, Update, and Delete queries and it works perfect. For one, I don't know how to test whether the table has been created or not. I know I could probably do some sort of mysql_list_tables and look for it or whatever but I was looking for something similar to If (mysql_affected_rows() == -1) Because that is very easy. And ideas as to why the table is not being created. === Jonathan Villa Application Developer IS Design Development www.isdesigndev.com 414.429.0327 === -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CREATE TABLE QUERY PHP/MySQL
answers inline Ignatius - Original Message - From: Jonathan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 06, 2002 10:39 PM Subject: RE: [PHP-DB] CREATE TABLE QUERY PHP/MySQL Granting access makes sense. Now what is the difference between the user information I put into the mysql_connect function and PHP user? one and same thing. If there is a difference , how would I grant the access via a query and how would it affect the new users who will use the application when it is given to my client? Also, a preview reply mentioned mysql_error(). How would I use function to verify that the table was created? Do I simply write If (mysql_error() != ) Return false A typical way to use it is mysql_***( *** ) or die( mysql_error() ) ; -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED]] Sent: Friday, December 06, 2002 3:34 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] CREATE TABLE QUERY PHP/MySQL Very likely you have to GRANT the CREATE permission to your PHP user account. Also investigate the CREATE TEMPORARY TABLE grant status available since version 4+. Very convenient. Ignatius - Original Message - From: Jonathan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, December 06, 2002 10:00 PM Subject: [PHP-DB] CREATE TABLE QUERY PHP/MySQL This is the first time I am trying to create a table in MySQL based on user input. Here is the scenario, The user will enter in the name of a stage, e.g. Harley Davidson. I then look for the first space (to indicate the first word), make it into lower case and then do the following: $new_stage_name = stage_.$var; This will give $new_stage_name the value of stage_harley. That works fine. Now I want to run the following query: $SQL = CREATE TABLE .$new_stage_name. (set values and their properties); If I run this query using PHPMyAdmin, minus the var of course, the table is created. When I run it in my code, nothing happens. I do a die($SQL) to see the final outcome of the query and it's correct and is what I am using to run the query in PHPMyAdmin. This is what my code is doing: I have class RecordSet which makes the db connection and its constructor takes the $SQL as an arg. So, $SQL = what is listed above; $objRecordSet = new RecordSet($SQL); //I used this all the time with all kinds of other Select, Insert, Update, and Delete queries and it works perfect. For one, I don't know how to test whether the table has been created or not. I know I could probably do some sort of mysql_list_tables and look for it or whatever but I was looking for something similar to If (mysql_affected_rows() == -1) Because that is very easy. And ideas as to why the table is not being created. === Jonathan Villa Application Developer IS Design Development www.isdesigndev.com 414.429.0327 === -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Form TextArea Formatting
What do you mean by formatted text? All you can enter in a textarea is a sequence of characters belonging to your encoding schema (including non-printing characters). Ignatius - Original Message - From: Keith Spiller [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 09, 2002 12:01 PM Subject: [PHP-DB] Form TextArea Formatting Hello, I've created a web form that includes a textarea input box called MessageText. The data from this form will be inserted into a mysql table. My problem is that the form users will be inserting formatted text into this textarea and I need to be able to transfer the formatting as well as the content into the database. Right now, all formatting is lost in the transfer. Any ideas or suggestions? Thank you for your help. Larentium [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Query Help...
Try: SELECT DISTINCT F.question, F.answer FROM Faqs AS F, FaqsRelatedToProducts Table AS FP WHERE F.faqid = FP.faqid DTH? Ignatius - Original Message - From: Michael Knauf/Niles [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 10, 2002 8:53 PM Subject: [PHP-DB] Select Query Help... select query question OK, I have 3 tables Products Table prodid fgnumber name description Faqs Table faqid question answer FaqsRelatedToProducts Table fpid fgnumber faqid I want to select all the faq question and answer pairs that relate to an fgnumber so I need to use both the Faqs table and the FaqsRelatedToProducts table, how do I make that work? Michael -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Catalog
lots of excellent resources on www.devshed.com, notably a PHPShop tutorial and a catalogue implementation. Ignatius - Original Message - From: Hynek Semecký ME [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 11, 2002 11:54 AM Subject: [PHP-DB] Catalog Hi list, I am trying to develop a product catalog using MySQL and PhP. A long time I was looking for some tips for the database structure. The idea is to have a powerfull and as much as possible universal DB application. Does anyone have an idea of a book, e-book, site, resource please ? Thanks Hynek -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] flytte bsd harddisk til anden pc
なるほど. 私も,そう言う問題に会った. Ignatius - Original Message - From: Martin Allan Jensen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, December 12, 2002 2:26 PM Subject: [PHP-DB] flytte bsd harddisk til anden pc Hej Allesammen, har et strt problem, jeg skal IDAG skifte server, men kan jeg bare tage mine harddiske med FreeBSD på og smide over i den nye maskine og så vil det køre eller -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Selecting more than asked for
$SQL = SELECT * FROM resources where unit_id='{$unit_id}' order by level ; Ignatius - Original Message - From: Alex Francis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, December 14, 2002 8:37 PM Subject: [PHP-DB] Selecting more than asked for When using the statement below, as well as getting the data corresponding to $unit_id, I also get any data where unit_id field is blank. I have tried various permutations of unit_id IS NOT NULL, but get syntax errors. Can someone help to get the syntax correct. $SQL = SELECT * FROM resources where unit_id='$unit_id' order by level ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Get error message, need help
You should write: $myquery = SELECT * FROM user WHERE username = '{$user}' ... ; As a bonus, it is much more readable. Ignatius - Original Message - From: David [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 16, 2002 2:16 AM Subject: [PHP-DB] Get error message, need help Hello all, I am new to PHP so I am going to need some help. I am trying to create a admin login page. But I am getting this error message: Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\sunwestsilver\admin\tmpi5pcf76sy9.php on line 43 tmpi5pcf76sy9.php is generated by Dreamweaver MX as a temp file from admin.php It is coming from this line: this is line 43 code # $myquery = .' AND password = ' . crypt($password, xpz8ty) . '; The complete code is: // Query Database with username and encrypted password #$myquery = SELECT * FROM user WHERE username = ' . $user #$myquery = .' AND password = ' . crypt($password, xpz8ty) . '; #$result = mysql_query($myquery); #if (!$result) #{ # $error = Cannot run Query; #return($error); #} Any help will be nice. I got this code from Dreamweaver MX: PHP Web Development pg. 257 Thanks David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] trees in MySQL
The difficulty you are being confronting could be alleviated by using an XML data model (meaning non relational). Of course, I don't know about your requirements, but it could be a direction worth investigating. I use the php_xslt.dll (sablotron) extension, which I find works quite pleasantly. Ignatius - Original Message - From: José Moreira [EMAIL PROTECTED] To: Php-Db (Correio electrónico) [EMAIL PROTECTED] Sent: Thursday, December 19, 2002 11:45 AM Subject: [PHP-DB] trees in MySQL hello im implementing a portal and im choosing between the 'Nested Set' and 'Adjacency Lists tree' models. http://users.starpower.net/rjhalljr/Serve/MySQL/traer.html im perfectly aware of the 'Adjacency Lists tree' model how-to and I am studying the 'Nested Set', example follows : CREATE TABLE LanguageTree ( Language VARCHAR(255) PRIMARY KEY , Parent VARCHAR(255) , Lft LONG , Rgt LONG , INDEX idxLft (Lft) , INDEX idxRgt (Rgt) ) Comment = Related languages; A[1 12] / \ / \ B[2 3] C[4 11] / \ /\ D[5 8] F[9 10] | E[6 7] my doubt is that if i want to insert a new node, for example 'G' under 'A' A[1 12] / | \ / \ B[2 3]G[] C[4 11] / \ / \ D[5 8] F[9 10] | E[6 7] i have? to update almost every left,righ fields after that node, resulting in a website performance downgrade help? even if thjats the only way, how can i do it? perhaps im getting it wrong ... best regards José Moreira TEGOPI S.A. http://www.tegopi.pt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Set Logout Time for No Activity
Another possibility is after each page call to rewrite the client's cookie's validity to, say, current time + 1800s: session_start() ; setcookie( session_name(), session_id(), time()+1800, / ) ; ob_start() ; // etc. If the user does not call a page for more than 30', the cookie will be destroyed, in effect destroying the session. Ignatius - Original Message - From: John W. Holmes To: 'Allens' ; [EMAIL PROTECTED] Sent: Friday, December 20, 2002 1:57 PM Subject: RE: [PHP-DB] Set Logout Time for No Activity Is there a variable in php.ini that will allow you to log someone out if there is no activity of 30 minutes or greater from the logged in user? Thanks in advance. :) No, not really. You can use sessions, for something like this, though. You start a session and look for a variable within it before you proceed with the page. If the user is inactive for a while, the session will be cleaned up and not exist when you go to check it, so you make them log in again. You can control the session garbage collection time in php.ini. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] form validation
Hi Mignon, it is really quite simple: you can pack several screens (each containing for instance a form) in a same script. each form contains a hidden field, say selector now, the script begins by a switch: if ( isset( $_POST['submit'] ) ) { switch ( $selector ) { // Switch 1: process the screen 1 // - case 1 : // process form 1 : data validation, ... form name=form2 action=samepage.php input type=hidden selector=2 / // ... // break ; // Switch 2: process the screen 2 // - case 2 : // etc. } else { // show the blank form } Javascript validation is not even a last resort. Use it only for usability purposes, but validate everything server-side. HTH Ignatius - Original Message - From: Mignon Hunter To: [EMAIL PROTECTED] Sent: Friday, December 20, 2002 3:25 PM Subject: [PHP-DB] form validation Hello list, I am developing a db form that gets passed to another form. I need to validate the fields in form(1), before passing on. The form action posts to form(2), so that upon hitting submit - form(2) shows up in browser...(the only way I know how to do this). I am trying to use php to validate. I have been googling and checking books and archives for 2 days and all examples use the same file to post to. In other words, form1.php uses form action=form1.php. But I need it to be form(2), but I still need to validate. Does anyone have any ideas, or does everyone just use javascript with say...alert boxes. This will be my last resort. Thanks Mignon Here's the code for form1.php !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN html head title/title /head body form action=form2.php method=post ? function check_form($comp_name, $city, $state, $contact) { if (!$comp_name || !$city || !$state || !$contact): print (Please fill in all Fields); if (!$comp_name) { print (Please fill in your company name); } if (!$city) { print (Please fill in your city); } if (!$contact) { print (Please fill in your contact name); } endif; } ? table align=center cellpadding=5 tr th colspan=2Please Enter the Information Below and Press the 'Submit' brButton When Finished.br(All Fields Required)/th trtdnbsp;/td/tr /tr tr tdb Company Name: /b/td td input type=text name=comp_name size=50 /td /tr tr td bCity:/b/td td input type=text name=city size=50 /td /tr tr td bContact Name: /b/td td input type=text name=contact size=50 /td /tr /table center input name=submit value=Submit type=submit /center ? //This works with form action form1.php //if (isset ($submit)) { //check_form($comp_name, $city, $state, $contact); //} //echo $comp_name, $city, $state, $contact; ? /form /table /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help with date....
You can do it very nicely with MySQL: $query = SELECT WEEKDAY( '{$mydate}' ) ; Provided your date is correctly formatted ( -mm-dd ) Ignatius - Original Message - From: Rodrigo Corrêa [EMAIL PROTECTED] To: PHP1 [EMAIL PROTECTED] Sent: Tuesday, January 07, 2003 3:57 PM Subject: [PHP-DB] Help with date How can i find out the day of the week in one date?? like = 07/01/2002 the day of the week is 3 thurday like = 18/01/2002 the day of the week is 6 saturday is there a way to do that? Equipe Pratic Sistemas Rodrigo Corrêa Fone: (14) 441-1700 [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate function to do this (it will simply give you the number of rows inside a group). Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 10:44 AM Subject: [PHP-DB] LEFT JOIN not working I have a page with many ads that stores both the number of times an ad is displayed and how many times it gets clicked. These are stored in two different tables (since different information is stored for each) but both have identical name columns. I am trying to display both # times displayed and # times clicked in the same table in an admin page. Here is my query: SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name I want to display for each ad the number of times displayed, and then number of times clicked if applicable, if not 0. The query is only returning rows for ads that have been clicked on. Is the problem because I have a COUNT column for one table, with a group by? Is this causing the display to be grouped also? If you need more information how the table is set up let me know, I'm really stumped here. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition to the three rows of ads that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, and 24 displays. That plus the other three account for all the displayed ads. However, since it is returning a null value for any ad name that has not been clicked on, and then it's grouped by ad name, it lumps all non-clicked ads into one row. What I need is to see each ad on a separate row, which is what I thought a LEFT JOIN was supposed to do. Any suggestions? Thanks, -Lisi At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote: problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate function to do this (it will simply give you the number of rows inside a group). Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 10:44 AM Subject: [PHP-DB] LEFT JOIN not working I have a page with many ads that stores both the number of times an ad is displayed and how many times it gets clicked. These are stored in two different tables (since different information is stored for each) but both have identical name columns. I am trying to display both # times displayed and # times clicked in the same table in an admin page. Here is my query: SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name I want to display for each ad the number of times displayed, and then number of times clicked if applicable, if not 0. The query is only returning rows for ads that have been clicked on. Is the problem because I have a COUNT column for one table, with a group by? Is this causing the display to be grouped also? If you need more information how the table is set up let me know, I'm really stumped here. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
Oops! Sorry, I missed it the first time. Your query should start as: SELECT ads_displayrate.name instead of SELECT ads_clickrate.name then you will always have a non-NULL name (coming from the table on the left of the LEFT JOIN). HTH Ignatius, from Brussels Where the fuck is Belgium? D. Ivester, CEO, Coca Cola - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 1:11 PM Subject: Re: [PHP-DB] LEFT JOIN not working Exactly my question - why does it not have a name? How would I modify my query to get a row with a name but null value for date? I thought the join would take care of this, but I'm obviously not doing it right. You mention a unique identifier, there is a separate table with a row for each ad, containing name, URL, and a unique ID number (autoincrement). Should this table be included somehow in the query? How would this help? Thanks, -Lisi At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote: Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition to the three rows of ads that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, and 24 displays. That plus the other three account for all the displayed ads. However, since it is returning a null value for any ad name that has not been clicked on, and then it's grouped by ad name, it lumps all non-clicked ads into one row. What I need is to see each ad on a separate row, which is what I thought a LEFT JOIN was supposed to do. Any suggestions? Thanks, -Lisi At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote: problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate function to do this (it will simply give you the number of rows inside a group). Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 10:44 AM Subject: [PHP-DB] LEFT JOIN not working I have a page with many ads that stores both the number of times an ad is displayed and how many times it gets clicked. These are stored in two different tables (since different information is stored for each) but both have identical name columns. I am trying to display both # times displayed and # times clicked in the same table in an admin page. Here is my query: SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name I want to display for each ad the number of times displayed, and then number of times clicked if applicable, if not 0. The query is only returning rows for ads that have been clicked on. Is the problem because I have a COUNT column for one table, with a group by? Is this causing the display to be grouped also? If you need more information how the table is set up let me know, I'm really stumped here. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] two inserts at once?
If you are using MySQL, you can't. (none of my business, but why not simplifying your table names: faqProduct instead of faqRelatedToProduct ?) Ignatius - Original Message - From: Michael Knauf/Niles [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 6:04 PM Subject: [PHP-DB] two inserts at once? This Code Snippet works: $newfaq_query = INSERT INTO `faq` (`faqid`, `question`, `answer`) VALUES ('', '$question', '$answer'); $newfeaturesResult = mysql_query($newfeatures_query); But I'd like to combine that query with this one: INSERT INTO `faqRelatedToProduct` (`id`, `fgNumber`, `faqId`) VALUES ('', '$fgNumber', '$faqid'); So that both are executed at the same time. The variables $question, $answer, $fgNumber come from a form, the faqid is a auto increment field, as is id... but it seems I need to know the value of faqid to relate it correctly to the fgNumber... Is there a way to combine the two queries? Michael -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
Oops! I missed again. If you specify conditions pertaining to the right-hand table, such as: ads_clickrate.date = '2001', Then you will lose all result rows for which the right-hand data is NULL. Not the expected result. So your restricting WHERE clauses must apply to the left-hand table only. Therefore: WHERE YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' (if your table ads_displayrate has such date fields). HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 6:54 PM Subject: Re: [PHP-DB] LEFT JOIN not working Cool! It's mostly working now, the only problem is it's ignoring the other clauses in the ON clause that select the desired date. Perhaps it's not supposed to be connected this way? How would I select specific dates? Thanks again, -Lisi At 01:20 PM 1/9/03 +0100, you wrote: Oops! Sorry, I missed it the first time. Your query should start as: SELECT ads_displayrate.name instead of SELECT ads_clickrate.name then you will always have a non-NULL name (coming from the table on the left of the LEFT JOIN). HTH Ignatius, from Brussels Where the fuck is Belgium? D. Ivester, CEO, Coca Cola - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 1:11 PM Subject: Re: [PHP-DB] LEFT JOIN not working Exactly my question - why does it not have a name? How would I modify my query to get a row with a name but null value for date? I thought the join would take care of this, but I'm obviously not doing it right. You mention a unique identifier, there is a separate table with a row for each ad, containing name, URL, and a unique ID number (autoincrement). Should this table be included somehow in the query? How would this help? Thanks, -Lisi At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote: Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition to the three rows of ads that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, and 24 displays. That plus the other three account for all the displayed ads. However, since it is returning a null value for any ad name that has not been clicked on, and then it's grouped by ad name, it lumps all non-clicked ads into one row. What I need is to see each ad on a separate row, which is what I thought a LEFT JOIN was supposed to do. Any suggestions? Thanks, -Lisi At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote: problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate function to do this (it will simply give you the number of rows inside a group). Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 10:44 AM Subject: [PHP-DB] LEFT JOIN not working I have a page with many ads that stores both the number of times an ad is displayed and how many times it gets clicked. These are stored in two different tables (since different information is stored for each) but both have identical name columns. I am trying to display both # times displayed and # times clicked in the same table in an admin page. Here is my query: SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name
Re: [PHP-DB] LEFT JOIN not working
Should work (provided that the HAVING clauses be written after the GROUP BY) But less efficient. The point of using the WHERE clauses is to restrict during the JOIN. What you propose amounts to joining the full left table, which may be very expensive, especially in the case of web log data. Ignatius - Original Message - From: Henrik Hornemann [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Cc: PHP-DB [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 10:56 AM Subject: SV: [PHP-DB] LEFT JOIN not working Hi, You might want to try something like: SELECT ads_displayrate.name, SUM(ads_displayrate.count) as display, SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name HAVING YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' AND DAYOFMONTH(ads_displayrate.date) = '05' GROUP BY ads_displayrate.name ORDER BY ads_displayrate.name regards Henrik Hornemann -Oprindelig meddelelse- Fra: Lisi [mailto:[EMAIL PROTECTED]] Sendt: 14. januar 2003 18:47 Til: Ignatius Reilly Cc: PHP-DB Emne: Re: [PHP-DB] LEFT JOIN not working Still not working. I made the change, and I'm still getting all results. I even tried it without the leading '0' in front of the 1, no good. Here's my current query, with suggested changes: SELECT ads_displayrate.name, SUM(ads_displayrate.count) as display, SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name AND YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' AND DAYOFMONTH(ads_displayrate.date) = '05' GROUP BY ads_displayrate.name ORDER BY ads_displayrate.name ads_displayrate.date is a column of date type, so as far as I understand this should work. Is there some typo I'm missing? At 07:15 PM 1/9/03 +0100, you wrote: Oops! I missed again. If you specify conditions pertaining to the right-hand table, such as: ads_clickrate.date = '2001', Then you will lose all result rows for which the right-hand data is NULL. Not the expected result. So your restricting WHERE clauses must apply to the left-hand table only. Therefore: WHERE YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' (if your table ads_displayrate has such date fields). HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 6:54 PM Subject: Re: [PHP-DB] LEFT JOIN not working Cool! It's mostly working now, the only problem is it's ignoring the other clauses in the ON clause that select the desired date. Perhaps it's not supposed to be connected this way? How would I select specific dates? Thanks again, -Lisi At 01:20 PM 1/9/03 +0100, you wrote: Oops! Sorry, I missed it the first time. Your query should start as: SELECT ads_displayrate.name instead of SELECT ads_clickrate.name then you will always have a non-NULL name (coming from the table on the left of the LEFT JOIN). HTH Ignatius, from Brussels Where the fuck is Belgium? D. Ivester, CEO, Coca Cola - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 1:11 PM Subject: Re: [PHP-DB] LEFT JOIN not working Exactly my question - why does it not have a name? How would I modify my query to get a row with a name but null value for date? I thought the join would take care of this, but I'm obviously not doing it right. You mention a unique identifier, there is a separate table with a row for each ad, containing name, URL, and a unique ID number (autoincrement). Should this table be included somehow in the query? How would this help? Thanks, -Lisi At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote: Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition
Re: [PHP-DB] making my own week? :)
The simplest seems to store the date normally in the DB. When you need your special Cinema date, just do a modulo 7: myDayOfWeek = ( WEEKDAY( '2003-01-17' ) + 3 ) % 7 HTH Ignatius - Original Message - From: Matthew Nock [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 11:45 AM Subject: [PHP-DB] making my own week? :) Hi All, I am currently building a website for a cinema - and a cinema week runs from Thursday, to Wednesday. I need some help with how to get PHP to work with one week periods, but having the week starting on a Thursday, instead of Sunday, or Monday. The week will be used to generate dynamic list boxes, and database queries... Anyone done anything like this before that may be able to shed a little light? If anyone is experienced with this sort of date manipulation let me know what info you need and I will provide it where possible. Cheers, Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mail() and replies
Quite doable. Check the IMAP functions. Ignatius - Original Message - From: Baumgartner Jeffrey [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, January 15, 2003 5:19 PM Subject: [PHP-DB] Mail() and replies Is there any way to receive mail via PHP? What I am interested in doing is creating a double opt-in e-mail list whereby someone can subscribe to an e-mail service via an on-line form. Upon doing so, they would get a confirmation e-mail. Replying to this e-mail would confirm the subscription and add the sender's e-mail address to the database (MySQL). Doable? Thanks, Jeffrey Baumgartner eBusiness Consultant - ITP Europe http://www.itp-europe.com [EMAIL PROTECTED] +32 2 721 51 00 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] need help spotting this php parse error
Dunno. I also remember once having a parse error, but it was on line 35. Cheers Ignatius - Original Message - From: David Rice [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 23, 2003 8:53 PM Subject: [PHP-DB] need help spotting this php parse error When i run this script it tells me that I have a parse error on line 34? I really can't see it anyhelp (please!) would be much appreciated Cheers, Dave ? session_start(); if(!$HTTP_COOKIE_VARS[username]) { /* The Cookie is not set, so load the page as if it is the first time */ include(library/include/header.php); include(library/include/database.php); /* Include a header file and a database connections/functions file */ ? form name=login method=post action= select name=select ? $query = SELECT * FROM Staff WHERE ResterauntId = 1; $result = mysql_query($query) or die( mysql_error () ); While( $row = mysql_fetch_array($result) ) { ? option value=? echo $row[0]; ?? echo $row[1]; echo $row[2]; ?/option ? } ? /select /form _ Stay in touch with MSN Messenger http://messenger.msn.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL Query Question
It is safe to test if the divisor is zero: replace columnB/columnC by IF( columnC = 0, 0, columnB/columnC ) (the 0 could be anything else; this depends on your business logic) Ignatius - Original Message - From: Jeremy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, January 23, 2003 10:29 PM Subject: [PHP-DB] MySQL Query Question Hello, I need some help from you MySQL gurus out there. This is pure SQL by the way..no front-end. Lets say you have a table that has 2columns.columnA, ColumnB and columnC I have something like this if (columnA'7', (columnB/columnC) + 52, columnB/ColumnC) as Number however i need to test if columnc is 0 also cause if i need divide by zero i get a null value I cant figure out how to do this any help would be greatly appreciated -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Import and export data from php/mysql
What is your problem exactly? Have you investigated the MySQL manual under: LOAD DATA INFILE SELECT ... INTO OUTFILE ? Ignatius - Original Message - From: Bruno Pereira [EMAIL PROTECTED] To: PHP-db list [EMAIL PROTECTED] Sent: Friday, January 24, 2003 1:51 PM Subject: [PHP-DB] Import and export data from php/mysql I would like to know, if there is any change to export/import data from MySQL/EXCEL/MySQL with php??? It's very important. So if someone knows a way please help me. Thanks. Cumprimentos Bruno Pereira [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] update
If you want to use WHERE clause, see the INSERT table SELECT ... syntax. Extremely convenient. You inherit all the flexibility of the SELECT statement. Ignatius - Original Message - From: Doug Thompson [EMAIL PROTECTED] To: Ike Austin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, February 04, 2003 2:17 PM Subject: Re: [PHP-DB] update UPDATE is for changing values in existing rows. It appears you want to add new information. Use INSERT. $query= INSERT tablename SET (username, email, location) VALUES( $username, $email, $location); Note that a WHERE condition is incorrect for INSERT. Your UPDATE syntax is not correct either. Note that you need only one query to update any or all of the columns in a row. Using your example: $query=UPDATE tablename SET username=$username, email=$email, location=$location WHERE userID=$id; Finally, your Flash of Success is not useful because it will print even when the query fails. Doug On Thu, 30 Jan 2003 13:34:41 -0500, Ike Austin wrote: Hello, Newbie question. And can the same SQL portion of the code be written something like... query= UPDATE taablename SET (username, email, location) VALUEs( $username, $email, $location); Any reason why this Update command would not execute? // BUILD AND EXECUTE QUERY TO SAVE USER INFO INTO DATABASE TABLE query = UPDATE forumUsers SET username = '$name' WHERE userID = '$id'; result = @mysql_query($query); query2 = UPDATE forumUsers SET email = '$emai' WHERE userID = '$id'; result2 = @mysql_query($query2); query3 = UPDATE forumUsers SET Location = '$loc' WHERE userID = '$id'; result3 = @mysql_query($query3); / INFORM FLASH OF SUCCESS print /:result=Updated Thanks; // CLOSE LINK TO DATABASE SERVER ysql_close($link); ? Ike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] first 10 or so words
Or rather SUBSTRING_INDEX(str,delim,count) Because you want to use a custom delimiter (space, comma) Ignatius - Original Message - From: Peter Lovatt [EMAIL PROTECTED] To: Bruce Levick [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, February 13, 2003 11:40 PM Subject: RE: [PHP-DB] first 10 or so words try SUBSTRING http://www.mysql.com/doc/en/String_functions.html Peter -Original Message- From: Bruce Levick [mailto:[EMAIL PROTECTED]] Sent: 13 February 2003 22:23 To: [EMAIL PROTECTED] Subject: [PHP-DB] first 10 or so words Howdy, I have a SELECT query displaying the results in repeated rows in a table. I have a COMMENTS column coming out of the database table which will likely contain a paragraph of information. I would like to display only the first 10 or so words and then have a more link that people can click on to display all the info. Is there a simple method for this?? Cheers -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] printing repeat table headers
It is not easy to design a SQL query that will repeat headers every 33 rows. So this should be done in the PHP code. Why not use a counter, that you increment at every mysql_fetch_array() and test if !( $counter % 33 ) Side remarks: you could also define a CSS class for TH and use TH as headers. Thus you avoid having those unpleasant bgcolor='#ff'. Or use a different TD class for that matter. Also I suppose that the count( $results ) is intended to be used to define the width attribute, but it does not seem to appear in your HTML. HTH Ignatius - Original Message - From: Sam Folk-Williams [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 15, 2003 6:26 PM Subject: [PHP-DB] printing repeat table headers Hi, I'm printing the results of a DB query that gets a 300 row staff directory. All 300 rows appear on one page. The top of the HTML table has basic headers like First Name, Last Name, Email etc, then all 300 rows print underneath the headers. What I would like to do is have those headers repeat every 33 rows, so that as the user scrolls down that can still see the table headers every so often. I feel like this should be easy, but it's giving me a hard time. Any suggestions? My code is below. Thanks, Sam $tableHeaders = tr td class='printRev'bStaff Name/b/td td class='printRev'bOffice Location/b/td td class='printRev'bPrimary Telephone/b/td td class='printRev'bExt/b/td td class='printRev'bEmail/b/td td class='printRev'bDirect Telephone/b/td td class='printRev'bCell/Pager/b/td /tr ; echo table width='850' border='1' cellpadding='1' cellspacing='0' bordercolor='#00'; echo $tableHeaders; while ($row = mysql_fetch_array($result)) { $count = count($result); $staff_id = $row['staff_id']; $staff_fname = $row['staff_fname']; $office_name = $row['office_name']; $staff_lname = $row['staff_lname']; $staff_phone = $row['staff_phone']; $staff_phone2 = $row['staff_phone2']; $staff_email = $row['staff_email']; $office_phone = $row['office_phone']; $ext = $row['ext']; //strip slashes from textfields $staff_fname = stripslashes($staff_fname); $staff_lname = stripslashes($staff_lname); $office_name = stripslashes($office_name); $tableContent = tr td class='print' bgcolor='#ff'$staff_lname, $staff_fname/td td class='print' bgcolor='#ff'$office_namenbsp;/td td class='print' bgcolor='#ff'$office_phonenbsp;/td td class='print' bgcolor='#ff'$extnbsp;/td td class='print' bgcolor='#ff'$staff_emailnbsp;/td td class='print' bgcolor='#ff'$staff_phonenbsp;/td td class='print' bgcolor='#ff'$staff_phone2nbsp;/td /tr; echo $tableContent; } //close while loop echo /table ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Web Page Caching
You can append to the URL a dummy variable that is sure to change every time: http://.../mypage?nocache=?php echo time() ; ? This will force the refresh. Ignatius - Original Message - From: Philip Zee [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, February 16, 2003 9:46 PM Subject: [PHP-DB] Web Page Caching Hello, I don't know if this is the right list to send this question to. It appears that the browser caches the result after a PHP page updates the database. I have to manually reload it in order to see the updates. Does anyone know how to overcome this? Thanks, Philip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Grabbing emails into MySql
Investigate PHP's IMAP functions. Ignatius - Original Message - From: Dave Carrera [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 8:09 AM Subject: [PHP-DB] Grabbing emails into MySql Hi All How would I go about grabbing ALL emails to a SMTP box and placing there contents and heads (individual parts of the message) into a MySql database. I have a feeling its a file to array kind of thing or a fsock thing but not sure. I have never attempted this kind of thing so any examples, websites, tips would be very much appreciated. Thanks in advance for any assistance. Dave Carrera --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.456 / Virus Database: 256 - Release Date: 18/02/2003 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Storing an array in the database
If your array is multidimensional, you could store it in a javascript-style: // get the print_r() // replace (recursively) all instances of Array( .. ) by [...] If you ever plan to write a class or a function to do that, let me know! Ignatius - Original Message - From: Jonathan Villa [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 28, 2003 5:09 PM Subject: [PHP-DB] Storing an array in the database How would I store an array in the database? I want to store 2 things. One array of shirt sizes and one array of which holds other arrays. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help with a query
Still not good. Try: SELECT a.item_id, a.subtotal, a.quantity FROM shopping_cart a, orders b WHERE b.session_id = .session_id(). AND b.customer_id = $customer_id AND a.order_id = b.border_id session_id() must be interpolated. Ignatius - Original Message - From: Corne' Cornelius [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 07, 2003 9:00 AM Subject: Re: [PHP-DB] Help with a query Why not use: SELECT a.item_id, a.subtotal, a.quantity FROM shopping_cart a, orders b WHERE b.session_id = session_id() AND b.customer_id = $customer_id AND a.order_id = b.border_id ? !Exclude Disclaimer! Jonathan Villa wrote: I can't figure this query out. I want to pull data from 2 tables but using a primary key from one. Here is what I think it should look like. SELECT item_id, subtotal, quantity from shopping_cart WHERE order_id = (SELECT order_id FROM orders WHERE session_id = session_id()) AND customer_id = $customer_id; -Jonathan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] I'm almost there! Just a little more help
You must use absolute path names c:\\... in copy(). As a matter of personal hygiene, I would not recommend to use file/ dir names containing spaces in your document root directory (or any place that the PHP user must have access). Why not try c:/apache/htdocs ? Ignatius - Original Message - From: Stephen K Knight [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, March 07, 2003 6:06 PM Subject: [PHP-DB] I'm almost there! Just a little more help Below is all of my code. The first is my html page that calls my php page. I do not know php well enough to edit the code to make this work. I need the image to go to a folder called logos on my C drive. The actual path is: C:\Program Files\Apache Group\Apache2\htdocs\logos Could someone please make the changes to my code so that it will work! Thank you Thank you!!! HTML Page*** html form action=fileupload2.php method=post enctype=multipart/form-data submit this file: input type=file name=userfilebr rename to: input type=text name=newnamebr input type=submitbr /form /html **PHP Page * ? if(!empty($userfile)) { $abpath = logos/ . $newname; echo FileUpload2.php; echo $username; echo $newname; echo $abpath; //copy the file // copy($userfile, $abpath); //destroy the uploaded file // unlink($userfile); // write javascript to store the newname // echo script language='javascript'\n; // echo newname = ' . $newname . ';\n; // echo /script\n; } ? If someone could fix this I would greatly greatly apreciate it! In Kindness Stephen K Knight -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] table relationship
Yes. You have to use the subtype relational design: USER user_id (PK) | | | || | || AdministratorClient Staff user_id(PFK) user_id(PFK) user_id(PFK) admin_field1 user_field1 staff_field1 admin_field2 . With a 1-1 relationship from Administrator to User, 0-1 relationship from User to Administrator (PFK : PRIMARY KEY and FOREIGN KEY) This is particularly useful when the subtypes have different fields, so you don't want to have only one table with many blanks for fields that do not relate to the type at hand. HTH Ignatius - Original Message - From: shaun [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 10, 2003 10:35 AM Subject: [PHP-DB] table relationship Hi, I am creating a web site which will have different types of users: Administrators, clients and staff. Is it possible/good practice to have 3 tables related to one table i.e. USER user_id (PK) | | | || | || AdministratorClient Staff admin_id(PK) client_id(PK) staff_id(PK) user_id(FK) user_id(FK)user_id(FK) Thanks in advance for any advice offered. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dynamic Variable names
The way to go is: ${tips_.$i} where $i is your increment control variable HTH Ignatius, Brussels Where the fuck is Belgium? (D. Ivester, CEO, Coca-Cola) - Original Message - From: David Rice [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, March 09, 2003 1:34 PM Subject: [PHP-DB] Dynamic Variable names Just a quick question about dynamic variables would like to end up with a variable called $tips_1 $tips_2 ... $tips_n where n is the value of the variable $sid i have tried $tips . '$sid'; and other variants, but i can't get one that doesn't return a parse error or T_VARIABLE error. _ Worried what your kids see online? Protect them better with MSN 8 http://join.msn.com/?page=features/parentalpgmarket=en-gbXAPID=186DI=1059 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sorting problem...
Take a look at the MySQL DATE_FORMAT() function. Ignatius - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, March 13, 2003 2:43 PM Subject: [PHP-DB] sorting problem... Hi All, I need to sort some data from a MySQL table. I have data saved like this: ++-++--+ | id | unixtime| porta_snmp | porta_switch | ++-++--+ | 1 | 2003-01-07 12:23:24 | 1614 | 1| | 2 | 2003-01-07 12:24:01 | 1614 | 1| | 3 | 2003-01-07 12:29:34 | 1614 | 1| | 4 | 2003-01-07 12:30:19 | 1614 | 1| | 5 | 2003-01-07 12:31:01 | 1614 | 5| | 6 | 2003-01-07 12:32:06 | 1614 | 5| | 7 | 2003-01-07 12:33:01 | 1614 | 1| | 8 | 2003-02-07 12:34:06 | 1614 | 1| | 9 | 2003-02-07 12:35:00 | 1614 | 1| | 10 | 2003-02-07 12:36:01 | 1614 | 1| ++-++--+ I neet to sort the data to be able to read it better. In this case I just need to filter the data to get only the different info for each day. Some thing like this: 2003-01-0716141 2003-01-0716145 2003-02-0716141 Is this possible ? Thank's in advance, Gus -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] several pointers to records in one field
The standard relational way is a relationship table: children - FK_parentID (parent) FK_childrenID (child) PRIMARY KEY ( FK_parentID, FK_childrenID ) HTH Ignatius - Original Message - From: Alain Barthélemy [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Monday, March 17, 2003 6:36 PM Subject: [PHP-DB] several pointers to records in one field Hello, I started to use PHP with MySQL last december. Personal use: list of inhabitants of a town in the 15th century Problem is the following: one person has an arbitrary number of children. It is heavy to have fields child1,child2,child3,...,childn containing the row number of each child especially if the number of children is variable. When I played with Commodore VIC20 I used to put pointers to records in a string in the form pointer1,pointer2,...,pointern in a string. I think of using explode and implode to put all the record numbers of the children in one varchar field. If someone have a better idea? -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Solidarity with the World View
Largely off topic palso. This mailing list does not care about what you have to say on this subject. It is a great professional tool for many of us, and does not need to be polluted. Ignatius - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, March 20, 2003 11:22 AM Subject: [PHP-DB] Solidarity with the World View At this moment, our hearts should reach out to the people of Iraq who are now faced with the brutality of an oppressive US regime. Bush is now acting like a dictator, worse than Hitler, and is a shame for all peace loving US citizens. I sympathise with all the technocrats of our own software fraternity, who have applied their brains on developing quality software, without realising on the notoriety that it could have brought about, when used in one-sided wars like the present one against Iraq. Perhaps Richard Stallman should air his views here, on whether Free Software is to be restricted for military applications. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] database model
I have been using Dezign for Databases from Datanamic for several years. http://www.datanamic.com/ Not free, but invaluably helpful. I strongly recommend it. Ignatius - Original Message - From: Snijders, Mark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 1:20 PM Subject: [PHP-DB] database model hello I use mysql can somebody tell me if it's possible to create a database model, like you can do in access... so you can see the relationships between tables (exporting to access and then to it really sucks :((( ) so please another option if possible thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] array fill/sort question
Another approach: 1. Load all results from the query in an array 2. Sort the array using a custom-defined user-defined comparison function ( usort() ). Study the example in the PHP manual. Writing your own comparison function is easy: - explode your IP addresses in 4 items each ( explode() ) - compare successively item by item HTH Ignatius _ - Original Message - From: Snijders, Mark [EMAIL PROTECTED] To: 'Becoming Digital' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, June 11, 2003 8:33 AM Subject: RE: [PHP-DB] array fill/sort question hi, no the both sollutions won't work cause: I can't sort within a query cause subnetaddr is a varchar (10.10.10.10) so it will be ordere like this 10.10.10.10 100.10.10.10 60.10.10.10 and that's not good cause 60 is smaller as 100, so with the function ip2long() i will first make an integer of it the second array solution you gave, won't work, cause I need ALL the query results in the array, and that's the problem I can't handle if I would do it like you said, I can sort it, but then I have a sorted array and for each element I have to do a query again to get the other fields of the table, and that's not good (2500 rows) so can please still somebody help me with this? -Original Message- From: Becoming Digital [mailto:[EMAIL PROTECTED] Sent: dinsdag 10 juni 2003 15:42 To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] array fill/sort question I might be overlooking something, but can't you just do this? $query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact, ccn FROM subnets ORDER BY subnetaddr; If you can't, you can sort the array like this. ? $query = SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact, ccn FROM subnets; $results = mysql_query( $query ); while ( $iptable = mysql_fetch_array( $result ) ) { $iptable['subnetaddr'] = ip2long( $iptable['subnetaddr'] ); } ? You can subsequently sort the array for the desired result. Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Snijders, Mark [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, 10 June, 2003 08:55 Subject: [PHP-DB] array fill/sort question hi, I'm working on a ipaddres/subnet programm now i have a talbe with a lot of information about ip-addresses i'm having this query: SELECT s_id, subnet_name,subnetaddr,subnetmask,dnsdomain, location, contact, ccn FROM subnets the subnetaddr field looks like this : 100.20.20.1 and is ofcourse a varchar field BUT before displaying it on the screen i have to sort it by subnetaddr and then show it but i have to sort it as integer, so i use the php-function ip2long(); so you get a decimal... so what i have to do: do the query make a decimal field of the 'subnetaddr' put it in an array, sort it and display it BUT how can i put ALL of the fields in the query in an array, sort it, and then display it? please help me, I can't work it out :( thanks, Mark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Keeping entries of a select-box after submitting the form
What you can do is replicate all OPTIONs with hidden fields: SELECT name=myselect[] OPTION value=1Al di Meola/OPTION OPTION value=2John McLaughlin/OPTION ... /SELECT INPUT name=replica[1] type=hidden value=Al di Meola / INPUT name=replica[2] type=hidden value=John McLaughlin / ... But I fail to see why so doing would be useful. Your dynamic form is created after some query; therefore why not simply call the same query after submission to obtain all possible values of the options? Or perhaps I failed to understand your problem. HTH Ignatius _ - Original Message - From: André Sannerholt [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, June 13, 2003 6:42 PM Subject: [PHP-DB] Keeping entries of a select-box after submitting the form Hi everyone, Well, I have already formulated my problem several times, always in a different way, but yet I have no solution. I try to say it as easy as it gets: I simply want one specific selction-box to 'keep' ALL options present after having submited the form! I'm thinking about a variable or something that contains all that options, and not just only ONE like the value-variable. I hope this is clear now. Regards, André -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] time without seconds
Check the TIME_FORMAT(time,format) MySQL function. Ignatius _ - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Tuesday, June 17, 2003 1:16 PM Subject: [PHP-DB] time without seconds If I have a time stored in MySQL, and I only need the hour and minutes without seconds: 1) Can I crop this in PHP after retrieving it? 2) Is there a way to store this without the seconds in MySQL? Same goes for storing a date without the year. I could use a regular char field, but I want to be able to retrieve a row that corresponds to the current month and day, currently I am doing this with $month = date(n); $day = date(d); $query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day; Is there a better way to do this without storing unnecessary data? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL editor
Try also DBTools (forWindows). Very nice. Been using for 2 years, and happy about it. http://www.dbtools.com.br/EN/ Ignatius _ - Original Message - From: Achilles Maroulis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 19, 2003 10:46 AM Subject: Re: [PHP-DB] MySQL editor MySQL CONTROL CENTER from mysql.org (very nice) SQLYOG from sqlyog.com PHPMYADMIN from phpmyadmin.net (web interface) - Original Message - From: Angelo Zanetti [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 19, 2003 11:40 AM Subject: [PHP-DB] MySQL editor Hi all. I need to get a program (interface) for MySQL, I was using MySQL Front but they've discontinued its use. Any suggestions. thanx in advance -Angelo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] checking a string for numbers
$extract = preg_replace( /[^0-9]/, , $str ) // will extract the figures from your string HTH Ignatius _ - Original Message - From: Jamie Saunders [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 26, 2003 1:04 PM Subject: [PHP-DB] checking a string for numbers Hi, I'm trying to find a way of simply checking a string for numbers. e.g. if ($myVar contains a number) { //numbers present } else { //no numbers present } Thanks, -- Jamie Saunders Media Architect [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Breaking down a table field....
SELECT DISTINCT unit... Ignatius _ - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 07, 2003 3:37 PM Subject: [PHP-DB] Breaking down a table field I have a table, wth many entries. Each entry has been asigned a unit to belong to. I want to list all the units dynamically. How can I display all the units, without displaying each instance of the unit? EG: Unititem breakfast cereal breakfast toast lunch salad lunch sandwich dinner steak dinner pie lunch soup dinner lasagne and so on.. I'd wanna get a list of: breafast lunch dinner not several instances of each... how can I do this? * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Queries probably timing out
- Original Message - From: Dillon, John [EMAIL PROTECTED] To: PHP-DB List [EMAIL PROTECTED] Sent: Tuesday, August 19, 2003 11:47 AM Subject: [PHP-DB] Queries probably timing out I'm doing queries on tables with 45,000 rows in one table and 1-2000 rows in another.. I think the queries are failing due to timeout on the server. The server is not dedicated to me and I may not be able to affect the timeout settings...though I'll ask my hosting company (Positive Internet). If I decide to do the queries on my local PC (I don't need or want to do them over the internet), (1) do I have to set up my PC as a server, Yes. (2) if so what's the quickest and easiest server to get started with, Install Apache, PHP and MySQL. There are countless tutes on the web on how to do so. It is a breeze under Windows 2000 (3) are there complications running the server on the same PC as the client applications (ie my PHP code), No, except maybe performance (4) do I then download MySQL and PHP onto it, though I read PHP comes bundled with MySQL, PHP has an API to MySQL, but you have to have first a MySQL server running (5) will it become clear to me what host name/IP address to use to connect to the database (up to now I've been told by the hosting company). You can use a dynamic DNS set-up (look for instance www.dnsmadeeasy.com) if you need a name-based address. Also a breeze to set up. Any other suggestions on timeouts on queries? Thanks, John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Need For SPEED
Sorry I don't seem to get it. 1. What isthe import function provided in PHPList ? 2. What do you mean by initialize each data record ? Ignatius _ - Original Message - From: Creigh Shank [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Thursday, August 21, 2003 7:26 PM Subject: Re: [PHP-DB] Need For SPEED Thanks. We're using the import function provided in PHPList. Looked at a more direct method, but we need to properly initialize each data record in the database. Sorry about the cross-posting. Not sure which list can help. Creigh At 07:13 PM 8/21/2003 +0200, you wrote: What is your data load method? What is the type of your table(s)? With LOAD DATA and text files, I load several million rows in about a minute. Also please don't cross-post. Better first find out what the most suitable mailing list is. Ignatius _ - Original Message - From: Creigh Shank [EMAIL PROTECTED] To: MySQL Users [EMAIL PROTECTED]; PHP-db List [EMAIL PROTECTED]; PHPList Users [EMAIL PROTECTED]; Michiel Dethmers [EMAIL PROTECTED] Sent: Thursday, August 21, 2003 6:58 PM Subject: [PHP-DB] Need For SPEED Using an Apache/PHP/MySQL/Linux (Redhat 8.0) solution, PHPList, to create an e-mailing list for our 5.6 million book club members. Unfortunately, the import speed for importing records (at record number 150,000 the rate is about 2,000 records per hour). We're running on the following: P4 (1.5 Ghz), 1.2 Gbytes RAM (650 Mbytes RAM Disk using ramfs), IDE drive (72,00 rpm) So far we've moved the MySQL data files (var/lib/mysql), PHP /tmp and upload directories and PHPlist web site files to RAM Disk (still just testing - not yet dealing with data safety issues). With all of this tuning we're still at only 2,000 records per hour for uploading. We need to be at 100,000 records per hour (uploading and sending seem to run at about the same rate - we need to be able to send to all book club members in the same week). Any suggestions? Creigh (We're planning to run the system on a server with dual Opterons, 8 Gbytes RAM and RAID-5 SCSI drives, but I don't think the additional system horsepower will solve our problem.) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Read the MySQL manual. 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. HTH Ignatius _ - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 3:39 AM Subject: [PHP-DB] MySQL, PHP or ghost? Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL| auto_increment | | year| year(4) | YES | | NULL| | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? Beckman -- - Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ -- - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Hmmm... You have a point; the doc is not quite clear. Illegal YEAR values are converted to My understanding is that any illegal value will be first converted into '', then into the corresponding year inside the 1901-2155 interval, ie 2000 Well, all this is quite logical. I have no quarrel with this behaviour. Ignatius _ - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, August 27, 2003 4:13 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? On Wed, 27 Aug 2003, Ignatius Reilly wrote: Read the MySQL manual. Hmmm, I thought I did. 6.2.2.4: Illegal YEAR values are converted to . 0 value is interpreted as 2000. Your empty string is converted to an integer, thus 0. What confuses me (what I can't find) is why a quoted empty string is converted to a quoted integer 0 for a YEAR type. Based on the manual, I assumed an empty string is considered an Illegal YEAR and thus converted to . The empty string is NOT converted to an UNQUOTED digit 0, because otherwise the field would be set to (the intended and expected action). You must specify it as a string '0' or '00' or it will be interpreted as . Can you point me to the correct portion of the manual that explains that? What you explain sounds like MySQL is working as designed, but I'm a bit embarrassed that I missed that in the manual, so I want to read up on it. Seems a bit obscure; I've been using mysql for 4+ years and have never came across this. Thanks, Beckman - Original Message - From: Peter Beckman [EMAIL PROTECTED] Seems that either I don't understand mysql, or something. My table, with the non-important things removed... mysql explain plate; +-+---+--+-+-+-- --+ | Field | Type | Null | Key | Default | Extra | +-+---+--+-+-+-- --+ | pid | mediumint(8) unsigned | | PRI | NULL | auto_increment | | year| year(4) | YES | | NULL | | [...] So my assumption is that if I insert with year= it should use the default. Or at least . mysql update plate set year=NULL where pid=65; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | NULL | +-+-+--+- But if I do this: mysql update plate set year= where pid=65; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql select * from plate where pid=65; +-+-+--+- | pid | plate | year | +-+-+--+- | 65 | DVF0343 | 2000 | +-+-+--+- 2000? What? Why? Confused. PHP or Mysql fault? -- - Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ -- - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple field replace...?
hundreds of what? rows or columns? Ignatius _ - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 11:35 AM Subject: [PHP-DB] Simple field replace...? Hi there, I need to take a field in my database, and remove the first 32 characters from each entry... There are 100's, and I know there's gotta be an easy way... I've looked up string replace, and it only appears to work one at a time... Can anyone tell me how to make it accross the whole table...? * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Simple field replace...?
Then a simple substring will do: UPDATE mytable SET url = SUBSTRING( url FROM 5 ) btw your date column looks pretty awful. HTH Ignatius _ - Original Message - From: [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 12:06 PM Subject: Re: [PHP-DB] Simple field replace...? Sorry, I'll specify... I have one column, in a row of perhaps 4 fields. I want to remove the first 32 characters from onlt one field EG: My DB: namedateurl ip bob 1/2/99 http:// 1.1.1.1. sue 4/6/01 http:// 2.2.2.2 If I wanted to remove just the http bit and leave :// I'd have to remove the first 4 characters from all the 'url' column. this is what I wanna do, jsut 100+ times over. but the first 32 characters. Ignatius Reilly [EMAIL PROTECTED] 28/08/2003 11:04 To: [EMAIL PROTECTED], [EMAIL PROTECTED] cc: Subject:Re: [PHP-DB] Simple field replace...? hundreds of what? rows or columns? Ignatius _ - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 11:35 AM Subject: [PHP-DB] Simple field replace...? Hi there, I need to take a field in my database, and remove the first 32 characters from each entry... There are 100's, and I know there's gotta be an easy way... I've looked up string replace, and it only appears to work one at a time... Can anyone tell me how to make it accross the whole table...? * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Well, it IS logical provided one is aware of the rules of the game, meaning, as you rightly point out, that MySQL does not reject SQL statements for incorrect values, but attempts at converting them at any price. I have no clue whether it is or not a shortcoming of the implementation (I do not know what SQL-92 says about this). Therefore data validation should be done outside MySQL. Ignatius _ - Original Message - From: Martin Marques [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; Peter Beckman [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 2:36 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? El Mié 27 Ago 2003 11:34, Ignatius Reilly escribió: Hmmm... You have a point; the doc is not quite clear. Illegal YEAR values are converted to My understanding is that any illegal value will be first converted into '', then into the corresponding year inside the 1901-2155 interval, ie 2000 Well, all this is quite logical. I have no quarrel with this behaviour. Not at all. This is totally ilogical. Wrong date values should give error messages. See what happens when you try to bend a bad input value: http://archives.postgresql.org/pgsql-general/2003-07/msg00599.php Please don't use MySQL in monetary aplications!! -- Porqué usar una base de datos relacional cualquiera, si podés usar PostgreSQL? - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL, PHP or ghost?
Well, you're certainly right (except I didn't get the meaning of 'FS' - anything obscene?). However: 1. The job of this ML is to help people get things done 2. For criticisms concerning the design of MySQL, you may get better results posting directly at the MySQL dev team. 3. You may decide that another RDBMS may suit your needs better. Someone told me that Oracle is quite nice. Ig _ - Original Message - From: Martin Marques [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; Peter Beckman [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, August 28, 2003 9:37 PM Subject: Re: [PHP-DB] MySQL, PHP or ghost? El Jue 28 Ago 2003 11:25, Ignatius Reilly escribió: Well, it IS logical provided one is aware of the rules of the game, meaning, as you rightly point out, that MySQL does not reject SQL statements for incorrect values, but attempts at converting them at any price. I have no clue whether it is or not a shortcoming of the implementation (I do not know what SQL-92 says about this). Therefore data validation should be done outside MySQL. The thing that IS ilogical is the way MySQL plays the game. What would you think if all of a sudden the date command in linux did something like that (try to add some strange date when the given date isn't a valid date)? Now lets suppose this is a good idea, and one would have to program to get the data integrity (data integrity isn't only when the database server fails). Then why do I have to put different data types? Let's use text everywhere! Or if I do use different data types, what if I have a bug? I could have people loading erronous data in the database and not getting an error, and after loading lots of information I find the bug, but see that all the data is bogus (like the numeric example I gave earlier). To state it more clearly, I havn't seen Oracle, Informix or PostgreSQL do things like this, which reminds me of what someone told me once: MySQL is just a FS with an lousy SQL language (and pretty incomplete). Maybe the problem is that most people never read Codd's 12 rules for a RDBMS: http://www.byte.com/art/9406/sec8/art11.htm -- 16:23:01 up 6 days, 8:13, 4 users, load average: 0.16, 0.31, 0.18 - Martín Marqués |[EMAIL PROTECTED] Programador, Administrador, DBA | Centro de Telematica Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT Part of a Field
SUBSTRING() _ - Original Message - From: Shaun [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, August 29, 2003 11:57 AM Subject: [PHP-DB] SELECT Part of a Field Hi, How can I SELECT a portion of a field in a table for example the first character, or the second two characters etc? Thanks for your help -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL: CREATE TABLE, BLOB, UNIQUE, INDEX etc
You should be very wary of the CREATE TABLE ... SELECT statement. From experience, the types created are not always conform to intuition - I've had my share of nasty surprises Much safer to do a CREATE TABLE statement defining the column types, then do an INSERT INTO ... SELECT Ignatius _ - Original Message - From: Dillon, John [EMAIL PROTECTED] To: php [EMAIL PROTECTED] Sent: Friday, August 29, 2003 5:06 PM Subject: [PHP-DB] MySQL: CREATE TABLE, BLOB, UNIQUE, INDEX etc My code: $query= CREATE TABLE IF NOT EXISTS temp3 UNIQUE(CON175) IGNORE SELECT DISTINCT CONCAT($tbl2.this,$tbl2.that) AS CON175 FROM $tbl2 WHERE $tbl2.this='$rcc' ; gives error: Query failed: BLOB column 'CON175' used in key specification without a key length. Manual suggests to give a BLOB a length: CREATE TABLE test (blob_col BLOB, INDEX(blob_col(10))); ...but how do you work this into the above query? CREATE TABLE IF NOT EXISTS temp3 (UNIQUE(CON175) BLOB, INDEX(CON175)(50))... ..does not work, I suppose because CON175 has not been created yet? CON175 is BLOB by default resulting from this part of the query: IGNORE SELECT DISTINCT CONCAT($tbl2.this,$tbl2.that)... this and that are varchar types. How do I set this as varchar instead: UNIQUE(CON175) VARCHAR(50) does not work. http://www.mysql.com/doc/en/CREATE_TABLE.html - lacks examples! John http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php