[PHP-DB] Re: MySQL, PHP, and XML
Hello, On 06/11/2003 11:53 PM, [EMAIL PROTECTED] wrote: Is there an automatic way to insert an XML file into a MySQL DB through say, Load Data InFILE? Or does one have to Pick apart the XML with PHP and insert data into the fields one by one, record by record? You may want to try this class: Class: MySQL to XML - XML to MySQL http://www.phpclasses.org/mysql_xml -- 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] Re: MySQL, PHP, and XML
Hello, On 06/11/2003 11:53 PM, [EMAIL PROTECTED] wrote: Is there an automatic way to insert an XML file into a MySQL DB through say, Load Data InFILE? Or does one have to Pick apart the XML with PHP and insert data into the fields one by one, record by record? You may want to try this class: Class: MySQL to XML - XML to MySQL http://www.phpclasses.org/mysql_xml -- 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] MySQL, PHP, and XML
A quick google search produced this: Creating XML from MySQL (it also talks about importing XML) http://www.zdnet.com.au/builder/architect/database/story/0,234918,20266023,00.htm On Wed, 11 Jun 2003 21:53:56 -0500, [EMAIL PROTECTED] wrote: > Is there an automatic way to insert an XML file into a MySQL DB through say, > Load Data InFILE? > > Or does one have to Pick apart the XML with PHP and insert data into the > fields one by one, record by record? > > /T > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php --- Listserv only address. Jeff Shapiro -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL, PHP, and XML
Is there an automatic way to insert an XML file into a MySQL DB through say, Load Data InFILE? Or does one have to Pick apart the XML with PHP and insert data into the fields one by one, record by record? /T -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP web templates?
The second two sites are almost definitely Nuke jobs. You could take a glimpse at the code and you'd know right away. If you want some good nuke theme sites, check phpnuke.org for resources, or do a Google search. One of my favourites (from when I had to use nuke for a project) is mtechnik.net. I won't "burn" you this time, but try to make sure your future posts to this list are actually related to database stuff. Thanks. Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: "Steve B." <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, 11 June, 2003 17:44 Subject: [PHP-DB] PHP web templates? Hi I'm working on the site http://www.handheldwarez.com I really like these sites style of table cells and borders etc... http://tribes.sierra.com/ http://www.planetrenegades.com/modules.php?name=Web_Links&l_op=MostPopular http://www.tribes2maps.com/ I've seen PHP nuke templates and am thinking that is what these sites are? Does anyone have a favorite open source template spot? I'd like a nice metal look like those sites. In the past I took graphics from php nuke free site and make my own tablecell.php that prints nice boxes. That is in use at http://www.northcountyrc.com if you wonder what I'm talking about. Please don't burn me I'm newb and have little art skill but decent photoshop knowledge. Any help, links is much appreciated thanks! - Do you Yahoo!? Free online calendar with sync to Outlook(TM). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP/MySQL beginner group project
Site: http://www.handheldspecs.com Benefit for helping: Better your PHP/MySQL Know what color/java/phone/game/handheld/mp3/radio/bluetooth to buy (yes Nokia-Ngage does all this) Link on front page of your choice MySQL people aren't necessarily PHP programmers. The site is in PHP so I picked here. If this project is not welcome here pls tell me where to post since it is php/mysql and in php and I apologize now to hope stop the abuse :) If you see the site you know it has sorry db design. My friend suggested this: use three tables. At first glance, it may seem more complicated, but will make your work much easier in the long run. HandHeldNames ID (integer, automatically assigned) Name (String, unique) Fields ID (integer, automatically assigned) Name (String, unique) Type (if necessary. There are several ways of doing this) HandHeldSpecs Name (integer, joined to the ID of HandHeldNames) Field (integer, joined to the ID of Fields table) Value (String. There are several ways of doing this, actually) For instance, what you currently have on the handheldspecs.com site would have the following values HandHeldNames ID | Name 1 | Motorola T720 2 | Nokia 3 | Emerson Fields ID | Name 1 | Screen Width 2 | Screen Height 3 | Pixelsx 4 | Pixelsy 5 | Java Support 6 | Color 7 | Bandwidth 8 | image HandHeldSpecs Name | Field | Value 1| 1 | 1 1| 2 | 2 1| 3 | 320 1| 4 | 200 1| 5 | yes (or 1 or however you want to represent booleans) 1| 6 | yes 1| 7 | 19 1| 8 | (the image file name, for instance) ... I like this very much. It relates to the posts about generated select boxes. It would be real easy to add info to it and it is a fun newbie project for me to learn php/mysql as I can barely connect and make queries. thx. please lets be happy friends. - Do you Yahoo!? Free online calendar with sync to Outlook(TM).
[PHP-DB] PHP web templates?
Hi I'm working on the site http://www.handheldwarez.com I really like these sites style of table cells and borders etc... http://tribes.sierra.com/ http://www.planetrenegades.com/modules.php?name=Web_Links&l_op=MostPopular http://www.tribes2maps.com/ I've seen PHP nuke templates and am thinking that is what these sites are? Does anyone have a favorite open source template spot? I'd like a nice metal look like those sites. In the past I took graphics from php nuke free site and make my own tablecell.php that prints nice boxes. That is in use at http://www.northcountyrc.com if you wonder what I'm talking about. Please don't burn me I'm newb and have little art skill but decent photoshop knowledge. Any help, links is much appreciated thanks! - Do you Yahoo!? Free online calendar with sync to Outlook(TM).
Re: [PHP-DB] Gnarley drop-down db problem
Please disregard. I found an idiotic typo in my code ;-) Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] new memeber
Hi all, I'm a new member to this mailing list and I thought I'd introduce myself. Well, that's not completely true, I've been a member of this list in the past under a different address, but that was at least a year ago. Anyway, I'm a 'media architect' based in Warrington in the UK.I'm 20 years old and I've been coding in PHP for a few years now. I've just started a new job which involves a vast amount of PHP programming, so I thought it a good move to subscribe to this list. I also hope I can help others with problems. I specialise in dynamic, database driven sites and think that PHP is one of the most versatile and user friendly programming languages available. Best Regards, J -- Jamie Saunders Media Architect [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Relationships in MySQL
> Hi every1...I'm new to this list and hope find it funny... Welcome to the PHP list. Your question has nothing to do with PHP. Did you mean to post this to the MySQL list, perhaps?? :) > A question that maybe answered sometime ago: > > How to create relationships between tables in MySQL? > > I used a front-end exe called SQLyog for MySQL DBs, it didn't allow me to do so, and didn't allow to convert tables and DBs into InnoDBs > > any idea? Look in the MySQL documentation at the InnoDB table format. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Relationships in MySQL
Hi every1...I'm new to this list and hope find it funny... A question that maybe answered sometime ago: How to create relationships between tables in MySQL? I used a front-end exe called SQLyog for MySQL DBs, it didn't allow me to do so, and didn't allow to convert tables and DBs into InnoDBs any idea? FAW - Do you Yahoo!? Free online calendar with sync to Outlook(TM).
RE: [PHP-DB] simple date formatting?
Building off of one of John Holmes's posts from yesterday: $f_date = date('n/d/Y',strtotime($yourDBdate)); should do the trick. Hope this helps. Rich > -Original Message- > From: Steve B. [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 11, 2003 2:53 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] simple date formatting? > > > Hi I'm looking to format a date but all I find is this date() > function and it appears to be for > current date? > > My variable $dbrec["ListDate"] is printing: > 4/30/2003 0:00:00 > > It needs to print > 4/30/2003 > > Am I on the right track to try to do a (with right parameters) > > $formatted_date = date("M D Y",$dbrec["ListDate"]); > or > $formatted_date = date_format("M D Y",$dbrec["ListDate"]); > > Thanks > Current code just chops it off: > print " color='white'>".substr($dbrec["ListDate"],0,9).""; > > > __ > Do you Yahoo!? > Yahoo! Calendar - Free online calendar with sync to Outlook(TM). > http://calendar.yahoo.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
[PHP-DB] simple date formatting?
Hi I'm looking to format a date but all I find is this date() function and it appears to be for current date? My variable $dbrec["ListDate"] is printing: 4/30/2003 0:00:00 It needs to print 4/30/2003 Am I on the right track to try to do a (with right parameters) $formatted_date = date("M D Y",$dbrec["ListDate"]); or $formatted_date = date_format("M D Y",$dbrec["ListDate"]); Thanks Current code just chops it off: print "".substr($dbrec["ListDate"],0,9).""; __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Gnarley drop-down db problem
I have a user maintenance script. In the address maintenance page there is a drop down for the country entry. First, I retrieve the address info from a MySQL table. Globals are off, so I initialize the variables in the input with $country=$_GET['country']. In the country drop down I have >United States and so forth for each country. This works beautifully, except that changes are not saved from this and sent to the database. I have, in the validation script (an included script), an initialization of the variables as $country = $_POST['country'] for later use since it makes for shorter coding later in the routines. Can anybody help with ideas about how I can capture the change to the drop down country entry? Or, why is the original value passed instead of the new one? I suspect my need to initialize with the $_GET, but I can't figure out how to both get the value from the query string and then send the changed value in the drop down. TIA, Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] Apache to compile PHP and Ruby languages in the same document?
Yes, I understand about PHP, and I would assume Ruby also executes on the server - thus you would have primarily one or the other generating the page. I don't see how both can execute simultaneously, without one of them calling the other. Miles At 02:15 PM 6/11/2003 -0400, John R Wunderly wrote: At 02:56 PM 6/11/2003 -0300, Miles Thompson wrote: Don't know, but it doesn't make sense to me -- Apache executes scripts based on the file extension, how can it process both languages? A possible work around would be to have the Ruby program exec()'d within PHP. Alternately, do Ruby pages, but embed PHP as PHP is presently embedded in HTML with opening closing tags. How you tell Ruby to exec the PHP I don't know. The PHP is executed on the server before the HTML is sent to the browser. A possible difficulty is if the PHP is being executed in *SAFE* mode. Miles At 12:19 PM 6/11/2003 -0500, you wrote: Hello, I'm trying to create one document with PHP and Ruby scripts in the same document. Is this possible? I've tried to configure mod_ruby to compile php documents as well but when I do that PHP doesn't work. Is it possible to have 2 languages in the same document? -- Keith -- PHP General 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] Re: [PHP] Apache to compile PHP and Ruby languages in the same document?
At 02:56 PM 6/11/2003 -0300, Miles Thompson wrote: Don't know, but it doesn't make sense to me -- Apache executes scripts based on the file extension, how can it process both languages? A possible work around would be to have the Ruby program exec()'d within PHP. Alternately, do Ruby pages, but embed PHP as PHP is presently embedded in HTML with opening closing tags. How you tell Ruby to exec the PHP I don't know. The PHP is executed on the server before the HTML is sent to the browser. A possible difficulty is if the PHP is being executed in *SAFE* mode. Miles At 12:19 PM 6/11/2003 -0500, you wrote: Hello, I'm trying to create one document with PHP and Ruby scripts in the same document. Is this possible? I've tried to configure mod_ruby to compile php documents as well but when I do that PHP doesn't work. Is it possible to have 2 languages in the same document? -- Keith -- PHP General 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: [PHP] Apache to compile PHP and Ruby languages in the same document?
Don't know, but it doesn't make sense to me -- Apache executes scripts based on the file extension, how can it process both languages? A possible work around would be to have the Ruby program exec()'d within PHP. Alternately, do Ruby pages, but embed PHP as PHP is presently embedded in HTML with opening closing tags. How you tell Ruby to exec the PHP I don't know. Miles At 12:19 PM 6/11/2003 -0500, you wrote: Hello, I'm trying to create one document with PHP and Ruby scripts in the same document. Is this possible? I've tried to configure mod_ruby to compile php documents as well but when I do that PHP doesn't work. Is it possible to have 2 languages in the same document? -- Keith -- PHP General 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 confirmation?
Keep the context of the email in a variable, add the details of the product in each loop. Then you can call mail() with the complete order information. PS. Don´t you think it´s better to query the db only once asking the details for all the products ordered? Bruno Pereti. - Original Message - From: "Boa Constructor" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 11, 2003 2:01 PM Subject: [PHP-DB] Email confirmation? > Greetings every1 I'm wondering how I can send the details of an > order to an email address. I have a foreach loop which loops through an > array and each time round the loop it runs a query on the database to get > product details. If for instance they ordered 5 different items then I > would need to loop 5 times to get all the product information. The way I > see it, I can't make a call to the mail() function within the foreach loop > as that would send out an email for each product ordered. > > Any ideas how to send all the order information all in one email? > > Cheers for any ideas, > > Graeme :) > > > -- > 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] Email confirmation?
Greetings every1 I'm wondering how I can send the details of an order to an email address. I have a foreach loop which loops through an array and each time round the loop it runs a query on the database to get product details. If for instance they ordered 5 different items then I would need to loop 5 times to get all the product information. The way I see it, I can't make a call to the mail() function within the foreach loop as that would send out an email for each product ordered. Any ideas how to send all the order information all in one email? Cheers for any ideas, Graeme :) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: forms with php/mysql
try http://www.hotscripts.com/PHP/Tips_and_Tutorials/User_Authentication/ Philippe Rousselot wrote: Hi, I need for an association to create a form using php/mysql. If I can understand php, I am not a coder, so if someone had the code I need, I would really be greatful. I need : 1. on a page someone identify himself or register to the service using a form where the person enter name, email(username) and password. 2. once registered, the person can access a secured zone containing a form 3. the persone can fill the form, abandon half way and save the result, then come back and have the previously recorded information appearing again. all data need to be in a Mysql database. Thank you very much for your help. Philippe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Now, how about Roman Numerals?
Hi, Hugh-- Thanks for both scripts! They are absolutely what I needed for my relatively simple case and they now work great. While I was thrashing around in my search for a conversion script, I found a number of items that were out there in the realm of Javascript and postgresql, etc. They were inscrutable to me, but I believe that some of them were coming to grips with the finer points of roman numeral conversion. While I cannot be a good judge, it sure seemed to me that this fellow had covered all bases: http://www.onlineconversion.com/roman_numerals_advanced.htm Hope this is of some contribution to the general good. I am amazed now to think what certain database software that blithely converts roman-int-roman is actually doing behind the scenes! --Dave Shugarts > "Richard Hutchins" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Here's a rundown of what the script is doing based on your input: >> >> If you pass in the number 155, here are the calculations: >> $m = $num / 1000; //$m will be equal to .155 >> $c = ($num % 1000) / 100; //$c will be equal to 1.55 >> $x = ($num % 100) / 10; //$x will be equal to 5.5 >> $i = $num % 10; //$i will be equal to 5 >> [snip] > > Yes, that's exactly the problem... I assumed > integer-only input and casting. Here is a fixed > (tested) version: > > > > function RomanDigit($dig, $one, $five, $ten) { > switch($dig) { > case 0:return ""; > case 1:return "$one"; > case 2:return "$one$one"; > case 3:return "$one$one$one"; > case 4:return "$one$five"; > case 5:return "$five"; > case 6:return "$five$one"; > case 7:return "$five$one$one"; > case 8:return "$five$one$one$one"; > case 9:return "$one$ten"; > } > } > > function IntToRoman($num) { > $num = (int) $num; > if (($num < 1) || ($num > 3999)) > return("No corresponding Roman number!"); > > $m = (int) ($num * 0.001); $num -= $m*1000; > $c = (int) ($num * 0.01); $num -= $c*100; > $x = (int) ($num * 0.1);$num -= $x*10; > $i = (int) ($num); > > // echo "m = $m, c = $c, x = $x, i = $i "; > > return( > RomanDigit($m, 'M', '', '') > . RomanDigit($c, 'C', 'D', 'M') > . RomanDigit($x, 'X', 'L', 'C') > . RomanDigit($i, 'I', 'V', 'X') > ); > } > > ?> > > > and my test script: > > > include("to_roman.php"); > > $test = array( 8, 19, 155, 980, 9.8, -3, 3999, 4000, "abc", "", array() ); > > foreach($test as $num) > echo "$num => ".IntToRoman($num).""; > > ?> > > > -- > Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada > v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ > PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Posting the results of a query to an email
on 11/6/03 4:09 pm, mike karthauser at [EMAIL PROTECTED] wrote: > I want to select item_code, qty from cart where cookie_id = > $_COOKIE["cartId"] > > //the above select needs work > > And then email these to the client which I would do using php's mail > function. Partially answering my own question: $result = mysql_query("select ITEM_CODE, ITEM_TITLE from cart inner join products on cart.item_id = products.ITEM_ID where cart.cookie_id = '" . GetCartId() . "' order by products.ITEM_TITLE asc", $db); This then gives me a result set. What would be the best way to extract the results to an emailable format, given that there could be one or many items in the cart table? Thanks -- Mike Karthauser Managing Director - Brightstorm Ltd Email >> [EMAIL PROTECTED] Web >> http://www.brightstorm.co.uk Tel >> 0117 9426653 (office) 07939 252144 (mobile) Snailmail >> Unit 8, 14 King Square, Bristol BS2 8JJ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Now, how about Roman Numerals?
Now that's sweet, Hugh. Just looked at it in the browser. Nice conversion. You should publish this as a class so it's available from this point forward. Rich > -Original Message- > From: Hugh Bothwell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 11, 2003 11:19 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Re: Now, how about Roman Numerals? > > > "Richard Hutchins" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Here's a rundown of what the script is doing based on your input: > > > > If you pass in the number 155, here are the calculations: > >$m = $num / 1000; //$m will be equal to .155 > >$c = ($num % 1000) / 100; //$c will be equal to 1.55 > >$x = ($num % 100) / 10; //$x will be equal to 5.5 > >$i = $num % 10; //$i will be equal to 5 > >[snip] > > Yes, that's exactly the problem... I assumed > integer-only input and casting. Here is a fixed > (tested) version: > > > > function RomanDigit($dig, $one, $five, $ten) { > switch($dig) { > case 0:return ""; > case 1:return "$one"; > case 2:return "$one$one"; > case 3:return "$one$one$one"; > case 4:return "$one$five"; > case 5:return "$five"; > case 6:return "$five$one"; > case 7:return "$five$one$one"; > case 8:return "$five$one$one$one"; > case 9:return "$one$ten"; > } > } > > function IntToRoman($num) { > $num = (int) $num; > if (($num < 1) || ($num > 3999)) > return("No corresponding Roman number!"); > > $m = (int) ($num * 0.001); $num -= $m*1000; > $c = (int) ($num * 0.01); $num -= $c*100; > $x = (int) ($num * 0.1);$num -= $x*10; > $i = (int) ($num); > > // echo "m = $m, c = $c, x = $x, i = $i "; > > return( >RomanDigit($m, 'M', '', '') > . RomanDigit($c, 'C', 'D', 'M') > . RomanDigit($x, 'X', 'L', 'C') > . RomanDigit($i, 'I', 'V', 'X') > ); > } > > ?> > > > and my test script: > > > include("to_roman.php"); > > $test = array( 8, 19, 155, 980, 9.8, -3, 3999, 4000, "abc", > "", array() ); > > foreach($test as $num) > echo "$num => ".IntToRoman($num).""; > > ?> > > > -- > Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada > v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ > PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ > > > > > -- > 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: Now, how about Roman Numerals?
"Richard Hutchins" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here's a rundown of what the script is doing based on your input: > > If you pass in the number 155, here are the calculations: >$m = $num / 1000; //$m will be equal to .155 >$c = ($num % 1000) / 100; //$c will be equal to 1.55 >$x = ($num % 100) / 10; //$x will be equal to 5.5 >$i = $num % 10; //$i will be equal to 5 >[snip] Yes, that's exactly the problem... I assumed integer-only input and casting. Here is a fixed (tested) version: 3999)) return("No corresponding Roman number!"); $m = (int) ($num * 0.001); $num -= $m*1000; $c = (int) ($num * 0.01); $num -= $c*100; $x = (int) ($num * 0.1);$num -= $x*10; $i = (int) ($num); // echo "m = $m, c = $c, x = $x, i = $i "; return( RomanDigit($m, 'M', '', '') . RomanDigit($c, 'C', 'D', 'M') . RomanDigit($x, 'X', 'L', 'C') . RomanDigit($i, 'I', 'V', 'X') ); } ?> and my test script: "; ?> -- Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Posting the results of a query to an email
Hi, I have been building up a store which now has catalogue and persistant shopping cart which I now want to submit the results (the order) to an email for processing. I have a mysql db called 'cart' that holds: Cart_id, cookie_id, item_id, and quantity. I have a 'products' table which contains: item_id, item_code, item_title, item_price etc. I want to select item_code, qty from cart where cookie_id = $_COOKIE["cartId"] //the above select needs work And then email these to the client which I would do using php's mail function. I'm currently trying to work out how to extract the contents of the cart, convert the item_id to its item_code from products and then dump the results to an email.. Can anyone provide me with some help in where to start. thanks -- Mike Karthauser Managing Director - Brightstorm Ltd Email >> [EMAIL PROTECTED] Web >> http://www.brightstorm.co.uk Tel >> 0117 9426653 (office) 07939 252144 (mobile) Snailmail >> Unit 8, 14 King Square, Bristol BS2 8JJ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Now, how about Roman Numerals?
Here's a rundown of what the script is doing based on your input: If you pass in the number 155, here are the calculations: $m = $num / 1000; //$m will be equal to .155 $c = ($num % 1000) / 100; //$c will be equal to 1.55 $x = ($num % 100) / 10; //$x will be equal to 5.5 $i = $num % 10; //$i will be equal to 5 So, when you go to pass info to the RomanDigit() function, the passed data looks like this: For reference, arguments are ($dig, $one, $five, $ten) return( RomanDigit(.155, 'M', '', '') .RomanDigit(1.55, 'C', 'D', 'M') .RomanDigit(5.5, 'X', 'L', 'C') .RomanDigit(5, 'I', 'V', 'X') ); When the RomanDigit Case($dig) control goes through and checks the $dig part of the passed in information, the only line that matches anything in the case statement is the last one where $dig is equal to 5. Using the formula in the case statement for 5: > > case 5:return "$five"; The code will look at what the data in the argument $five is and return the V. Unfortunately, that's where the function stops. It doesn't do anything to take care of the fact that the number is 155, not 5. If you use your second example of 980, here are the results: $m = $num / 1000; //$m will be equal to .980 $c = ($num % 1000) / 100; //$c will be equal to 9.8 $x = ($num % 100) / 10; //$x will be equal to 80 $i = $num % 10; //$i will be equal to 0 So, when you go to pass info to the RomanDigit() function, the passed data looks like this: For reference, arguments are ($dig, $one, $five, $ten) return( RomanDigit(.980, 'M', '', '') .RomanDigit(9.8, 'C', 'D', 'M') .RomanDigit(8, 'X', 'L', 'C') .RomanDigit(0, 'I', 'V', 'X') ); When the RomanDigit Case($dig) control goes through and checks the $dig part of the passed in information, the only line that matches anything in the case statement is the last one where $dig is equal to 8. Using the formula in the case statement for 8: > > case 8:return "$five$one$one$one"; The function will return LXXX which is the value of 8 in the tens place, or 80. I don't know exactly how to fix it, but it would seem that the key would be to get the function to drop anything to the right of the decimal point after the equation fires. In this example: RomanDigit(.980, 'M', '', '') .RomanDigit(9.8, 'C', 'D', 'M') .RomanDigit(8, 'X', 'L', 'C') .RomanDigit(0, 'I', 'V', 'X') the function would probably work because the digits are properly broken out in the last three lines: .RomanDigit(9.8, 'C', 'D', 'M') .RomanDigit(8, 'X', 'L', 'C') .RomanDigit(0, 'I', 'V', 'X') but the first line: .RomanDigit(9.8, 'C', 'D', 'M') fails because the 9.8 doesn't match any of the cases. Drop the .8 and I think it works. If you had: RomanDigit(.980, 'M', '', '') .RomanDigit(9, 'C', 'D', 'M') .RomanDigit(8, 'X', 'L', 'C') .RomanDigit(0, 'I', 'V', 'X') Then the result would be CMLXXX which, I checked, does equal 980. Am I on the right track here? Rich > -Original Message- > From: David Shugarts [mailto:[EMAIL PROTECTED] > Sent: Wednesday, June 11, 2003 9:57 AM > To: Hugh Bothwell; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Re: Now, how about Roman Numerals? > > > Hi, Hugh-- > > I am very grateful for your help and very impressed with > this, but I am not > sure that I am able to confirm that it works and I am not > competent to fix > it if it does not. Perhaps you can tell where I am going wrong. > > I stored your script as a separate php document, > RomanDigit.php. Here is > what I tested it with: > > include OERomanDigit.php¹; > > $a=8; > $b=19; > $c=155; > $d=980; > > $ar= IntToRoman($a); > $br= IntToRoman($b); > $cr= IntToRoman($c); > $dr= IntToRoman($d); > > echo ³ > a = $a and ar = $ar > b = $b and br = $br > c = $c and cr = $cr > d = $d and dr = $dr > ²; > > ?> > > > And here are the results: > > a = 8 and ar = VIII > b = 19 and br = IX > c = 155 and cr = V > d = 980 and dr = LXXX > > TIA--Dave Shugarts > > > > > function RomanDigit($dig, $one, $five, $ten) { > > switch($dig) { > > case 0:return ""; > > case 1:return "$one"; > > case 2:return "$one$one"; > > case 3:return "$one$one$one"; > > case 4:return "$one$five"; > > case 5:return "$five"; > > case 6:return "$five$one"; > > case 7:return "$five$one$one"; > > case 8:return "$five$one$one$one"; > > case 9:return "$one$ten"; > > } > > } > > > > function IntToRoman($num) { > > if (($num < 1) || ($num > 3999)) > > return("No corresponding Roman number!"); > > > > $m = $num / 1000; > > $c = ($num % 1000) / 100; > > $x = ($num % 100) / 10; > > $i = $num % 10; > > > > return( > >RomanDigit($m, 'M', '', '') > > .RomanDigit($c, 'C', 'D', 'M') > > .RomanDigit($x, 'X', 'L', 'C') > > .RomanDigit($i, 'I', 'V', 'X') > > ); > >
RE: [PHP-DB] T_String?
The function mysql_query() expects a string, so you have to put "select ..." in quote for it to be considered one string, instead of 4. Have fun, Matt. -Original Message- From: Jorge L. [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 10:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] T_String? I am getting the following error: Parse error: parse error, unexpected T_STRING in C:\Program Files\Apache Group\Apache2\htdocs\view.php on line 4 On line: $result = mysql_query(select * from guestbook) or die (mysql_error()); And I have no idea where the T_STRING is coming from. I know this is probably some little detail that I am over looking, but I would appreciate any help. _ 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] Re: Now, how about Roman Numerals?
"George Pitcher" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > That's great, but what about the reverse: Roman to Arabic? > > George in Oxford // NOTE: the order of the table is // important! I will use greedy parsing, // so (for example) IX and IV must precede // I to parse correctly. $RomanTable = array( "M" => 1000, "CM" => 900, "D" => 500, "CD" => 400, "C" => 100, "XC" => 90, "L" => 50, "XL" => 40, "X" => 10, "IX" => 9, "V" => 5, "IV" => 4, "I" => 1 ); function MatchClause($needle, $haystack) { // These two tests are probably just paranoia, // but - hey, I'm paranoid. ;-) if (strlen($haystack) < 1) return false; if (strlen($haystack) < strlen($needle)) return false; return( strncasecmp($needle, $haystack, strlen($needle)) == 0 ); } function RemoveClause($needle, $haystack) { return( substr($haystack, strlen($needle)) ); } function RomanToInt($str) { global $RomanTable; $sum = 0; do { $done = true; foreach($RomanTable as $clause => $value) if ( MatchClause($clause, $str) ) { $sum += $value; $str = RemoveClause($clause, $str); $done = false; break; } } while ($done == false); return($sum); } NOTE! This algorithm is sufficient but not complete - it will correctly translate all legal Roman-numeral strings, but cannot detect illegal strings. -- Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Now, how about Roman Numerals?
Hi, Hugh-- I am very grateful for your help and very impressed with this, but I am not sure that I am able to confirm that it works and I am not competent to fix it if it does not. Perhaps you can tell where I am going wrong. I stored your script as a separate php document, RomanDigit.php. Here is what I tested it with: b = $b and br = $br c = $c and cr = $cr d = $d and dr = $dr ²; ?> And here are the results: a = 8 and ar = VIII b = 19 and br = IX c = 155 and cr = V d = 980 and dr = LXXX TIA--Dave Shugarts > function RomanDigit($dig, $one, $five, $ten) { > switch($dig) { > case 0:return ""; > case 1:return "$one"; > case 2:return "$one$one"; > case 3:return "$one$one$one"; > case 4:return "$one$five"; > case 5:return "$five"; > case 6:return "$five$one"; > case 7:return "$five$one$one"; > case 8:return "$five$one$one$one"; > case 9:return "$one$ten"; > } > } > > function IntToRoman($num) { > if (($num < 1) || ($num > 3999)) > return("No corresponding Roman number!"); > > $m = $num / 1000; > $c = ($num % 1000) / 100; > $x = ($num % 100) / 10; > $i = $num % 10; > > return( >RomanDigit($m, 'M', '', '') > .RomanDigit($c, 'C', 'D', 'M') > .RomanDigit($x, 'X', 'L', 'C') > .RomanDigit($i, 'I', 'V', 'X') > ); > } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] array fill/sort question
Snijders, Mark wrote: 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? can you change the database format ? store the address as four ints - then you can concatenate them when you need to, and sort as you wish SELECT s_id, subnet_name, concat(subnetaddr1, '.', subnetaddr2, '.', subnetaddr3, '.', subnetaddr4) as subnetaddr ,subnetmask,dnsdomain, location, contact, ccn FROM subnets ORDER BY subnetaddr1, subnetaddr2, subnetaddr3, subnetaddr4; -- Sean -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Help Please!! Oracle/PHP connection
> -Original Message- > From: Matthew Moldvan [mailto:[EMAIL PROTECTED] > Sent: 11 June 2003 01:03 > > Have you tried the built in Oracle functions in PHP? > > http://us3.php.net/oracle That's only for Oracle up to version 7. For Oracle 8 or 9, use the OCI extension http://www.php.net/oci8. 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: Now, how about Roman Numerals?
That's great, but what about the reverse: Roman to Arabic? George in Oxford > -Original Message- > From: nabil [mailto:[EMAIL PROTECTED] > Sent: 11 June 2003 9:26 am > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Re: Now, how about Roman Numerals? > > > That's is wonderfull Hugh.. > Nabil > > "Hugh Bothwell" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > "David Shugarts" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Second poser today: > > > > > > How to use either a MySQL select statement or PHP to produce a roman > > > numeral, starting from an arabic (INT) number in a database? > > > > > > In PHP: > > > > > > function RomanDigit($dig, $one, $five, $ten) { > > switch($dig) { > > case 0:return ""; > > case 1:return "$one"; > > case 2:return "$one$one"; > > case 3:return "$one$one$one"; > > case 4:return "$one$five"; > > case 5:return "$five"; > > case 6:return "$five$one"; > > case 7:return "$five$one$one"; > > case 8:return "$five$one$one$one"; > > case 9:return "$one$ten"; > > } > > } > > > > function IntToRoman($num) { > > if (($num < 1) || ($num > 3999)) > > return("No corresponding Roman number!"); > > > > $m = $num / 1000; > > $c = ($num % 1000) / 100; > > $x = ($num % 100) / 10; > > $i = $num % 10; > > > > return( > > RomanDigit($m, 'M', '', '') > > .RomanDigit($c, 'C', 'D', 'M') > > .RomanDigit($x, 'X', 'L', 'C') > > .RomanDigit($i, 'I', 'V', 'X') > > ); > > } > > > > > > -- > > Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada > > v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ > > PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ > > > > > > > > > > -- > 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: Now, how about Roman Numerals?
That's is wonderfull Hugh.. Nabil "Hugh Bothwell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "David Shugarts" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Second poser today: > > > > How to use either a MySQL select statement or PHP to produce a roman > > numeral, starting from an arabic (INT) number in a database? > > > In PHP: > > > function RomanDigit($dig, $one, $five, $ten) { > switch($dig) { > case 0:return ""; > case 1:return "$one"; > case 2:return "$one$one"; > case 3:return "$one$one$one"; > case 4:return "$one$five"; > case 5:return "$five"; > case 6:return "$five$one"; > case 7:return "$five$one$one"; > case 8:return "$five$one$one$one"; > case 9:return "$one$ten"; > } > } > > function IntToRoman($num) { > if (($num < 1) || ($num > 3999)) > return("No corresponding Roman number!"); > > $m = $num / 1000; > $c = ($num % 1000) / 100; > $x = ($num % 100) / 10; > $i = $num % 10; > > return( > RomanDigit($m, 'M', '', '') > .RomanDigit($c, 'C', 'D', 'M') > .RomanDigit($x, 'X', 'L', 'C') > .RomanDigit($i, 'I', 'V', 'X') > ); > } > > > -- > Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada > v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+ > PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+ > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] connecting to remote interbase via odbc
Hello all, have some problems to connect my php script to a remote interbase running on W2K Server! My systems: DB-Server: W2K Server with interbase 5.x Webserver: SuSE 8.0 with apache 1.3.23 and php 4.1.0 Problem: I want to use the odbc_connect() to connect to the remote DB-Server, from the shell with isql it works! my scripts: odbc.ini: [dtm] Driver= INTERBASE Description= interbase driver Database = 192.168.2.29:d:/ES2000/DB/IBSQL/DTM/DTM.gdb User = something Password = something With_Schema = 0 Dialect= 1 Charset = Role = Nowait= 0 odbcinst.ini [INTERBASE] Description = Easysoft Driver for Interbase Driver = /usr/lib/libib7odbc.so Setup = /usr/lib/libib7odbcS.so FileUsage = 1 DontDLClose = 1 Trace = Yes Trace File = /var/log/sql-log If I do a connection from the shell with: "isql -v dtm" it works, but with the php it doesn't. my php: It fails with the errormsg: Warning: SQL error: [iODBC][Driver Manager]Specified driver could not be loaded, SQL state IM003 in SQLConnect in /www/dtm/katalog/test.php on line 8 [iODBC][Driver Manager]Specified driver could not be loaded Where line 8 is the line with: "$connection = odbc_connect('dtm','','') or die (odbc_errormsg());" Even if I declare the $db with the location of the database and username and password? Where is my fault? Maybe anbody can help me... Regards Christian -- 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