[PHP-DB] foreach problem
Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Thank you. Sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: foreach problem
$sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); Where does $entry_id come from? Maybe it's unique? Bastian -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] help with loop and query
Hi guys, Hopefully last time I need to call of you people for this report I am creating. In this report there is a multiple select box like: select name=province[] class=selectcontent size=3 multiple option value= class=selectcontentProvince/State/option option value=AK selected class=selectcontentAlaska/option option value=AB selected class=selectcontentAlberta/option option value=BC class=selectcontentBritish Columbia/option option value=CA class=selectcontentCalifornia/option option value=CO class=selectcontentColorado/option option value=CT class=selectcontentConnecticut/option /select Using this select box comparison data for each of the selected provinces where an order was placed is supposed to be displayed. For example if Alaska, Alberta and British Columbia were selected 1) Grab all cart_ids from the OrderTable for each province 2) Reference the cart_id from the OrderTable to the cart_id in the CartTable 3) Display results and products order totals for each province individually. Illustration: Product | Total Orders | Total Sold | Dollar Total Pronvince Name: Alaska Product 1 | 12 | 350 | $3215.45 Product 2 | 8 | 123 | $2143.23 Product 3 | 14 | 113 | $6412.43 Pronvince Name: Alberta Product 1 | 5 | 87 | $1215.45 Product 2 | 3 | 23 | $143.23 Product 3 | 7 | 101 | $5412.43 Pronvince Name: British Columbia Product 1 | 6 | 71 | $1015.45 Product 2 | 25 | 66 | $643.23 Product 3 | 3 | 23 | $412.43 Hopefully you can see what I am trying to do here. Here is the code I have been working this thus far.. ** CODE ** ?php foreach ($province as $value) { $provinceQuery = db_query(SELECT cart_id FROM OrderTable WHERE submitted=1 AND province='$value'); while ($provinceResult = db_fetch($provinceQuery)) { $cartid[] = $provinceResult[cart_id]; } ? tr valign=middle td class=cartlink colspan=5?php echo $value; ?/td /tr ?php $province_search = in(; for ($i=0;$icount($cartid);$i++) { $province_search .= escapeQuote($cartid[$i]); if ($i != (count($cartid) - 1)) { $province_search .= ,; } } $province_search .= ); $provinceCart = AND cart_id $province_search; $query = SELECT name, COUNT(*) AS orders, SUM(quantity) AS sold, SUM(quantity * price ) AS value FROM CartTable WHERE $query $provinceCart GROUP BY name ORDER BY $orderby DESC; $result = mysql_query($query); $total_items = 0; $total_orders = 0; $total = 0.0; while($cartResult = mysql_fetch_array($result)) { $allrows[] = $cartResult; $total_items += $cartResult['sold']; $total_orders += $cartResult['orders']; $total += $cartResult['value']; } foreach($allrows as $cartResult) { ? tr valign=middle td class=cartlink?php echo $cartResult[name]; ?/td td class=cartlink?php echo $cartResult[orders]; ?/td td class=cartlink align=right?php echo $cartResult[sold]; ?/td td class=cartlink align=right?php echo number_format($cartResult[value],2); ?/td td class=cartlink align=right?php echo number_format($cartResult[sold]*100/$total_items,1); ?%/td /tr ?php } } ? Ive been able to get the cart_ids associated with each province selected but I am having lots of trouble displaying the result FOR the selected $provinces. Can anyone help me with where I am erroring? Thanks a ton! Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: PHP - Oracle 7.3.4 - ORA-12154
I set up PHP on a Sun Solaris box a week ago (see phpinfo output below). It has oracle 7.3.4 and php 4.0.4pl1 so I'm using the --with-oracle configure option. Due to a special module we're using we're stuck with using that php version (4.0.4pl1). Couldn't you use --with-oci, even with that php version ? it's the newer and better module for oracle (both oracle 7 and 8). Look at ocilogon() function and friends. At first I was getting the ORA-12154 TNS:could not resolve service name error almost every time. I then followed the instructions to set the ORACLE_HOME and TNS_ADMIN environment variables in apaches http.conf. I've also tried using the putenv function to set the variables. I had also trouble with ora12154. I use now a workaround : when I use : $connection = OCILogon($user, $pass, $tns) or die(No Connection); for the third parameter ($tns), I don't use the name found in tnsnames.ora, but directly the entire syntax something like : (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = tcp.world) (PROTOCOL = TCP) (Host = ip address) (Port = 1521) ) (ADDRESS = (COMMUNITY = tcp.world) (PROTOCOL = TCP) (Host = ip address) (Port = 1526) ) ) (CONNECT_DATA = (SID = ORCL) ) ) Regards, Philippe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Oracle 9.2 + IIS 5.0 + Win2k server + PHP 4.3 + ADODB 3.10
$conn-NConnect('', 'usr', 'usr_pwd', 'TNSName'); # select machines from machinetable NConnect exists in adodb since version 2.43. Have you tried with PConnect() or Connect() instead of NConnect() ? they are older (october 2002), and may be they are more robust ? Is this a bug? Should I try ADODB 2.5 instead since it's listed as being more stable on the site? I use without any problem adodb 3.10, but with oracle 7.3. IMHO, I don't think adodb 2.5 would help you. Have you posted a message in http://phplens.com/lens/lensforum/topics.php?id=4 ? Regards, Philippe -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: vaiable from one page to another
- Original Message - From: J.Veenhuijsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 1:24 PM Subject: [PHP-DB] Re: vaiable from one page to another Try p.php: ?php //Not ?php echo($fname); ? Jochem Bismi Jomon wrote: hi, i hav two programs , html form name=f action=p.php mehtod=post input type=text name=fname input type=submit /form /html p.php: ?php echo($fname) ? i tried these programs and i didnt get the value of the variable in another php program. butit is not getting. one our friend told to put like echo $_post(fname) but it is also not working. now getting the error about post array. so what to do. help me regards bis -- 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] foreach problem
On Friday 07 February 2003 11:22, Sam Folk-Williams wrote: Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Any error messages? If so what does mysql_error() say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* WHERE CAN THE MATTER BE Oh, dear, where can the matter be When it's converted to energy? There is a slight loss of parity. Johnny's so long at the fair. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] foreach problem
I don't get any MySQL error... It adds the first entry_id and date exactly as it should... it seems to be acting like entry_date is not an array, but when I use the same foreach loop to echo the contents of entry_date it echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same code to insert checkbox data in a different form, so... I'm kinda stumped. Sam Jason Wong [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Friday 07 February 2003 11:22, Sam Folk-Williams wrote: Hi, I can't figure out why this won't work: foreach($event_date as $val) { $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES (\$entry_id\, \$val\); $result = @mysql_query($sql2,$connection) or die (Problem executing foreach database query.); } $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first dae in the array, but none of the others... am I missing something? Any error messages? If so what does mysql_error() say? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* WHERE CAN THE MATTER BE Oh, dear, where can the matter be When it's converted to energy? There is a slight loss of parity. Johnny's so long at the fair. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Old memory contents appearing in files created by dba_open
I was playing around with figuring out why dba_open creates an ndbm database when run in stand alone mode (as requested) but creates a db2 database when run as an apache module. This is in php 4.2.3 on a Debian 3.0 system. I haven't tried with 4.3 yet. I am not sure if this is a bug somewhere, or a configuration problem, but it does seem odd. Something I noticed while playing with this, is that all the files created by dba_open contain a lot of other old memory contents from the apache/php process when created, some of which perhaps shouldn't be dumped into files being saved. My guess is that when the db lib used by dba_open creates a file, it does a malloc of a certain size, and uses that as the basis for the file, and it doesn't clear this memory (after all why should it care what is in it before it creates it's db structure). I assume that when php's garbage collector frees memory, it does not clear it, and hence script code, sql query contents, etc are still present in the freed memory, which may be allocated by another malloc later in the same thread without being cleared (since it was already used by that process there is no point in the OS clearing it, assuming the OS is ever responsible for clearing memory). As a result, content of SQL queries sent to postgres from a previous request on that web server, may end up written to the db2 or ndbm or gdbm file (whichever is used), when you create a new file with dba_open, meaning potentially private information could end up in a file you may end up giving to someone else later. So does anyone have any idea who is to blame for this problem? Is it PHP? libc? The OS? Apache? The DB library in use? I am certainly not sure, but given I don't know of a way for the php user to make php wipe it's memory, I can't think of any way to prevent the data from ending up in the file, short of changing the lib*db* code to zero the memory it allocs before writing the file. Somehow that seems like the wrong place to attack it. Calling bzero every time you call free in php also seems like the wrong approach. Opinions and possible fixes are welcome. Telling me another mailing list that is better suited for the question would be fine too given this could happen with other libraries included with php. Len Sorensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Getting array values into a query
I've been attempting to take the values from an array pulled from a session to supply the variable in a WHERE clause. list() provides only the first value as expected. implode() the last. Any suggestions or should I just load the values I want in the session through a query on the previous script and call it directly to the function I want to use? Michael Conway [EMAIL PROTECTED] (703) 968-8875
Re: [PHP-DB] Old memory contents appearing in files created by dba_open
On Fri, Feb 07, 2003 at 05:38:04PM -0500, Len Sorensen wrote: I was playing around with figuring out why dba_open creates an ndbm database when run in stand alone mode (as requested) but creates a db2 database when run as an apache module. This is in php 4.2.3 on a Debian 3.0 system. I haven't tried with 4.3 yet. I am not sure if this is a bug somewhere, or a configuration problem, but it does seem odd. Something I noticed while playing with this, is that all the files created by dba_open contain a lot of other old memory contents from the apache/php process when created, some of which perhaps shouldn't be dumped into files being saved. My guess is that when the db lib used by dba_open creates a file, it does a malloc of a certain size, and uses that as the basis for the file, and it doesn't clear this memory (after all why should it care what is in it before it creates it's db structure). I assume that when php's garbage collector frees memory, it does not clear it, and hence script code, sql query contents, etc are still present in the freed memory, which may be allocated by another malloc later in the same thread without being cleared (since it was already used by that process there is no point in the OS clearing it, assuming the OS is ever responsible for clearing memory). As a result, content of SQL queries sent to postgres from a previous request on that web server, may end up written to the db2 or ndbm or gdbm file (whichever is used), when you create a new file with dba_open, meaning potentially private information could end up in a file you may end up giving to someone else later. So does anyone have any idea who is to blame for this problem? Is it PHP? libc? The OS? Apache? The DB library in use? I am certainly not sure, but given I don't know of a way for the php user to make php wipe it's memory, I can't think of any way to prevent the data from ending up in the file, short of changing the lib*db* code to zero the memory it allocs before writing the file. Somehow that seems like the wrong place to attack it. Calling bzero every time you call free in php also seems like the wrong approach. Opinions and possible fixes are welcome. Telling me another mailing list that is better suited for the question would be fine too given this could happen with other libraries included with php. I also occoured to me, that any user that can create php scripts and run them, could use dba_open, to dump a chunk of memory to a file, and then send that file using readfile, or the like to the user viewing the page, even if that file isn't in a location apache itself would serve. What if that memory dump contained passwords used on other parts of the site? Does this concern anyone else? Len Sorensen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Passing ARRAY through URL
Help. I've tried to pass large array through URL but it keep telling me page can not be displayed: ? // page1.php $mList = arrary(); ...// fill array with values $mList = urlencode( serialize( $mList ) ); header( location: page2.php?mL=$mList ); ? ? // page2.php $mList = stripslashes( unserialize( $mL ) ); print_r( $mList ); ? - This mail sent through ISOT. To find out more about ISOT, visit http://isot.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Passing ARRAY through URL
Help. I've tried to pass large array through URL but it keep telling me page can not be displayed: If you get page not found then it's not an issue with your code. Does page2.php really exist? What does the URL look like when it says page cannot be found? Is this a PHP or HTML error that you get? ? // page1.php $mList = arrary(); assuming this is a typo ...// fill array with values $mList = urlencode( serialize( $mList ) ); header( location: page2.php?mL=$mList ); To be entirely correct, it should be Location with a capitol L, and a full URL (not relative) as the address. ? ? // page2.php $mList = stripslashes( unserialize( $mL ) ); Reverse this. Stripslashes() first, then unserialize(). print_r( $mList ); ? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] foreach problem
On Saturday 08 February 2003 06:16, Sam Folk-Williams wrote: I don't get any MySQL error... It adds the first entry_id and date exactly as it should... it seems to be acting like entry_date is not an array, but when I use the same foreach loop to echo the contents of entry_date it echoes the multiple values (2003-05-01, 2003-05-02, etc)... I use the same code to insert checkbox data in a different form, so... I'm kinda stumped. $sql2 = INSERT INTO cal_date_map (entry_id, date) VALUES echo $sql2 and plug each of them into the mysql commandline to see what happens. $event_date is an array with several dates separated by commas. (2003-10-02, 2003-10-03). The code above successfuly inserts the first Could you explain what exactly $event_date contains? The output of print_r($event_date) would suffice. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Art is anything you can get away with. -- Marshall McLuhan. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting array values into a query
On Saturday 08 February 2003 06:47, Michael Conway wrote: I've been attempting to take the values from an array pulled from a session to supply the variable in a WHERE clause. list() provides only the first value as expected. implode() the last. Any suggestions or should I just load the values I want in the session through a query on the previous script and call it directly to the function I want to use? Please post your code. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* A city is a large community where people are lonesome together -- Herbert Prochnow */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php