[PHP-DB] [plain SQL Problem] Group By
Hi, sorry if this is off topic. I hope you don't mind a plain SQL question here. I know I can do what I want using subqueries (I'm on Oracle9i here), but I would really like to avoid them for performance reasons. Here's my example data: DESC dept NameType - DEPT_ID NUMBER(10) DEPT_NAME VARCHAR2(20) SELECT * FROM dept; DEPT_ID DEPT_NAME --- 1 sales 2 marketing DESC emp Name Type -- EMP_ID NUMBER(10) EMP_DEPT_ID NUMBER(10) EMP_AGE NUMBER(2) EMP_NAME VARCHAR2(20) SELECT * FROM emp; EMP_ID EMP_DEPT_IDEMP_AGE EMP_NAME - --- -- 1 1 32john 2 1 19 mike 3 1 40 alex 4 2 42 norman 5 2 33 jason 6 2 20bert And here's the result I'd like to produce: ??? DEPT_NAME YOUNGEST_AGE YOUNGEST_NAME OLDEST_AGE OLDEST_NAME - - -- --- marketing 20 bert 42 norman sales 19 mike 40alex Here's what I have so far: SELECT D.dept_name, MIN(E1.emp_age) AS YOUNGEST_AGE, MAX(E2.emp_age) AS OLDEST_AGE FROM dept D, emp E1, emp E2 WHERE E1.emp_dept_id = D.dept_id AND E2.emp_dept_id = D.dept_id AND E1.emp_id E2.emp_id GROUP BY D.dept_name DEPT_NAMEYOUNGEST_AGE OLDEST_AGE -- marketing 2042 sales 19 40 What is missing ist the name of the younges and oldest employee, since I can't use aggregate functions to get at them. Any help would be greatly appreciated! Thanks, -sapporo. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] hotornot functionality
I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: 1. A picture is served up. 2. User clicks on a radio button scale from 1 to 10 to rate the picture. 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. 4. The user can cycle through as many pictures this way as they want. I have MySQL and PHP to work with. What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit updates the database with the rating and then fetches the next row. The problem that occurred to me as I was putting together a prototype is: I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, which should work ok, but the problems come up when they reach the last row. Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] hotornot functionality
Why not have a field called last in the db? You set it equal to true for the last image and then check it for all of the images. If it's true, you just null the next option and the user can't go any farther. From: Matthew Horn [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] hotornot functionality Date: Wed, 28 May 2003 08:55:59 -0400 MIME-Version: 1.0 Received: from pb1.pair.com ([216.92.131.4]) by mc1-f1.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.5600); Wed, 28 May 2003 05:56:22 -0700 Received: (qmail 87531 invoked by uid 1010); 28 May 2003 12:56:18 - Received: (qmail 87516 invoked from network); 28 May 2003 12:56:17 - X-Message-Info: JGTYoYF78jEHjJx36Oi8+Q1OJDRSDidP Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: mailto:[EMAIL PROTECTED] list-unsubscribe: mailto:[EMAIL PROTECTED] list-post: mailto:[EMAIL PROTECTED] Delivered-To: mailing list [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] X-Mailer: Internet Mail Service (5.5.2653.19) Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 28 May 2003 12:56:22.0911 (UTC) FILETIME=[8A78A0F0:01C32518] I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: 1. A picture is served up. 2. User clicks on a radio button scale from 1 to 10 to rate the picture. 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. 4. The user can cycle through as many pictures this way as they want. I have MySQL and PHP to work with. What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit updates the database with the rating and then fetches the next row. The problem that occurred to me as I was putting together a prototype is: I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, which should work ok, but the problems come up when they reach the last row. Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] hotornot functionality
i would do it totally different if i understand you right.. you start with row number one, show it, give it a rate, then show number 2, and show number 1 as last rated pic!!! then you have the problem of reaching the last record!! but !! i also see another problem: if you do row 1,2,3,4 you always gets the first image , then the second etc etc what I would do: take a random picture from the mysql table (you can use the mysql random functin within a query for it) then show this one! give it a rate then after rating it, put it in an array then do a new random query but use the 'not in' function and don't select the numbers what are in the array!! so you get a new picture! and the last rated pic is the picture at the last place in the array so you can show it... and when the array has equal number of rows as the table has, you showed them all and you empty the array so they can start over you get my point ? (sorry for my bad english) how about this idea? greeting , mark -Original Message- From: Matthew Horn [mailto:[EMAIL PROTECTED] Sent: woensdag 28 mei 2003 14:56 To: [EMAIL PROTECTED] Subject: [PHP-DB] hotornot functionality I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: 1. A picture is served up. 2. User clicks on a radio button scale from 1 to 10 to rate the picture. 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. 4. The user can cycle through as many pictures this way as they want. I have MySQL and PHP to work with. What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit updates the database with the rating and then fetches the next row. The problem that occurred to me as I was putting together a prototype is: I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, which should work ok, but the problems come up when they reach the last row. Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] hotornot functionality
I think the best way is to use sessions. when the user comes to the site or he submits a rating, start a session and create a variable, in which you store the images' id that the user rated like $var=1,1423,523 etc.. then use it in your query mysql_query(select id from images where id not in ($var) order by rand() limit 1); this will keep the images the user rated out of your recordset and gives you a random image from the database -- Finest, Mengü mailto:[EMAIL PROTECTED] MH I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: MH 1. A picture is served up. MH 2. User clicks on a radio button scale from 1 to 10 to rate the picture. MH 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. MH 4. The user can cycle through as many pictures this way as they want. MH I have MySQL and PHP to work with. MH What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit MH updates the database with the rating and then fetches the next row. MH The problem that occurred to me as I was putting together a prototype is: MH I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to MH rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, MH which should work ok, but the problems come up when they reach the last row. MH Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. MH MH Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] printing with php
Crikey !! However, this is still server-side, and the impression I got was that the printing was going to be client-side. I may be wrong though, in which case, this seems to do the trick just fine BTW, its also on the PHP site ... printer module. Ronan e: [EMAIL PROTECTED] t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley On 28 May,2003 at 15:55 Catta Rodolphe wrote: Good start but in french, hope u know a little of French but it is not hard to understand ! ### tire de : function.printer-set-option.html printer_set_option 6.84.31 printer_set_option()Configure la connexion a` l'imprimante [ Exemples avec printer_set_option ] CVS uniquement bool printer_set_option ( resource handle , int option , mixed value ) printer_set_option modifie les options suivantes pour la connexion a` l'imprimante handle . handle doit e^tre une ressource d'imprimante valide. option peut e^tre l'une des constantes suivantes : * PRINTER_COPIES : indique le nombre de copie a` imprimer. value doit e^tre un entier . * PRINTER_MODE : spe'cifie le type de data (text, raw' ou emf), value doit e^tre une chai^ne de caracte'res . * PRINTER_TITLE : spe'cifie le nom du document, value doit e^tre une chai^ne de caracte'res . * PRINTER_ORIENTATION : spe'cifie l'orientation du papier, value peut e^tre PRINTER_ORIENTATION_PORTRAIT ou PRINTER_ORIENTATION_LANDSCAPE * PRINTER_RESOLUTION_Y : spe'cifie la re'solution en ordonne'es, en DPI, value doit e^tre un entier . * PRINTER_RESOLUTION_X : spe'cifie la re'solution en absisse, en DPI, value doit e^tre un entier . * PRINTER_PAPER_FORMAT : spe'cifie un format de papier pre'de'fini : donnez a` value la valeur de PRINTER_FORMAT_CUSTOM si vous souhaitez utiliser un format de papier personnalise', gra^ce aux constantes PRINTER_PAPER_WIDTH et PRINTER_PAPER_LENGTH . value peut alors e^tre l'une des constantes suivantes : o PRINTER_FORMAT_CUSTOM : vous laisse spe'cifier le format de papier. o PRINTER_FORMAT_LETTER : spe'cifie le format standard letter (8 1/2 par 11 pouces (2.54cm)). o PRINTER_FORMAT_LETTER : spe'cifie le format standard legal (8 1/2 par 14 pouces (2.54cm)). o PRINTER_FORMAT_A3 : spe'cifie le format standard A3 (297 par 420 millime`tres). o PRINTER_FORMAT_A4 : spe'cifie le format standard A4 (210 par 297 millime`tres). o PRINTER_FORMAT_A5 : spe'cifie le format standard A5 (148 par 210 millime`tres). o PRINTER_FORMAT_B4 : spe'cifie le format standard B4 (250 par 354 millime`tres). o PRINTER_FORMAT_B5 : spe'cifie le format standard B5 (182 par 257 millime`tres). o PRINTER_FORMAT_FOLIO : spe'cifie le format standard FOLIO (8 1/2 par 13 pouces (2.54cm)). * PRINTER_PAPER_LENGTH : si PRINTER_PAPER_FORMAT vaut PRINTER_FORMAT_CUSTOM , PRINTER_PAPER_LENGTH spe'cifie une longueur personnalise'e de papier, en millime`tres. value doit e^tre un entier . * PRINTER_PAPER_WIDTH : si PRINTER_PAPER_FORMAT vaut PRINTER_FORMAT_CUSTOM , PRINTER_PAPER_WIDTH spe'cifie une largeur personnalise'e de papier, en millime`tres. value doit e^tre un entier . * PRINTER_SCALE : spe'cifie le facteur de mise a` l'e'chelle du document. La taille physique de la page imprime'e est alors mise a` l'e'chelle avec un facteur e'gal a` value /100. Par exemple, si vous donnez un facteur d'e'chelle de 50, l'impression sera de la moitie' de la taille du document original. value doit e^tre un entier . * PRINTER_BACKGROUND_COLOR : spe'cifie la couleur de fond pour le contexte actuel. value doit e^tre une chai^ne de caracte'res contenant une couleur au format RGB hexade'cimal : par exemple, 005533. * PRINTER_TEXT_COLOR : spe'cifie la couleur du texte pour ce contexte d'imprimante. value doit e^tre une chai^ne de caracte'res contenant une couleur au format RGB hexade'cimal : par exemple, 005533. * PRINTER_TEXT_ALIGN : spe'cifie l'alignement du etxte pour le contexte d'imprimante. value peut e^tre une combinaison, avec l'ope'rateur OR, des constantes suivantes : o PRINTER_TA_BASELINE : le texte sera aligne'e sur la ligne de base. o PRINTER_TA_BOTTOM : le texte sera aligne'e sur la ligne de fond. o PRINTER_TA_TOP : le texte sera aligne'e sur la ligne de haut. o PRINTER_TA_CENTER : le texte sera aligne'e au centre. o PRINTER_TA_LEFT : le texte sera aligne'e a` gauche. o PRINTER_TA_RIGHT : le texte sera aligne'e a` droite. Exemple avec printer_set_option ?php $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 75); printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT); printer_close($handle); ? Ronan Chilvers wrote: Hi Carol I don't think you'll strike lucky here !! PHP is a server-side, not client-side language and therefore doesn't know anything about the client's printer or its settings. You can use PHP to create a page that is formatted nicely and will therefore print well. There are also
Re: [PHP-DB] [plain SQL Problem] Group By
Em Wed, 28 May 2003 14:54:19 +0200 Sapporo [EMAIL PROTECTED] escreveu: Hi, sorry if this is off topic. I hope you don't mind a plain SQL question here. Maybe this works... SELECT D.dept_name, MIN(E1.emp_age) AS YOUNGEST_AGE, MAX(E2.emp_age) AS OLDEST_AGE, E1.emp_name AS YOUNGEST_NAME, E2.emp_name AS OLDEST_NAME FROM dept D, emp E1, emp E2 WHERE E1.emp_dept_id = D.dept_id AND E2.emp_dept_id = D.dept_id AND E1.emp_id E2.emp_id GROUP BY D.dept_name, E1.emp_name, E2.emp_name -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ODBC driver for ORACLE
Alain Barbu wrote: Hi, Is there any free ODBC Driver for ORACLE 9i to use with PHP, APACHE, LINUX ? Regards Alain The Oracle Client software includes a perfectly good ODBC driver. If you install the client it will be included. -- Dave Smith [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] hotornot functionality
Uh, why not just do this: input type='hidden' name='lastid' value='1930' Then on the next page, you can get the id. Or geez, it's gonna be there anyway -- after you do the insert/update of your vote, just pass that ID to the function that displays the page. function display($x) { if (!empty($x['vote'])) { db_query(insert into vote (pid,vote) values (.$x['thisid'].,.$x['vote'].)); } $r = db_query(select * from pictures order by rand() limit 1); $row = mysql_fetch_array($r); // sure, do error checking if you want beginpage($x['thisid'],$x['vote']); votebar($row['pid']); echo img src='.$row['imgurl'].'; endpage(); } assuming beginpage is responsible for displaying the last image you voted on. Peter On Wed, 28 May 2003, Matthew Horn wrote: I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: 1. A picture is served up. 2. User clicks on a radio button scale from 1 to 10 to rate the picture. 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. 4. The user can cycle through as many pictures this way as they want. I have MySQL and PHP to work with. What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit updates the database with the rating and then fetches the next row. The problem that occurred to me as I was putting together a prototype is: I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, which should work ok, but the problems come up when they reach the last row. Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- 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-DB] Re: printing with php
Here it is in English. You will find it in the PHP manual. To get a copy of the help go to http://weblabor.hu/php-doc-chm/ Dave Anagram systems http://www.anagram-sys.co.uk/ printer_set_option Configure the printer connection () bool printer_set_option ( resource handle, int option, mixed value ) The function sets the following options for the current connection. handle must be a valid handle to a printer. For option can be one of the following constants: PRINTER_COPIES: sets how many copies should be printed, value must be an integer. PRINTER_MODE: specifies the type of data (text, raw or emf), value must be a string. PRINTER_TITLE: specifies the name of the document, value must be a string. PRINTER_ORIENTATION: specifies the orientation of the paper, value can be either PRINTER_ORIENTATION_PORTRAIT or PRINTER_ORIENTATION_LANDSCAPE PRINTER_RESOLUTION_Y: specifies the y-resolution in DPI, value must be an integer. PRINTER_RESOLUTION_X: specifies the x-resolution in DPI, value must be an integer. PRINTER_PAPER_FORMAT: specifies the a predefined paper format, set value to PRINTER_FORMAT_CUSTOM if you want to specify a custom format with PRINTER_PAPER_WIDTH and PRINTER_PAPER_LENGTH. value can be one of the following constants. PRINTER_FORMAT_CUSTOM: let's you specify a custom paper format. PRINTER_FORMAT_LETTER: specifies standard letter format (8 1/2- by 11-inches). PRINTER_FORMAT_LETTER: specifies standard legal format (8 1/2- by 14-inches). PRINTER_FORMAT_A3: specifies standard A3 format (297- by 420-millimeters). PRINTER_FORMAT_A4: specifies standard A4 format (210- by 297-millimeters). PRINTER_FORMAT_A5: specifies standard A5 format (148- by 210-millimeters). PRINTER_FORMAT_B4: specifies standard B4 format (250- by 354-millimeters). PRINTER_FORMAT_B5: specifies standard B5 format (182- by 257-millimeter). PRINTER_FORMAT_FOLIO: specifies standard FOLIO format (8 1/2- by 13-inch). PRINTER_PAPER_LENGTH: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_LENGTH specifies a custom paper length in mm, value must be an integer. PRINTER_PAPER_WIDTH: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_WIDTH specifies a custom paper width in mm, value must be an integer. PRINTER_SCALE: specifies the factor by which the printed output is to be scaled. the page size is scaled from the physical page size by a factor of scale/100. for example if you set the scale to 50, the output would be half of it's original size. value must be an integer. PRINTER_BACKGROUND_COLOR: specifies the background color for the actual device context, value must be a string containing the rgb information in hex format i.e. 005533. PRINTER_TEXT_COLOR: specifies the text color for the actual device context, value must be a string containing the rgb information in hex format i.e. 005533. PRINTER_TEXT_ALIGN: specifies the text alignment for the actual device context, value can be combined through OR'ing the following constants: PRINTER_TA_BASELINE: text will be aligned at the base line. PRINTER_TA_BOTTOM: text will be aligned at the bottom. PRINTER_TA_TOP: text will be aligned at the top. PRINTER_TA_CENTER: text will be aligned at the center. PRINTER_TA_LEFT: text will be aligned at the left. PRINTER_TA_RIGHT: text will be aligned at the right. Example 649. printer_set_option() example copy to clipboard $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 75); printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT); printer_close($handle); User contributed notes: [EMAIL PROTECTED] (20-Oct-2002 01:36) Warning : PRINTER_FORMAT_LETTER = LETTER 8.5x11 PRINTER_FORMAT_LEGAL = LEGAL 8.5x14 If your printer uses custom paper size, printer_get_option will return an unpredictable code. Carol [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Hy there, I have a problem... I have a linux server, apache, php, and mysql instaled. I can make all kind of queries but I nedd to printed them (using the browser but not usig file-print-page setup-) in a specified format (like A3, landscape, border=2cm, and all kind of things like that... usin php) Could enyone help? Thanks! -- Carol [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hy there, I have a problem... I have a linux server, apache, php, and mysql instaled. I can make all kind of queries but I nedd to printed them (using the browser but not usig file-print-page setup-) in a specified format (like A3, landscape, border=2cm, and all kind of things like that... usin php) Could enyone help? Thanks! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Email an attached file
I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. Thanks in advance. Marie EXAMPLE: $myname = Me Myself; $myemail = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $message = hello from happy me; $subject = Included your file; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; $headers .= From: .$myname. .$myemail.\r\n; $headers .= To: .$contactname. .$contactemail.\r\n; $headers .= Reply-To: .$myname. $myreplyemail\r\n; $headers .= X-Priority: 1\r\n; $headers .= X-MSMail-Priority: High\r\n; $headers .= X-Mailer: Just My Server; mail($contactemail, $subject, $message, $headers); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] hotornot functionality
I agree with both Peter and Mengü, in a manner of speaking. Assuming you want visitors to return, I think it's best to use sessions and cookies so that they're not served the same image twice. Passing that information between pages is easy with Peter's method. Mengü's technique (albeit slightly altered) would work well at storing that information for future use. Storing this information is *very* important. If users keep seeing the same images, they won't return. Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Peter Beckman [EMAIL PROTECTED] To: Matthew Horn [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, 28 May, 2003 10:29 Subject: Re: [PHP-DB] hotornot functionality Uh, why not just do this: input type='hidden' name='lastid' value='1930' Then on the next page, you can get the id. Or geez, it's gonna be there anyway -- after you do the insert/update of your vote, just pass that ID to the function that displays the page. function display($x) { if (!empty($x['vote'])) { db_query(insert into vote (pid,vote) values (.$x['thisid'].,.$x['vote'].)); } $r = db_query(select * from pictures order by rand() limit 1); $row = mysql_fetch_array($r); // sure, do error checking if you want beginpage($x['thisid'],$x['vote']); votebar($row['pid']); echo img src='.$row['imgurl'].'; endpage(); } assuming beginpage is responsible for displaying the last image you voted on. Peter On Wed, 28 May 2003, Matthew Horn wrote: I am toying with the idea of implementing functionality similar to the hotornot.com site -- for a different purpose, mind you, but the same kind of user experience. Here's what it does: 1. A picture is served up. 2. User clicks on a radio button scale from 1 to 10 to rate the picture. 3. The page refreshes. The rating is re-computed with the user's rating for the original picture. The original picture becomes that last rated pic, and a new one is served up. 4. The user can cycle through as many pictures this way as they want. I have MySQL and PHP to work with. What I am trying to do is figure out the best approach to implementing it. Specifically, when the user clicks on the radio button, that triggers the form submit via JavaScript. The form submit updates the database with the rating and then fetches the next row. The problem that occurred to me as I was putting together a prototype is: I don't want the user to get the entire result set of all the images in the database at once. I really want them to get just the two images (the one they just rated and the one they are about to rate). Is there a way to remember the last row they selected and then use that number to fetch the next one on the subsequent request? I can keep recycling hidden form fields with a number, which should work ok, but the problems come up when they reach the last row. Anyway, just looking to see if you folks have some ideas. I would prefer to roll my own rather than use one of the available hotornot-style PHP scripts to do this. Matthew J. Horn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- 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] Email an attached file
www.phpclasses.org is your best bet. there are plenty. personally i use this one..http://phpclasses.com/browse.html/package/32.html check out his site for examples. hth jd Marie Osypian [EMAIL PROTECTED] To: [EMAIL PROTECTED] llege.com cc: Subject: [PHP-DB] Email an attached file 05/28/2003 02:08 PM I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. Thanks in advance. Marie EXAMPLE: $myname = Me Myself; $myemail = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $message = hello from happy me; $subject = Included your file; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; $headers .= From: .$myname. .$myemail.\r\n; $headers .= To: .$contactname. .$contactemail.\r\n; $headers .= Reply-To: .$myname. $myreplyemail\r\n; $headers .= X-Priority: 1\r\n; $headers .= X-MSMail-Priority: High\r\n; $headers .= X-Mailer: Just My Server; mail($contactemail, $subject, $message, $headers); -- 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] Email an attached file
Hello!! If your storing the file name, file type, in mysql; and are storing the files on a server. (Which you should be doing!!!) You could use this!! // $query = SELECT * FROM Images WHERE Num = $num; $result = mysql_query ($query, $db); $data = mysql_fetch_object($result); function sendfile($to, $subject, $text, $cc, $from, $file, $type) { $content = fread(fopen($file,r),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time(; $name = basename($file); $text = stripslashes($text); $subject = stripslashes($subject); $header = From: $from\nReply-To: $from\n; $header .= Cc: $cc\n; $header .= MIME-Version: 1.0\n; $header .= Content-Type: multipart/mixed; boundary=$uid\n; $header .= --$uid\n; $header .= Content-Type: text/plain\n; $header .= Content-Transfer-Encoding: 8bnoit\n\n; $header .= $text\n; $header .= \n; $header .= \n; $header .= --$uid\n; $header .= Content-Type: $type; name=\$name\\n; $header .= Content-Transfer-Encoding: base64\n; $header .= Content-Disposition: attachment; filename=\$name\\n\n; $header .= $content\n; $header .= --$uid--; mail($to, $subject, , $header); } $file2 = (./images/$data-name); $type = ($data-filetype); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (Here is that Pic you wanted...); sendfile($To, $sub, $mess, $cc, $From, $file2, $type); //- Of course all of the $To,$sub,etc...etc...etc...are from posting the data from a form. I think you can figure out the rest Good luck!! Dan Brunner On Wednesday, May 28, 2003, at 01:12 PM, [EMAIL PROTECTED] wrote: www.phpclasses.org is your best bet. there are plenty. personally i use this one..http://phpclasses.com/browse.html/package/32.html check out his site for examples. hth jd Marie Osypian [EMAIL PROTECTED] To: [EMAIL PROTECTED] llege.com cc: Subject: [PHP-DB] Email an attached file 05/28/2003 02:08 PM I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. Thanks in advance. Marie EXAMPLE: $myname = Me Myself; $myemail = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $message = hello from happy me; $subject = Included your file; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; $headers .= From: .$myname. .$myemail.\r\n; $headers .= To: .$contactname. .$contactemail.\r\n; $headers .= Reply-To: .$myname. $myreplyemail\r\n; $headers .= X-Priority: 1\r\n; $headers .= X-MSMail-Priority: High\r\n; $headers .= X-Mailer: Just My Server; mail($contactemail, $subject, $message, $headers); -- 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-DB] pg_fetch_result() get unexpectly trimmed
Take a look at the titles in this site (revision project of my bigbands site): http://studorg.nlh.no/storband/revisjon/vis.php An then, move up one folder, and hava look at the same on the current site: http://studorg.nlh.no/storband/vis.php To show the database-entries, I use code similar to this one: --- snip --- $query = SELECT * FROM nyheter_view WHERE visframside = 't' ORDER BY endradato DESC;; // listar oppslag for framsida $resultat = pg_query($dbtilkobling, $query); if (!$resultat) { $feilmelding .= $F1101; include ($exit); } $num = pg_num_rows($resultat); // tilordnar antal rekker på spørringa viss den blei vellukka $i = 0; while ($i$num) { $nyheter_id[$i] = pg_fetch_result($resultat, $i, nyheter_id); $tittel[$i] = pg_fetch_result($resultat, $i, tittel); $ingress[$i] = pg_fetch_result($resultat, $i, ingress); $i++; } pg_free_result($resultat); // frigjer resultatet frå spørringa $i = 0; while ($i$num) { if ($tittel[$i]){ echo h3.$tittel[$i]./h3\n; } if ($ingress[$i]){ echo p.$ingress[$i].br\n; } $i++; } --- snip --- But some of the returning strings like $tittel[$i] get trimmed, and show only first letter in the string stored in the actual database-cell. The strange ting is tha $ingress[$i] returns the whole string... So the problems seem to be in returning values from the column. The code is copied from the script which queries the same table for the same data on the second URL. So the data presented should be exactly the same. I've had a similar problem while developing the current site, but then the problem got solved, and I can't remeber if I did anything (I guess not). But then it happened when I printed the result from the oid-query in the insert-script. Why do this happen? Is it an postgre-issue, or a php-issue? What can I do to solve the problem? BM -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Email an attached file
I am storing the file on my server. -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 2:42 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Email an attached file Hello!! If your storing the file name, file type, in mysql; and are storing the files on a server. (Which you should be doing!!!) You could use this!! // $query = SELECT * FROM Images WHERE Num = $num; $result = mysql_query ($query, $db); $data = mysql_fetch_object($result); function sendfile($to, $subject, $text, $cc, $from, $file, $type) { $content = fread(fopen($file,r),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time(; $name = basename($file); $text = stripslashes($text); $subject = stripslashes($subject); $header = From: $from\nReply-To: $from\n; $header .= Cc: $cc\n; $header .= MIME-Version: 1.0\n; $header .= Content-Type: multipart/mixed; boundary=$uid\n; $header .= --$uid\n; $header .= Content-Type: text/plain\n; $header .= Content-Transfer-Encoding: 8bnoit\n\n; $header .= $text\n; $header .= \n; $header .= \n; $header .= --$uid\n; $header .= Content-Type: $type; name=\$name\\n; $header .= Content-Transfer-Encoding: base64\n; $header .= Content-Disposition: attachment; filename=\$name\\n\n; $header .= $content\n; $header .= --$uid--; mail($to, $subject, , $header); } $file2 = (./images/$data-name); $type = ($data-filetype); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (Here is that Pic you wanted...); sendfile($To, $sub, $mess, $cc, $From, $file2, $type); //- Of course all of the $To,$sub,etc...etc...etc...are from posting the data from a form. I think you can figure out the rest Good luck!! Dan Brunner On Wednesday, May 28, 2003, at 01:12 PM, [EMAIL PROTECTED] wrote: www.phpclasses.org is your best bet. there are plenty. personally i use this one..http://phpclasses.com/browse.html/package/32.html check out his site for examples. hth jd Marie Osypian [EMAIL PROTECTED] To: [EMAIL PROTECTED] llege.com cc: Subject: [PHP-DB] Email an attached file 05/28/2003 02:08 PM I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. Thanks in advance. Marie EXAMPLE: $myname = Me Myself; $myemail = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $message = hello from happy me; $subject = Included your file; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; $headers .= From: .$myname. .$myemail.\r\n; $headers .= To: .$contactname. .$contactemail.\r\n; $headers .= Reply-To: .$myname. $myreplyemail\r\n; $headers .= X-Priority: 1\r\n; $headers .= X-MSMail-Priority: High\r\n; $headers .= X-Mailer: Just My Server; mail($contactemail, $subject, $message, $headers); -- 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-DB] mail() function
I have set up my pc as a test server Windows 98 running Apache as a service, PHP and MySQL but cannot get the mail() function to work. After a long wait, I get an error Warning: Failed to Receive in c:\phpdev\www\assets\submit_users.php on line 17. Is there something I should be changing in the PHP.ini. I used the default settings for this. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mail() function
Yehp, actually there is :-) On windows machines you'll need to change the SMTP in there (Since you probably aren't running a local mail server), in your php.ini you can most likely change it to your ISP's mail server., there is more specific info on the docs for the mail funcion in the php manual -- refer to the user postings: http://us4.php.net/manual/en/ref.mail.php -Mike - Original Message - From: Alex Francis [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 3:41 PM Subject: [PHP-DB] mail() function I have set up my pc as a test server Windows 98 running Apache as a service, PHP and MySQL but cannot get the mail() function to work. After a long wait, I get an error Warning: Failed to Receive in c:\phpdev\www\assets\submit_users.php on line 17. Is there something I should be changing in the PHP.ini. I used the default settings for this. -- 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] Email an attached file
Then you should be able to use that function... So are you storing the Path of the file in MYSQL or any other database?!?!!? If not then replace /- $file2 = (./images/$data-name); //-- to reflect your path... Dan On Wednesday, May 28, 2003, at 02:34 PM, [EMAIL PROTECTED] wrote: I am storing the file on my server. -Original Message- From: Dan Brunner [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 2:42 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Email an attached file Hello!! If your storing the file name, file type, in mysql; and are storing the files on a server. (Which you should be doing!!!) You could use this!! // $query = SELECT * FROM Images WHERE Num = $num; $result = mysql_query ($query, $db); $data = mysql_fetch_object($result); function sendfile($to, $subject, $text, $cc, $from, $file, $type) { $content = fread(fopen($file,r),filesize($file)); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time(; $name = basename($file); $text = stripslashes($text); $subject = stripslashes($subject); $header = From: $from\nReply-To: $from\n; $header .= Cc: $cc\n; $header .= MIME-Version: 1.0\n; $header .= Content-Type: multipart/mixed; boundary=$uid\n; $header .= --$uid\n; $header .= Content-Type: text/plain\n; $header .= Content-Transfer-Encoding: 8bnoit\n\n; $header .= $text\n; $header .= \n; $header .= \n; $header .= --$uid\n; $header .= Content-Type: $type; name=\$name\\n; $header .= Content-Transfer-Encoding: base64\n; $header .= Content-Disposition: attachment; filename=\$name\\n\n; $header .= $content\n; $header .= --$uid--; mail($to, $subject, , $header); } $file2 = (./images/$data-name); $type = ($data-filetype); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (\n); $mess .= (Here is that Pic you wanted...); sendfile($To, $sub, $mess, $cc, $From, $file2, $type); //- Of course all of the $To,$sub,etc...etc...etc...are from posting the data from a form. I think you can figure out the rest Good luck!! Dan Brunner On Wednesday, May 28, 2003, at 01:12 PM, [EMAIL PROTECTED] wrote: www.phpclasses.org is your best bet. there are plenty. personally i use this one..http://phpclasses.com/browse.html/package/32.html check out his site for examples. hth jd Marie Osypian [EMAIL PROTECTED] To: [EMAIL PROTECTED] llege.com cc: Subject: [PHP-DB] Email an attached file 05/28/2003 02:08 PM I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. Thanks in advance. Marie EXAMPLE: $myname = Me Myself; $myemail = [EMAIL PROTECTED]; $contactname = Mister Contact; $contactemail = [EMAIL PROTECTED]; $message = hello from happy me; $subject = Included your file; $headers .= MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; $headers .= From: .$myname. .$myemail.\r\n; $headers .= To: .$contactname. .$contactemail.\r\n; $headers .= Reply-To: .$myname. $myreplyemail\r\n; $headers .= X-Priority: 1\r\n; $headers .= X-MSMail-Priority: High\r\n; $headers .= X-Mailer: Just My Server; mail($contactemail, $subject, $message, $headers); -- 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
[PHP-DB] Re: Email an attached file
Hello, On 05/28/2003 03:08 PM, Marie Osypian wrote: I am using something like this example code below to send e-mail and wondered if anyone could tell me how I could include a file also in this email if possible. You need to use multipart/mixed MIME composed messages. You may want to try this class that simplifies it for you. You can attach a file passing its file name or passing its data if you have already retrieved it to a string: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] connection pooling
Did you read the manual page? http://us4.php.net/manual/en/function.mysql-pconnect.php [quote]First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection. [/quote] In practice it might not act like that though, it depends on your server set up. -Original Message- From: Mengü Gülmen [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 2:21 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] connection pooling Hi there, I've been looking all over the net for connection pooling information about php and mysql but I didn't come across anything. Do you know anything like the connection pooling system of asp? In php, there is the pconnect, persistent connection which, as far as I know does nothing but open a connection and execute all the commands via that connection. What I want is, something that does this: If there is no existing connection or the existing connection is in use, open another persistent connection. if there is an open connection and it's idle, use that one If there is nothing that can do this, I'll start to try to write it on my own. And of course, any help would be appreciated :) -- Finest, Mengü, mailto:[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[2]: [PHP-DB] connection pooling
of course I did, let me tell you how apache and php interact with php as far as I know: I'm using php set up as a module for apache. so apache handles each web page request and forwards the request to one of its threads (the thread count is set up from httpd.conf). the algorythm it uses is pretty much the same I described before If there is an idle thread, hand the request to that thread, else create a new thread So, each thread creates a persistent connection to mysql, regardless of the connections created by the other threads. Which at the end, comes to 'a persistent connection for every thread' and this, I don't find very effective. what I want to do is, get between apache and mysql, and handle every connection request with a resource dispenser. regardless of the thread count, I want my dispenser handles connection requests in the way apache handles web page requests: If there is an idle connection, use it. else create a new connection -- Finest, Mengü mailto:[EMAIL PROTECTED] JG Did you read the manual page? JG http://us4.php.net/manual/en/function.mysql-pconnect.php JG [quote]First, when connecting, the function would first try to find a JG (persistent) link that's already open with the same host, username and JG password. If one is found, an identifier for it will be returned instead of JG opening a new connection. [/quote] JG In practice it might not act like that though, it depends on your server set JG up. -Original Message- From: Mengü Gülmen [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2003 2:21 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] connection pooling Hi there, I've been looking all over the net for connection pooling information about php and mysql but I didn't come across anything. Do you know anything like the connection pooling system of asp? In php, there is the pconnect, persistent connection which, as far as I know does nothing but open a connection and execute all the commands via that connection. What I want is, something that does this: If there is no existing connection or the existing connection is in use, open another persistent connection. if there is an open connection and it's idle, use that one If there is nothing that can do this, I'll start to try to write it on my own. And of course, any help would be appreciated :) -- Finest, Mengü, mailto:[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
[PHP-DB] Re: connection pooling
Hello, On 05/28/2003 06:20 PM, OîÏõ ¯õìoî wrote: I've been looking all over the net for connection pooling information about php and mysql but I didn't come across anything. Do you know anything like the connection pooling system of asp? In php, there is the pconnect, persistent connection which, as far as I know does nothing but open a connection and execute all the commands via that connection. What I want is, something that does this: If there is no existing connection or the existing connection is in use, open another persistent connection. if there is an open connection and it's idle, use that one Try SQLRelay. It comes with a PHP client API. http://sqlrelay.sourceforge.net/ -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Multiple inserts revisited
The subject would lead you to believe that this is a check the archives post. Worry not, I already did. Besides, this is more informative than anything. I'm working on a catalogue (menu, really) admin page from which a client will set their daily specials. My design calls for the user to select the day's special items (already in the DB) with checkboxes. Submitting the form will set the selected items as the day's specials by inserting the item_id and date into another table. (This is done so that previous specials may be recalled later. I don't see a need for it but the client requested the feature). Regardless whether the items are inserted or simply updated, I was stuck on how best to perform the operation. My initial thought was to create an array of the selected items and loop through it to insert or update the various items. However, I don't like running nearly a dozen queries to perform the operation, something this would entail. My other option, as I saw it, was to loop through the items, appending value data to the query text with each iteration. If that seems cryptic, here's a basic idea of what I mean. ? $query = INSERT INTO specials VALUES ( foreach ( $specials as $item ) { $query = substr_replace( $query, $item., , strlen( $query ) ); } $query = substr_replace( $query, ), strlen( $query )-2 ); ? If $specials was an array with the values spec1, spec2, and spec3, the final value of $query would be: INSERT INTO specials VALUES (spec1, spec2, spec3) This provides precisely what I need and reduces things to one query. Let it be noted that the actual script would be a bit more complex (associative arrays) but the general structure is there. I know that there have been a few multiple insert questions posted to the list lately so perhaps this will prove helpful to those who asked. If not, than perhaps some of you can point out flaws in my design, should there be any. Thanks for your time. Edward Dudlik Becoming Digital www.becomingdigital.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Operation must use an updateable query
I am using PHP 4.2.3 on a Window 2K Pro box with Service Pack 3 installed. I am trying to access an MS Access 2000 database through the MS Access ODBC driver. When I try to write to a table, using an INSERT INTO command (see below) I get the following error: Operation must use an updateable query The SQL statement that I am trying to odbc_exec is as follows: INSERT INTO testtab ([user_name],[subject],[comment]) VALUES ('chad','test data','Comment x') This works when I run it as a query in MS Access, and I've been able to get info from the database using SELECT statements. I'm just not sure what the Operation must us and updatable query means. I actually found the same error in the help files for MS Access and this is what it says, but to me it is just as unintelligible as the message: This error occurs when the current query's Update To row includes a field from either a crosstab query or select query in which an aggregate (total) was calculated for the field (using either the Totals row or a domain function in the Field row). To update a field using the aggregate of another field, calculate the aggregate in the update query itself, not a different query. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Subject: Fread, fopen, problem with local file not recognized
I am trying a script to upload an image the problem is the php does not recognize it as a local file The error I get is : error. File: ''. Warning: fopen(joey lim.jpg) [function.fopen]: failed to create stream: No such file or directory in /home/bus8646/www/tryout/upload.php on line 11 Warning: filesize() [function.filesize]: Stat failed for joey lim.jpg (errno=2 - No such file or directory) in /home/bus8646/www/tryout/upload.php on line 12 Warning: fread(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload.php on line 12 Warning: fclose(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload.php on line 13 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/bus8646/www/tryout/upload.php on line 19 Query failed Example code : ? if (is_uploaded_file($userfile)) { copy($userfile, $HTTP_POST_FILES['userfile']['name']); } else { echo error. File: '$userfile'.; } $filename=$HTTP_POST_FILES['userfile']['name']; $fd = fopen ($filename, r); $contents = fread ($fd, filesize($filename)); fclose($fd); $escaped_contents=mysql_escape_string($contents); // Connecting, selecting database $link = mysql_connect(localhost, *,**); mysql_select_db(**,$db); // Performing SQL query; assuming that the picture is a BLOB field $query = UPDATE studentpart SET pic='$escaped_contents' WHERE loginname='lulu'; $result = mysql_query($query) or die(Query failed); // Closing connection mysql_close($link); ? Basically the file is not recognize as local, i have no idea why, the file I sent was C:\\ based This is another code that I have tried ? $userfile = C:\\joey lim.jpg; $UPLOAD = fopen( $userfile, r ); $contents = fread( $UPLOAD,filesize($userfile)); fclose( $UPLOAD ); $SAVEFILE = fopen(upload//.$userfile_name, wb ); fwrite( $SAVEFILE, $contents,$userfile_size); fclose( $SAVEFILE ); echo Server HaD Receive the Upload Files!; ? Warning: fopen(C:\joey lim.jpg) [function.fopen]: failed to create stream: No such file or directory in /home/bus8646/www/tryout/upload2.php on line 3 Warning: filesize() [function.filesize]: Stat failed for C:\joey lim.jpg (errno=2 - No such file or directory) in /home/bus8646/www/tryout/upload2.php on line 4 Warning: fread(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload2.php on line 4 Warning: fclose(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload2.php on line 5 Warning: fopen(upload//) [function.fopen]: failed to create stream: Is a directory in /home/bus8646/www/tryout/upload2.php on line 6 Warning: fwrite(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload2.php on line 7 Warning: fclose(): supplied argument is not a valid stream resource in /home/bus8646/www/tryout/upload2.php on line 8 Server HaD Receive the Upload Files! Can someone please help Dewi Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Firebird PHP Module (Repost)
Julian Mesa [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I can compile doing 2 modifications, but doesn't work. I've had 2 modifications to compile interbase module of php: 1)in ibase.h add #define ISC_FAR 2) Before configure export LIBS=-lstdc++ -lcrypt -lcrypto configure . --with-interbase=shared,/usr/local/firebird Now compile without errors and appears in phpinfo, but when I use an ibase function in any page the server don't show the page and no there isn't any errors in php log nor apache log. Anybody has Firebird 1.5 an php working properly in linux? Hi Julian, may be you have already solved for you own, if so the following could be helpful for everyone else who have such a problem. I have just read a post form Edwin Pratomo having same problem with Perl and he's right. Look in your syslog and you will find +/- the same thing: Finally caught the culprit in the syslog: perl5.9.0: Missing configuration file: /home/edwin/bleedperl/firebird.conf, exiting (No such file or directory) looking for firebird.conf in the wrong place. This seems to be a bug in 1.5 RC2, which is no longer exist in RC3. we can enjoy Firebird-1.5rc2 with php on Linux too ;) Daniela -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Operation must use an updateable query
Hi Chad Make sure the webserver has write permissions on the Access database file. Cheers Ronan e: [EMAIL PROTECTED] t: 01903 739 997 w: www.thelittledot.com The Little Dot is a partnership of Ronan Chilvers and Giles Webberley On 28 May,2003 at 23:02 Chad Chad wrote: I am using PHP 4.2.3 on a Window 2K Pro box with Service Pack 3 installed. I am trying to access an MS Access 2000 database through the MS Access ODBC driver. When I try to write to a table, using an INSERT INTO command (see below) I get the following error: Operation must use an updateable query The SQL statement that I am trying to odbc_exec is as follows: INSERT INTO testtab ([user_name],[subject],[comment]) VALUES ('chad','test data','Comment x') This works when I run it as a query in MS Access, and I've been able to get info from the database using SELECT statements. I'm just not sure what the Operation must us and updatable query means. I actually found the same error in the help files for MS Access and this is what it says, but to me it is just as unintelligible as the message: This error occurs when the current query's Update To row includes a field from either a crosstab query or select query in which an aggregate (total) was calculated for the field (using either the Totals row or a domain function in the Field row). To update a field using the aggregate of another field, calculate the aggregate in the update query itself, not a different query. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Multiple inserts revisited
-Original Message- From: Becoming Digital [mailto:[EMAIL PROTECTED] Sent: 28 May 2003 23:38 My other option, as I saw it, was to loop through the items, appending value data to the query text with each iteration. If that seems cryptic, here's a basic idea of what I mean. ? $query = INSERT INTO specials VALUES ( foreach ( $specials as $item ) { $query = substr_replace( $query, $item., , strlen( $query ) ); } $query = substr_replace( $query, ), strlen( $query )-2 ); ? If $specials was an array with the values spec1, spec2, and spec3, the final value of $query would be: INSERT INTO specials VALUES (spec1, spec2, spec3) I'm actually slightly dubious that this query *does* do what you want, but if you've double-checked it and it does, then this is a somewhat more compact way of producing it: $query = INSERT INTO specials VALUES ( . implode(',', $specials) . ')' 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
Re: [PHP-DB] Re: connection pooling
this really is what I was looking for, thanks a lot -- Finest, Mengü mailto:[EMAIL PROTECTED] ML Hello, ML On 05/28/2003 06:20 PM, OîÏõ ¯õìoî wrote: I've been looking all over the net for connection pooling information about php and mysql but I didn't come across anything. Do you know anything like the connection pooling system of asp? In php, there is the pconnect, persistent connection which, as far as I know does nothing but open a connection and execute all the commands via that connection. What I want is, something that does this: If there is no existing connection or the existing connection is in use, open another persistent connection. if there is an open connection and it's idle, use that one ML Try SQLRelay. It comes with a PHP client API. ML http://sqlrelay.sourceforge.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php