RE: [PHP-DB] Shrinking gifs.
Thank you Martin I install new gd, reconfigure php and now is running OK. But, it was a mass to realize that shortening gifs results to loss transparency(!). So I turn them all to jpegs and use the ImageCreateFromJPG instead. My code looks like this: ? $ph='photos/'.$photo; $imgReal = imagecreatefromjpeg($ph); $x = ImagesX($imgReal); $y = ImagesY($imgReal); $newX=$x*0.50; $newY=$y*0.50; $img = ImageCreate($newX,$newY); ImageCopyResized($img, $imgReal, 0, 0, 0, 0, $newX, $newY, $x, $y); ImageJPEG($img); header(Content-Type: {$img_type}); echo $img; ? -Original Message- From: Martin Norland [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 21, 2005 4:31 PM To: PHP-mailist (PHP-mailist) Subject: Re: [PHP-DB] Shrinking gifs. . nikos wrote: Hello list I'd like to make a thumbnaile list using some gifs. I use the following code but I got error (Call to undefined function: imagecreatefromgif() ). Does anybody knows what's wrong? [snip] RH-9 Linux Apache httpd-2.0.40-21.11 PHP Version 4.3.11 gd-1.8.4-11 gif support was removed from gd in 1.6*. It was re-added in 2.0.28. This is all due to the Unisys patent on the LZW compression that gifs use. short answer - you just don't have support for making gifs, it was a licensing issue at the time the software you're using was released/packaged. Upgrade gd. * funny, since gd stood for 'gif draw' originally. cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- 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: splitting CSV rows into multiple SQL inserts?
I wanted to clarify my question from yesterday, as re-reading it, it sounds quite confusing. I have a CVS file that has order header *and* line item info on each line, like: 1110,6/20/2005,Jan Doe,123 Main St,,1,Book 1116,6/22/2005,Jim Smith,44 Here St,19191980,1,CD 1116,6/22/2005,Jim Smith,44 Here St,77736222,1,Tape The above is actually two orders - one with one line item, and the 2nd with two line items. I need to insert data from those lines into two tables: insert into order_header (o_num, date, name, addr) values ('1110','6/20/2005','Jan Doe','123 Main St'), ('1116','6/22/2005','Jim Smith','44 Here St'); insert into line_items (o_num, item_num, quan, desc, line_order) values ('1110','','1','Book','1'), ('1116','19191980','1','CD','1'), ('1116','77736222','1','Tape','2'); Note the line_order field - it needs to increment per order for each line item added to the line_items table. To complicate matters a bit, I'm actually massaging the data before inserting [eg: splitting the name field from the CSV into two fields for the mysql db, formatting the date field for mysql, etc]. I'm currently doing this process via a form where a user uploads the CVS file [created with Excel, complete with the first row being made up the Excel table's header]. I currently do something like this: $fp = fopen(/tmp/.$txt_file, r); while ($line = fgets($fp,1024)) { $i++ if ($i 1) { // skip excel header row list ($o_num, $date, $name, $addr, $item_num, $quan, $desc) = csv_explode($line); // i can now print the vars, but i get duplicate header records when // there are multiple line items for a particular order. also, i // need to generate the line_order field for insertion into the // line_items table } } If I try and do any processing up where my comments are, well, the comments tell you what happen. I know I am reading this file line by line, so I can't compare order numbers [o_num] to group multiple line item orders together. So how do I go about doing that? Read the entire CSV into an array? How can that help? Any tips would be most appreciated! Thanks! /vjl/ p/s - FYI, cvs_explode() is: function csv_explode($str, $delim = ',', $qual = \) { $len = strlen($str); $inside = false; $word = ''; for ($i = 0; $i $len; ++$i) { if ($str[$i]==$delim !$inside) { $out[] = $word; $word = ''; } else if ($inside $str[$i]==$qual ($i$len $str[$i+1]==$qual)) { $word .= $qual; ++$i; } else if ($str[$i] == $qual) { $inside = !$inside; } else { $word .= $str[$i]; } } $out[] = $word; return $out; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select * from table where column 'CONTAINS' more than one value (how?)
I have no problem creating a table, using a query from my dbase table news: SELECT * FROM table where column = VALUE. However, now that most of our articles have more than one column type (i.e. instead of just technology, the column can now contain technology, politics, local. You need to normalize your tables. Make a table called columntypes, then another called articlecolumntypes. If you have an article with ID 456, and it has column types of technology (ID 5), politics (ID 15), and local (ID 34), you tie the articles table to the columntypes table using the articlecolumntypes table: articleid columntypeid - 4565 45615 45634 --df -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Shrinking gifs.
nikos a écrit dans le message But, it was a mass to realize that shortening gifs results to loss transparency(!). Yea TRUE ! The background is black ! You will get the same result when creating PNG thumbnails ! In fact imagecreate and imagecreatetruecolor both [quoted from the manual] ... returns an image identifier representing a BLACK image of size x_size by y_size. Question: Does anyone have a script / piece of code that keeps transparency after creating the thumbnail ? Regards, Nadim Attari -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: php-db Digest 20 Jun 2005 23:54:37 -0000 Issue 2992
I make part of a team where we have created a system which produces reports. The reports are produced based on selection criteria which the user sets from an oracle database. The problem we are facing is that when the users selects a big time frame the report just freezes, the status bar displays 'done' the IE (our preferred browser) window flag stops animating and report does not show anything, only a blank page. I am suspecting a time out somewhere. I am using the function set_time_limit and some of the reports did improve but still facing the problem with others. Each report has a main SQL based on which the report is generated. I am guessing setting set_time_limit prolongs the timeout of the generation of the report by php, but i am suspecting, either: 1 - The sql is taking too much time to get back with some data on which php will still time out. 2 - Some other time out exists (e.g. Apache). if so 1 can somebody advice how to set this other time out if it exists or some other way to workaround this. if so 2 do somebody knows how to override this through php or some other way to workaround this. Any feedback / ideas are very much welcomed Cosman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] RE: php-db Digest 20 Jun 2005 23:54:37 -0000 Issue 2992. .
Cosman CUSCHIERI wrote: I make part of a team where we have created a system which produces reports. The reports are produced based on selection criteria which the user sets from an oracle database. The problem we are facing is that when the users selects a big time frame the report just freezes, the status bar displays 'done' the IE (our preferred browser) window flag stops animating and report does not show anything, only a blank page. I am suspecting a time out somewhere. I am using the function set_time_limit and some of the reports did improve but still facing the problem with others. [snip] Make sure php is logging its errors somewhere, and check your apache error logs. This seems very much like the behavior I've seen when a script hits the maximum memory allowed. It's possible the first bottleneck was the processing, and the second is the memory needed. Of course, it's possible it's something else entirely - but something should be logged when the pages bail out like that. cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] RE: php-db Digest 20 Jun 2005 23:54:37 -0000 Issue 2992
once solution might be to fork a process and send that to run the sql with some big time out limit on it...then create the report save it as a file and email to the user when complete see http://ca.php.net/manual/en/function.pcntl-fork.php Bastien From: Cosman CUSCHIERI [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] RE: php-db Digest 20 Jun 2005 23:54:37 - Issue 2992 Date: Wed, 22 Jun 2005 15:29:47 +0200 I make part of a team where we have created a system which produces reports. The reports are produced based on selection criteria which the user sets from an oracle database. The problem we are facing is that when the users selects a big time frame the report just freezes, the status bar displays 'done' the IE (our preferred browser) window flag stops animating and report does not show anything, only a blank page. I am suspecting a time out somewhere. I am using the function set_time_limit and some of the reports did improve but still facing the problem with others. Each report has a main SQL based on which the report is generated. I am guessing setting set_time_limit prolongs the timeout of the generation of the report by php, but i am suspecting, either: 1 - The sql is taking too much time to get back with some data on which php will still time out. 2 - Some other time out exists (e.g. Apache). if so 1 can somebody advice how to set this other time out if it exists or some other way to workaround this. if so 2 do somebody knows how to override this through php or some other way to workaround this. Any feedback / ideas are very much welcomed Cosman -- 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] Shrinking gifs.. .
nikos wrote: Thank you Martin I install new gd, reconfigure php and now is running OK. But, it was a mass to realize that shortening gifs results to loss transparency(!). [snip] imagecolortransparent() That function will set the transparent color in an image (only one per image). If you read the description carefully it says that it will return the existing one if you don't specify a new color... so: $transparent_color = imagecolortransparent($uploaded_img); imagecolortransparent($thumbnail, $transparent_color); That should get you and Nadim what you're looking for, assuming things work as promised (I've never used it myself). If you need to work with pngs and the likes, imagecolorexactalpha / imagecolorclosestalpha - requires GD 2.01 and PHP 4.0.6 (imagecolorallocatealpha requires PHP 4.3.2 though, oddly enough) cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Subject: RE: [FIX YOUR SUBJECT !] php-db Digest 20 Jun 2005 23:54:37 -0000 Issue 2992
Hi - Suggestions : 1) Turn on error_reporting in your PHP script : ?php error_reporting(E_ALL); ? 2) Load page, and go to browser's View-Source menu, to see if you actually got malformed HTML or anything at all. Cheers - Neil From: Cosman CUSCHIERI [EMAIL PROTECTED] To: php-db@lists.php.net Date: Wed, 22 Jun 2005 15:29:47 +0200 Message-ID: [EMAIL PROTECTED] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: RE: php-db Digest 20 Jun 2005 23:54:37 - Issue 2992 I make part of a team where we have created a system which produces reports. The reports are produced based on selection criteria which the user sets from an oracle database. The problem we are facing is that when the users selects a big time frame the report just freezes, the status bar displays 'done' the IE (our preferred browser) window flag stops animating and report does not show anything, only a blank page. I am suspecting a time out somewhere. I am using the function set_time_limit and some of the reports did improve but still facing the problem with others. Each report has a main SQL based on which the report is generated. I am guessing setting set_time_limit prolongs the timeout of the generation of the report by php, but i am suspecting, either: 1 - The sql is taking too much time to get back with some data on which php will still time out. 2 - Some other time out exists (e.g. Apache). if so 1 can somebody advice how to set this other time out if it exists or some other way to workaround this. if so 2 do somebody knows how to override this through php or some other way to workaround this. Any feedback / ideas are very much welcomed Cosman CaptionKit http://www.captionkit.com : Production tools for accessible subtitled internet media, transcripts and searchable video. Supports Real Player, Quicktime and Windows Media Player. VideoChat with friends online, get Freshly Toasted every day at http://www.fresh-toast.net : NetMeeting solutions for a connected world. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: splitting CSV rows into multiple SQL inserts?
On 6/22/05, Doug Hernandez [EMAIL PROTECTED] wrote: I can't help but wonder why you're using the line_order field at all. Can't you nix it and count the number of records with each order# as a stored procedure or some such? It would make your entire order system easier. Also, you may think about capturing that first row in its own list: $fp = fopen(/tmp/.$txt_file, r) ; $headers = fgets($fp,1024) ; while( $line = fgets( $fp,1024) ) { $row[] = csv_explode($line); $table[][] = $row[] } // Now you've got your whole table in $table[][] In your csv_explode function, you can use split() to make things easier on yourself: $out[] = split(',' $line, 7) ; // Your file has 7 fields, so don't overrun that Even if you insist on calculating an order_line, you can still use split. Just push a count onto the end of the list. $out[] = $order_line ; // according to php.net, array_push() shouldn't be used I strongly urge you whack the order_line. Or maybe I can bother you to give me more info about it? It's hard to judge without being closer to the situation. Peace, Doug PS: I'm new to the list. What address will post this to the entire user group? On 6/22/05, Vince LaMonica [EMAIL PROTECTED] wrote: I wanted to clarify my question from yesterday, as re-reading it, it sounds quite confusing. I have a CVS file that has order header *and* line item info on each line, like: 1110,6/20/2005,Jan Doe,123 Main St,,1,Book 1116,6/22/2005,Jim Smith,44 Here St,19191980,1,CD 1116,6/22/2005,Jim Smith,44 Here St,77736222,1,Tape The above is actually two orders - one with one line item, and the 2nd with two line items. I need to insert data from those lines into two tables: insert into order_header (o_num, date, name, addr) values ('1110','6/20/2005','Jan Doe','123 Main St'), ('1116','6/22/2005','Jim Smith','44 Here St'); insert into line_items (o_num, item_num, quan, desc, line_order) values ('1110','','1','Book','1'), ('1116','19191980','1','CD','1'), ('1116','77736222','1','Tape','2'); Note the line_order field - it needs to increment per order for each line item added to the line_items table. To complicate matters a bit, I'm actually massaging the data before inserting [eg: splitting the name field from the CSV into two fields for the mysql db, formatting the date field for mysql, etc]. I'm currently doing this process via a form where a user uploads the CVS file [created with Excel, complete with the first row being made up the Excel table's header]. I currently do something like this: $fp = fopen(/tmp/.$txt_file, r); while ($line = fgets($fp,1024)) { $i++ if ($i 1) { // skip excel header row list ($o_num, $date, $name, $addr, $item_num, $quan, $desc) = csv_explode($line); // i can now print the vars, but i get duplicate header records when // there are multiple line items for a particular order. also, i // need to generate the line_order field for insertion into the // line_items table } } If I try and do any processing up where my comments are, well, the comments tell you what happen. I know I am reading this file line by line, so I can't compare order numbers [o_num] to group multiple line item orders together. So how do I go about doing that? Read the entire CSV into an array? How can that help? Any tips would be most appreciated! Thanks! /vjl/ p/s - FYI, cvs_explode() is: function csv_explode($str, $delim = ',', $qual = \) { $len = strlen($str); $inside = false; $word = ''; for ($i = 0; $i $len; ++$i) { if ($str[$i]==$delim !$inside) { $out[] = $word; $word = ''; } else if ($inside $str[$i]==$qual ($i$len $str[$i+1]==$qual)) { $word .= $qual; ++$i; } else if ($str[$i] == $qual) { $inside = !$inside; } else { $word .= $str[$i]; } } $out[] = $word; return $out; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Douglas Hernandez (612) 229-9684 -- Douglas Hernandez (612) 229-9684 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: splitting CSV rows into multiple SQL inserts?
I can't help but wonder why you're using the line_order field at all. Can't you nix it and count the number of records with each order# as a stored procedure or some such? It would make your entire order system easier. Also, you may think about capturing that first row in its own list: $fp = fopen(/tmp/.$txt_file, r) ; $headers = fgets($fp,1024) ; while( $line = fgets( $fp,1024) ) { $row[] = csv_explode($line); $table[][] = $row[] } // Now you've got your whole table in $table[][] In your csv_explode function, you can use split() to make things easier on yourself: $out[] = split(',' $line, 7) ; // Your file has 7 fields, so don't overrun that Even if you insist on calculating an order_line, you can still use split. Just push a count onto the end of the list. $out[] = $order_line ; // according to php.net, array_push() shouldn't be used I strongly urge you whack the order_line. Or maybe I can bother you to give me more info about it? It's hard to judge without being closer to the situation. Peace, Doug On 6/22/05, Doug Hernandez [EMAIL PROTECTED] wrote: On 6/22/05, Doug Hernandez [EMAIL PROTECTED] wrote: I can't help but wonder why you're using the line_order field at all. Can't you nix it and count the number of records with each order# as a stored procedure or some such? It would make your entire order system easier. Also, you may think about capturing that first row in its own list: $fp = fopen(/tmp/.$txt_file, r) ; $headers = fgets($fp,1024) ; while( $line = fgets( $fp,1024) ) { $row[] = csv_explode($line); $table[][] = $row[] } // Now you've got your whole table in $table[][] In your csv_explode function, you can use split() to make things easier on yourself: $out[] = split(',' $line, 7) ; // Your file has 7 fields, so don't overrun that Even if you insist on calculating an order_line, you can still use split. Just push a count onto the end of the list. $out[] = $order_line ; // according to php.net, array_push() shouldn't be used I strongly urge you whack the order_line. Or maybe I can bother you to give me more info about it? It's hard to judge without being closer to the situation. Peace, Doug PS: I'm new to the list. What address will post this to the entire user group? On 6/22/05, Vince LaMonica [EMAIL PROTECTED] wrote: I wanted to clarify my question from yesterday, as re-reading it, it sounds quite confusing. I have a CVS file that has order header *and* line item info on each line, like: 1110,6/20/2005,Jan Doe,123 Main St,,1,Book 1116,6/22/2005,Jim Smith,44 Here St,19191980,1,CD 1116,6/22/2005,Jim Smith,44 Here St,77736222,1,Tape The above is actually two orders - one with one line item, and the 2nd with two line items. I need to insert data from those lines into two tables: insert into order_header (o_num, date, name, addr) values ('1110','6/20/2005','Jan Doe','123 Main St'), ('1116','6/22/2005','Jim Smith','44 Here St'); insert into line_items (o_num, item_num, quan, desc, line_order) values ('1110','','1','Book','1'), ('1116','19191980','1','CD','1'), ('1116','77736222','1','Tape','2'); Note the line_order field - it needs to increment per order for each line item added to the line_items table. To complicate matters a bit, I'm actually massaging the data before inserting [eg: splitting the name field from the CSV into two fields for the mysql db, formatting the date field for mysql, etc]. I'm currently doing this process via a form where a user uploads the CVS file [created with Excel, complete with the first row being made up the Excel table's header]. I currently do something like this: $fp = fopen(/tmp/.$txt_file, r); while ($line = fgets($fp,1024)) { $i++ if ($i 1) { // skip excel header row list ($o_num, $date, $name, $addr, $item_num, $quan, $desc) = csv_explode($line); // i can now print the vars, but i get duplicate header records when // there are multiple line items for a particular order. also, i // need to generate the line_order field for insertion into the // line_items table } } If I try and do any processing up where my comments are, well, the comments tell you what happen. I know I am reading this file line by line, so I can't compare order numbers [o_num] to group multiple line item orders together. So how do I go about doing that? Read the entire CSV into an array? How can that help? Any tips would be most appreciated! Thanks! /vjl/ p/s - FYI, cvs_explode() is: function csv_explode($str, $delim = ',', $qual = \) { $len = strlen($str); $inside = false; $word = ''; for ($i = 0; $i $len; ++$i) {
[PHP-DB] mysql_connect() with a multi-file format
I'm new to PHP, due to having been all hard-nosed and obtuse about using Perl/CGI. I've been looking for a good way to pick up php tricks and what-nots, so I joined the list. That said, I have an immediate question. I have a multi-file script: main.php requires_once config.php, and so on. I'd like to have a data.php file that handles function wrappers for database and also establishes a connection to the db. I read in the php.net manual that the connection closes automatically when the script exits. Does this mean I can't open a db connection in one file and pass the link around from function to function? ie: require_once 'data.php'; // data.php contains a mysql_connect() // after this line, is my link closed? require_once 'blah.php' ; OR: require_once 'data.php'; // with wrapper data_connection() $save_this_link = data_connection() ; // will this work? some_function( $save_this_link ) ; //etc. -- Douglas Hernandez (612) 229-9684 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_connect() with a multi-file format
I read in the php.net manual that the connection closes automatically when the script exits. Does this mean I can't open a db connection in one file and pass the link around from function to function? No, the script you include becomes part of the main script calling the inclusion, therefore the connection stays open 'til you explicitly close it, or your main script exits. cheers -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] select * from table where column 'CONTAINS' more than one value (how?)
On Tuesday 21 June 2005 10:35 pm, Dan Fulbright wrote: I have no problem creating a table, using a query from my dbase table news: SELECT * FROM table where column = VALUE. However, now that most of our articles have more than one column type (i.e. instead of just technology, the column can now contain technology, politics, local. You need to normalize your tables. Make a table called columntypes, then another called articlecolumntypes. If you have an article with ID 456, and it has column types of technology (ID 5), politics (ID 15), and local (ID 34), you tie the articles table to the columntypes table using the articlecolumntypes table: Good point, this would be the 'Proper' way to do it. -Micah -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php