RE: [PHP-DB] Tree structure - how to show only current branch ??
Ya it has - that is a great script! -Original Message- From: Galbreath, Mark A [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 30, 2004 7:15 AM To: '-{ Rene Brehmer }-'; '[EMAIL PROTECTED]' Subject: RE: [PHP-DB] Tree structure - how to show only current branch ?? Already been done: http://www.destroydrop.com/javascripts/tree/ Mark -Original Message- From: -{ Rene Brehmer }- [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 30, 2004 7:50 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Tree structure - how to show only current branch ?? Ok, Tom Reed got my thinker running big time ... and I've been trying to build an expandable and modifiable tree structure where it only displays the branch leading to the current folder... Showing the entire tree is easy, but how do I change the code to only display the branch we need??? ... I've never coded visual trees before, so this is new for me ... Found several samples with google where the code relies on the structure being fixed in the DB. What I want to create is the possibility to mode folders around within the tree ... literally moving branches from one place to another, while retaining their content. DB structure is simply this (I want to get rid of the level field if it's at all possible to count the levels with recursive functions, but for now it stays). folderID int(10) UNSIGNED auto-increment parentID int(10) UNSIGNED level tinyint(3) UNSIGNED name varchar(255) (I'm fully aware that int may be overkill, but this is for testing purposes...) test data: http://localhost/phpmyadmin/sql.php?lang=en-iso-8859-1server=1db=tree +tes ttable=folderspos=0session_max_rows=30disp_direction=horizontalrepe at_c ells=100dontlimitchars=0sql_query=SELECT++%2A+%0AFROM++%60folders%60++ ORDE R+BY+%60folderID%60+ASCfolderID http://localhost/phpmyadmin/sql.php?lang=en-iso-8859-1server=1db=tree +tes ttable=folderspos=0session_max_rows=30disp_direction=horizontalrepe at_c ells=100dontlimitchars=0sql_query=SELECT++%2A+%0AFROM++%60folders%60++ ORDE R+BY+%60parentID%60+ASCparentID http://localhost/phpmyadmin/sql.php?lang=en-iso-8859-1server=1db=tree +tes ttable=folderspos=0session_max_rows=30disp_direction=horizontalrepe at_c ells=100dontlimitchars=0sql_query=SELECT++%2A+%0AFROM++%60folders%60++ ORDE R+BY+%60level%60+ASClevel http://localhost/phpmyadmin/sql.php?lang=en-iso-8859-1server=1db=tree +tes ttable=folderspos=0session_max_rows=30disp_direction=horizontalrepe at_c ells=100dontlimitchars=0sql_query=SELECT++%2A+%0AFROM++%60folders%60++ ORDE R+BY+%60name%60+ASCname 1 0 0 parent 1 2 0 0 parent 2 3 0 0 parent 3 4 0 0 parent 4 5 0 0 parent 5 6 1 1 child of 1 7 3 1 child of 3 8 1 1 child 2 of 1 9 6 2 sub-child 1 10 6 2 sub-child 2 11 10 4 sub-sub 1 12 10 4 sub-sub 2 13 11 5 sub-sub-sub 1 Current code looks like this, the 2 subfunctions prints the branches, the main function below prints the root structure...: function count_children($parentID) { // count number of children in folder $count = mysql_query(SELECT COUNT(*) AS num_children FROM folders WHERE `parentID`='$parentID'); $numrows = mysql_fetch_array($count); return $numrows['num_children']; } function print_children($parentID) { // print the branch of sub-folders $children = mysql_query(SELECT folderID,level,name FROM folders WHERE `parentID`='$parentID'); while($child = mysql_fetch_array($children)) { $folderID = $child['folderID']; $name = $child['name']; $level = $child['level']; for ($i = 0; $i $level; $i++) { echo('middot'); } echo(middot; a href=\test1.php?folderID=$folderID\$name/abr\n); // let's find children... recursive call !! if (count_children($folderID) 0) { print_children($folderID); } } } // get root parents -- main tree function $parents = mysql_query(SELECT folderID,name FROM folders WHERE `parentID`='0'); while($folder = mysql_fetch_array($parents)) { $folderID = $folder['folderID']; $name = $folder['name']; echo(middot; a href=\test1.php?folderID=$folderID\$name/abr\n); // let's find children... if (count_children($folderID) 0) { print_children($folderID); } } The output of all this looks like this: . http://localhost/tests/tree%20structure/test1.php?folderID=1parent 1 .. http://localhost/tests/tree%20structure/test1.php?folderID=6child of 1 ... http://localhost/tests/tree%20structure/test1.php?folderID=9sub-child 1 ... http://localhost/tests/tree%20structure/test1.php?folderID=10sub-child 2 . http://localhost/tests/tree%20structure/test1.php?folderID=11sub-sub 1 .. http://localhost/tests/tree%20structure/test1.php?folderID=13sub-sub-s ub 1 . http://localhost/tests/tree%20structure/test1.php?folderID=12sub-sub 2 .. http://localhost/tests/tree%20structure/test1.php?folderID=8child 2 of 1 . http://localhost/tests/tree%20structure/test1.php?folderID=2parent 2 . http://localhost/tests/tree%20structure/test1.php?folderID=3parent 3 ..
RE: [PHP-DB] Automatically Refreshing png-Image'd Web Page
I might be reading this wrong, but I do not think you should put your meta refresh request in the png creation script. It should be in the html body script. Index.php Meta-refresh to call itself in 30 secs Call to img src=php_radio_image_creation_script.php php_radio_image_creation_script.php header(Content-type: image/png) Echo image content Hopefully this sudo code is enough to get what I am trying to say. You might have some caching issues, but that is another issue. - Paul -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, March 19, 2004 11:01 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Automatically Refreshing png-Image'd Web Page Howdy Listers, The Background: I am making dynamic, color-coded, png images of the floor plan of a building and displaying them in a browser. Numerous radioactivity sensors throughout the building send their readings to a MySQL dB, and the web page queries the dB, and depending on the readings, the areas specific to the sensors will appear green for normal, yellow for high but acceptable, and red for critical. All this works OK. The Problem: Neither the HTML nor JavaScript code I usually use for automatically refreshing a page has any effect if the header(Content-type: image/png) necessary for displaying the png image is included. If I comment out the header() line, the page refreshes, but the image data comes through as hieroglyphics. Obviously, I need to refresh the page to get the latest data, and to create and display the corresponding image. The Question: Is there any way to automatically refresh a web page displaying a png image? Thanks in advance for any thoughts/insights into how I can solve this problem. dave -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] ?DHTML Layers with PHP?
This JS script is awesome. I work with Oracle Portal and a guy modified it to read portal hierarchies so I know it can read dynamic data with modification. http://www.destroydrop.com/javascripts/tree/ I believe you just have to be able to create the parent child relationships and display them in a js include like this: script type=text/javascript src=dynamic_page.php /script With dynamic_page.php containing links like: !-- d = new dTree('d'); d.add(44273,-1,'Corporate Documents'); d.add(44273,1,'Corporate Documents','http://www.someserver.com/portal/page?_pageid=73,44273','Fol der Name',''); document.write(d); -- I am not sure of a ready made php script that can do what you want, but I know it can be done. HTH - Paul -Original Message- From: Galbreath, Mark A [mailto:[EMAIL PROTECTED] Sent: Friday, March 19, 2004 11:04 AM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] ?DHTML Layers with PHP? I've been sitting here all morning wracking my brains for a way to code a hierarchical menu tree with JavaScript from database data retrieved by PHP, so that the child menus appear on a mouse click. Can PHP do this without JS? The only JS examples I can find use static menu trees, not dynamic data. tia, Mark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] How to redirect after a valid login
That means you send some output before the headers were sent. That is a no no. For instance, this will not work: ?php Echo hello world; header(Location:http://www.yahoo.com/;); ? But this will ?php header(Location:http://www.yahoo.com/;); Echo hello world; ? - Paul -Original Message- From: Larry Sandwick [mailto:[EMAIL PROTECTED] Sent: Friday, March 12, 2004 2:25 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] How to redirect after a valid login What is considered to be the headers() information When I use the header() functions, I get an error stating that I have already sent the headers information? // Larry -Original Message- From: Larry E. Ullman [mailto:[EMAIL PROTECTED] Sent: Friday, March 12, 2004 3:04 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] How to redirect after a valid login Is there a way that after a execution of a Login script and validation of login from a MySql database to automatically redirected to run another script ? Use PHP's header() function. See the manual for syntax. Larry -- 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] Paging large recordsets
In no way I am trying start some long thread here. But I have always heard it was bad to store that much data in a session array? I could just be really off here and not understanding what I have read. I know PHP stores the sessions as text files. The only reason I can come up with why one should not store large amounts of data would be disk write/read speed per user. Can someone clarify this for me? - Paul -Original Message- From: Robert Twitty [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 12:34 PM To: Karen Resplendo Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Paging large recordsets Most of the PHP solutions I have seeen require the use of session variables. You could create an array containing only the unique identifiers of all the records, and then store it into a session variable. You would then use another session variable to retain the page size, and then include the page numbers in the Next, Prev, First, Last and Absolutr page links. Printing is probably best done with dynamically generated PDF instead of HTML. -- bob On Fri, 13 Feb 2004, Karen Resplendo wrote: I guess the time has come that my boss wants Next, Previous, First, Last paging for our data displays of large recordsets or datasets. Any good solutons out there already? I have pieces of a few examples. Also, how to deal with printing? I would assume that the ideal page size is not the ideal printed page size. oi vay! TIA - Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online -- 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] Paging large recordsets
One way that I have found - but never used is... http://sqlrelay.sourceforge.net/ It can cache result sets in a file for later use. You can then use It does a whole bunch of other stuff too. I really need to install this and start working with it. - Paul -Original Message- From: Robert Twitty [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 1:59 PM To: Paul Miller Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Paging large recordsets If you are not opearating in a stateless environment, then you could use a cursor. The web is a stateless environment, and therefore the record set needs to be cached either to disk or memeory. The other alternative is to rerun the query for each page request. Using disk space to store query results for the purpose of paging over the web is commonly done by search engines, and even some database engines use disk space for cursor implementation. I agree that using session variables for this purpose is not ideal, but what's the alternative in PHP? Storing only the identifiers instead of all the data significantly lessons the impact. I agree, it should be avoided if possible. -- bob On Fri, 13 Feb 2004, Paul Miller wrote: In no way I am trying start some long thread here. But I have always heard it was bad to store that much data in a session array? I could just be really off here and not understanding what I have read. I know PHP stores the sessions as text files. The only reason I can come up with why one should not store large amounts of data would be disk write/read speed per user. Can someone clarify this for me? - Paul -Original Message- From: Robert Twitty [mailto:[EMAIL PROTECTED] Sent: Friday, February 13, 2004 12:34 PM To: Karen Resplendo Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Paging large recordsets Most of the PHP solutions I have seeen require the use of session variables. You could create an array containing only the unique identifiers of all the records, and then store it into a session variable. You would then use another session variable to retain the page size, and then include the page numbers in the Next, Prev, First, Last and Absolutr page links. Printing is probably best done with dynamically generated PDF instead of HTML. -- bob On Fri, 13 Feb 2004, Karen Resplendo wrote: I guess the time has come that my boss wants Next, Previous, First, Last paging for our data displays of large recordsets or datasets. Any good solutons out there already? I have pieces of a few examples. Also, how to deal with printing? I would assume that the ideal page size is not the ideal printed page size. oi vay! TIA - Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online -- 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] compiling oracle support
I am using OCI-8 with Oracle 9i just fine. - Paul -Original Message- From: Adam Williams [mailto:[EMAIL PROTECTED] Sent: Thursday, February 12, 2004 9:13 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] compiling oracle support How do I compile PHP on Unix to have oracle 9 support. Looking at ./configure --help and PHP's website, I see no option for oracle 9 support. I see --with-oci8 but that appears to only work for Oracle 8. Any help? Thanks! -- 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] Rules in a database
I guess I did not pay attention that day in class, but that is cool. - Paul -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Friday, February 06, 2004 9:14 AM To: DB list PHP; John Subject: Re: [PHP-DB] Rules in a database A bit of algebra first: any expression formed of atomic expressions, AND, OR and parentheses can be reduced to a canonical form, by using the De Morgan laws: a AND ( b OR c ) is equiv. to a AND b OR a AND c So a rule can eventually be reduced to AND groups, joined by OR: a(1) AND... AND a(n) OR ... OR z(1) AND ... AND z(p) Each AND group contains 1 or more rules. Therefore, to model input rules: - store atomic rules in a table - store AND rule groups in a table (1-n relation to the atomic table) - store full rules in a table (1-n relation to the AND table) Now you can model output rules likewise, and finally create a table of associations between input and output rules Problem is: once you've flattened your rules to the canonical form, they can become illegible. So perhaps a hierarchical data model (XML) would be more appropriate, for your rules would remain human-legible (and thererfore human-maintainable) HTH Ignatius _ - Original Message - From: John [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 06, 2004 15:35 Subject: [PHP-DB] Rules in a database I work in tax and thus have to read legislation - some complex - and I wanted to store some of the logic in a database so that if I know certain conditions were true I could look up what results this might have. Thus I am thinking of having two tables - one of phrases and the other of how these phrases are linked together as rules. A rule structure could be: IF A THEN B IF A OR A1 OR A2 THEN B IF A THEN B AND C I was wondering how to do this. For instance, each rule could be one record in the table. The rules table has fields, IF and THEN. The ID field is the rule ID. Assume the phrases are numbered. One IF record could say: +/12/41/31/+/90/ meaning if phrases 12, 41 or 31 are true and phrase +90 is true. Then if I have a real situation where condition 12 is true, for instance, I can find it and access it using sub string functions. Does this scheme seem OK? Has anyone done anything like this before? Regards, John -- 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] PHP Command Line
php script.php %1 %2 %3 %4 And it is referenced as $argv[arg number] ... I think. To be sure, here is the link to that info: http://www.php.net/manual/en/features.commandline.php - Paul -Original Message- From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 4:34 PM To: PHP-DB Subject: [PHP-DB] PHP Command Line Anyone know how to pass a query string to a php script when you call it on the command line? Ryan -- 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] Inserting querydata as default value in form
Need some quotes input name=link TYPE=TEXT cols=40 value=\.$query_data[4].\ Output will look like input name=link TYPE=TEXT cols=40 value=Look Here Instead of input name=link TYPE=TEXT cols=40 value=Look Here\ Which it probably looks like now. - Paul -Original Message- From: Georg Herland [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 12:05 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Inserting querydata as default value in form Hi! I hav made a simle page to insert update and delete data in MYSQL. I try to put existing data into a standard form field to make editing easyer: input name=link TYPE=TEXT cols=40 value=$query_data[4] Problem is when the text data contains a space ie Look here. Then only the first word show. To display both words i have to update the data to Look_here witch isn't really looking good. A good suggestion, anyone? TIA Georg :-) -- 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] Wonder Program Question
Hi All, Got a question for everyone. Does anyone know of a Red Hat (Fedora would be even better) package that does the following: - Load Balancing - Proxying - Host Name Redirects - Server Heartbeat monitoring I know IP Tables can do it with some help from some other programs, but I am looking for one simple clean program that works a lot like my router or expensive routers I have used in the past. Some Foundry routers do this already and if I cannot do it server side I am going to consider that option. I am just wondering if any one knows of anything. Thanks, Paul Here is an example of what I want to setup. === All domains will have the same IP address. I want all traffic that comes in over port 80 on that IP address to be handled by my routing server. The server will send windows traffic to the windows machine and Linux traffic to one of the Linux machines based on availability and load. I want the routing server to determine what traffic goes where based on the host name (www.domain1.com or www.domain2.com). Below is a quick sketch. www.domain1.com - Linux Server (12) Domain1 will go to Linux Server1 and Linux Server2 in my backend network. It will be the load balanced server. www.domain2.com - Windows Server1 Domain2 will go to my Windows Server. The host name will tell the routing server to send the request to the Windows server. The Windows server will determine which virtual site to serve based on the proxied host name (Domain2) and then return the correct info. www.domain3.com - Windows Server1 Domain3 will also go to my Windows Server. The host name will tell the routing server to send the request to the Windows server. The Windows server will determine which virtual site to serve based on the proxied host name (Domain3) and then return the correct info. - www.domain1.com www.domain2.com www.domain3.com AB B || | - | | - My Firewall --| | | - | Linux Routing, Load- | | balancing and Proxy Server | | which accepts all port 80 | | traffic | - | | --- A A B B | | | | Linux Linux WindowsWindows Server1Server2 Server1Server1 - Thanks again if you have gotten this far, Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Can anyone see what's wrong with this code?
You probably need to specify the path in the filesize call also. It looks like you are just pushing the filename. Like $filepath = /home/www/nortonway/photos/$filename; $fd = fopen($filepath, rb); $filedata = fread ($fd, filesize($filepath)); $zipfile - add_file($filedata, $filename); fclose ($fd); HTH - Paul -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 12:52 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Can anyone see what's wrong with this code? HI there Everyone, Finally found the list address again, my computer crashed and I lost everything, sigh. Anyway, i'm zipping a file and it's zipping the filename ok but not the file and I have a feeling it's something wrong with the below, as I get an error on the filesize parameter saying no such file, even though I know it is there. For this example, think of $filename as having mypic.jpg stored in it (Which it does, checked and it echoed the name), so I specified the server path and that got rid of that error, but the filesize one is just frustrating me, is it something simple i'm missing? I've looked into the PHP manual and seems it should be working. $fd = fopen(/home/www/nortonway/photos/$filename, rb); $filedata = fread ($fd, filesize($filename)); $zipfile - add_file($filedata, $filename); fclose ($fd); Any help would be extremely appreciated. Regards Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php-db globals turned off
I love this one... extract($_REQUEST); but it undermines the whole reason PHP moved to the new default parameter specification. Be careful with you coding. I use it, and it makes things much like the pre 4.3.2 release without changing the ini files. You just have to specify the default $_server and file upload params. The other option is change the php.ini file for that dir or globally. - Paul -Original Message- From: Mignon Hunter [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 12:56 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] php-db globals turned off How do most of you handle variables in next page after passing. For instance. What I have right now (very ugly) is: $email = $_POST['emal']; $first = $_POST['first']; $lastl = $_POST['last']; Then I work with $email, $first etc... I will have to do this for many, many variables which doesnt seem very efficient. I tried: foreach ($_POST as $key = $value) $key = $value; but that didnt work...but I can print them out. but even if this did work - this wouldnt handle the 2 sets of arrays I have. Does anybody have any snippets for this ... ??? Thanks Mignon Hunter Webmaster Toshiba International Corporation (713) 466-0277 x 3461 (800) 466-0277 x 3461 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php-db globals turned off
Also, many legacy applications use the non $_POST variable definitions. A problem that I ran into. - Paul -Original Message- From: Mignon Hunter [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 1:47 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] php-db globals turned off So it will be easier to use in my script on this page, where I'm creating several query strings with the data. Mignon Hunter Webmaster Toshiba International Corporation (713) 466-0277 x 3461 (800) 466-0277 x 3461 John W. Holmes [EMAIL PROTECTED] 01/28/04 01:15PM Mignon Hunter wrote: How do most of you handle variables in next page after passing. For instance. What I have right now (very ugly) is: $email = $_POST['emal']; $first = $_POST['first']; $lastl = $_POST['last']; Why are you recreating variables? You already have a variable $_POST['email'], so why do you feel the need to make $email? Now you have two variables to keep track of. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php-db globals turned off
I am not 100% sure what you are doing here, so I am responding with this... if (is_array($_POST['prod']) { // Value is an Array $prod = $_POST['prod']; }else{ // Value is not an array, but the value // is added to the first element. $prod[] = $_POST['prod']; } With extract, if $_POST['prod'] is an array, then prod will be an array also. - Paul -Original Message- From: Mignon Hunter [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 2:09 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] php-db globals turned off How would you extract variables from arrays? before I was doing $prod[] = $_POST['prod']; $choice[] = $_POST['choice']; then I could iterate through $prod[], $choice[] Mignon Hunter Webmaster Toshiba International Corporation (713) 466-0277 x 3461 (800) 466-0277 x 3461 Paul Miller [EMAIL PROTECTED] 01/27/04 01:06PM I love this one... extract($_REQUEST); but it undermines the whole reason PHP moved to the new default parameter specification. Be careful with you coding. I use it, and it makes things much like the pre 4.3.2 release without changing the ini files. You just have to specify the default $_server and file upload params. The other option is change the php.ini file for that dir or globally. - Paul -Original Message- From: Mignon Hunter [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 12:56 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] php-db globals turned off How do most of you handle variables in next page after passing. For instance. What I have right now (very ugly) is: $email = $_POST['emal']; $first = $_POST['first']; $lastl = $_POST['last']; Then I work with $email, $first etc... I will have to do this for many, many variables which doesnt seem very efficient. I tried: foreach ($_POST as $key = $value) $key = $value; but that didnt work...but I can print them out. but even if this did work - this wouldnt handle the 2 sets of arrays I have. Does anybody have any snippets for this ... ??? Thanks Mignon Hunter Webmaster Toshiba International Corporation (713) 466-0277 x 3461 (800) 466-0277 x 3461 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Oracle and upper case field name
the way I do it is with http://www.ytztech.com product SQL_AL.PHP which has a switch that will say all values are upper or lower. You can also create a simple wrapper function that will do the lower conversion. - Paul -Original Message- From: William Cheung [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 2:27 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Oracle and upper case field name Hi, When Oracle returns the result set, the field names are all in upper case. However, I have an application that needs to work on both MSSQL and Oracle. I don't want to keep 2 copies. One has upper case field names and the other lower case. How could I make PHP or ADODB to work with lower case field names even the result set is upper case? William Cheung mailto:[EMAIL PROTECTED] B.Sc, MCSE, MCDBA Databyte Corp. http://www.databyte.com/ --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.567 / Virus Database: 358 - Release Date: 1/24/2004
RE: [PHP-DB] php-db globals turned off
As mentioned in my first email, PHP and myself think turning the global var reg off is a good thing, especially for inexperienced coders and var definition. $email = $_POST['email'] makes a difference is you are dealing with an application that was built during the 90% of PHP's lifetime where reg global vars was turned on and you want to use that application with your server where with 4.3.2 - it is turned off. Basically $_POST['email'] is already referred to as $email in thousands of lines of code and instead of trying to convert them (legacy application), you just use the extract function. Hope that is a bit clearer. - Paul -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:21 PM To: [EMAIL PROTECTED] Cc: 'Mignon Hunter'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] php-db globals turned off Paul Miller wrote: Also, many legacy applications use the non $_POST variable definitions. A problem that I ran into. So how is saying $email = $_POST['email'] going to help you in that case?? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals - www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Stroring files as BLOBs in MySQL?
One thing that is not a huge issue, just something to be aware of is the default 2mb limit in the php.ini file. It is easily changed if you want to upload bigger files. - Paul -Original Message- From: John [mailto:[EMAIL PROTECTED] Sent: Friday, January 23, 2004 10:04 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Stroring files as BLOBs in MySQL? Whats the problems with it?? I now have an 150MB table with MIDI files and title and authors. could i run into problems bu doing this?? -- ** Free Nokia Ringtones US http://www.ring-tones.us ** -- 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] Images stored in a db - how to get them?
While I totally agree with Ryan, there are instances where I have found that people do not follow best practices, namely Oracle (Oracle File Storage) and many MySQL/PHP programs out there (OPT and Help Center Live). So here is some code addressing both. You would probably need an interpreter file. Something like image.php and call images like image.php?ID=house. Then in your code, you grab the blob or file info and print it out after you set the headers like this: = THE DB OPTION (local file system storage): = ?php $sql = select image_blob_column, mime_type from images where image_ext_id = '$ID'; $results = sql_query($sql, $db_id); if ($row_file = sql_fetch_array($results)){ // Set the headers Header(Content-Type: .$row_file[mime_type]); // Gif or Jpeg Header(Content-Disposition: inline); // Tells the browser to display it // in the browser if it is opened up by itself Header(Content-Length: .count($row_file[image_blob_column])); echo $row_file[image_blob_column]; } ? = THE FILE OPTION (local file system storage): = ?php $sql = select file_path, mime_type from images where image_ext_id = '$ID'; $results = sql_query($sql, $db_id); if ($row_file = sql_fetch_array($results)){ // Set the headers Header(Content-Type: .$row_file[mime_type]); // Gif or Jpeg Header(Content-Disposition: inline); // Tells the browser to display it // in the browser if it is opened up by itself Header(Content-Length: .filesize($row_file[file_path])); $fp=fopen($row_file[file_path], rb); fpassthru($fp); } ? The GD library is for creating new images using specified parameters or editing an image. HTH - Paul -Original Message- From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED] Sent: Monday, January 26, 2004 3:28 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Images stored in a db - how to get them? about once a quarter this question comes up and the answer is always the same. Don't store them in the database, just store filenames and store the files in the filesystem. That way you just generate a link and treat it like any other image. Then when you query the database you would create img tags with src property set to the image. You probably don't want to store FULL path info, just enough to find the image. Ryan -Original Message- From: John T. Beresford [mailto:[EMAIL PROTECTED] Sent: Monday, January 26, 2004 2:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Images stored in a db - how to get them? Hello All, I am interested in storing images in a table. My question is - What is the proper way of retrieving the images and displaying them on a web page? Will I need to go through the GD library and create an image from the information stored in the table? While PHP is not new to me, images in db's is. Specifically, when info is returned, it's usually in the form of: $var=$row['FieldName']; What would I then do with the 'BLOB' information? Is that where the GD image tools come in play? Any URL's or small hints to point in the right direction would be very much appreciated. Thanks, John -- === John T. Beresford Apple Certified Technical Coordinator http://www.deewi.com/ 405.760.0794 -- 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] Database Abstraction Layer?
There are a couple of products out there that I am about to start testing, starting first with: - SQL Relay http://sqlrelay.sourceforge.net/ This product uses its on C interfaces to interact with DBs and different programming languages. It addresses a bunch of items in the PHP DB calls. Connection pooling and load balancing. - Propel http://propel.phpdb.org/ Extensive templates create the SQL definition files you need to setup your database and the classes you need to work with your data model in your PHP scripts. The classes for your object model are generated from a simple XML schema and any customizations are written in plain PHP. This will effectively that add SQL and DB dependence out of your mix. This is PHP5 also. HTH - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 2:31 AM To: phpdb Subject: [PHP-DB] Database Abstraction Layer? Hello everybody, What do you think is the best method to abstract php code from a specific database?. Make PHP code 100% database independent?.. Waitin' for your comments. Muhammed Mamedov -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Abstraction Layer?
Oh ya, one more thing, I am going to integrate SQL Relay with the PHP abstraction layer: http://sourceforge.net/projects/sqlalphp to give the functions a more PHP feel to them. Plus, I will be able to retain DB specific calls if I want with this layer. I have used this layer with a great deal of success in the past. But it was never the DB calls that got me, it was the actually SQL. So I am building a swappable SQL library. The Propel solution would effectively negate me having to do that. - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 3:41 AM To: phpdb Subject: Re: [PHP-DB] Database Abstraction Layer? Thanks Ricardo for your comments. What do you think guys: ADODB or PEAR::DB ? - Original Message - From: Ricardo Lopes [EMAIL PROTECTED] To: Muhammed Mamedov [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 11:21 AM Subject: Re: [PHP-DB] Database Abstraction Layer? You have ADODB and PEAR DB that both work as abstraction layer. I have used ADODB and seems to me that is very good, yet i have not tested PEAR DB... To make php code 100% database independent is not very easy, depends of what are you going to do with your code. Use the ADODB or PEAR functions every time possible, and avoid the using of sql statements in your code because you have to carefull design then to be database independent but that can be a very difficult task. - Original Message - From: Muhammed Mamedov [EMAIL PROTECTED] To: phpdb [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 8:31 AM Subject: [PHP-DB] Database Abstraction Layer? Hello everybody, What do you think is the best method to abstract php code from a specific database?. Make PHP code 100% database independent?.. Waitin' for your comments. Muhammed Mamedov -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Database Abstraction Layer?
PEAR is great from what I hear. The issue you are going to run into with DB independence is not the function calls which could be handled with something as simple as sqlalphp. It is the SQL calls themselves. The two options I have found is a SQL library with unembeded SQL or the Propel solution. Either way adds a significant time to coding and product release initially. - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 10:07 AM To: [EMAIL PROTECTED]; phpdb Subject: Re: [PHP-DB] Database Abstraction Layer? Hmm.. Thank you for you sql picks:) But what do you guys think aabout Pear :: DB? Is it as effective as these Paul's picks? Thank you. Muhammed Mamedov - Original Message - From: Paul Miller [EMAIL PROTECTED] To: phpdb [EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 5:44 PM Subject: RE: [PHP-DB] Database Abstraction Layer? There are a couple of products out there that I am about to start testing, starting first with: - SQL Relay http://sqlrelay.sourceforge.net/ This product uses its on C interfaces to interact with DBs and different programming languages. It addresses a bunch of items in the PHP DB calls. Connection pooling and load balancing. - Propel http://propel.phpdb.org/ Extensive templates create the SQL definition files you need to setup your database and the classes you need to work with your data model in your PHP scripts. The classes for your object model are generated from a simple XML schema and any customizations are written in plain PHP. This will effectively that add SQL and DB dependence out of your mix. This is PHP5 also. HTH - Paul -Original Message- From: Muhammed Mamedov [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 2:31 AM To: phpdb Subject: [PHP-DB] Database Abstraction Layer? Hello everybody, What do you think is the best method to abstract php code from a specific database?. Make PHP code 100% database independent?.. Waitin' for your comments. Muhammed Mamedov -- 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] Update problems
You might want to use single quotes FirstName='$fname' $sqlupdate=UPDATE UserInfo SET ZNum='112763', FirstName='$fname', LastName='Short', TA='00', Building='1197', Room='112', Div='FWO', Grp='IIM' WHERE ZNum='112763'; - Paul -Original Message- From: Peter Lovatt [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 20, 2004 5:17 PM To: Kermit Short; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Update problems you need quotes around the name FirstName=$fname otherwise it takes the value of $fname to be aa field name HTH Peter -Original Message- From: Kermit Short [mailto:[EMAIL PROTECTED] Sent: 20 January 2004 22:28 To: [EMAIL PROTECTED] Subject: [PHP-DB] Update problems I'm trying to update a record in a MSSQL database. When I execute the following code on an IIS5 webserver, I get an error message that says: PHP Warning: odbc_do(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Tom'., SQL state S0022 in SQLExecDirect in E:\web\phptest\dbtest.php on line 31 This is after I've submitted the name Tom in the form. Does anyone have any ideas?! Thanks very much in advance! -Kermit ?php $fname=$_POST['first']; if (!(is_null($fname))) { if (!($odbccon = odbc_connect(**, **, **))) { die(pCould not Connect./p); } else { echopConnected to Database./p; $sqlupdate=UPDATE UserInfo SET ZNum='112763', FirstName=$fname, LastName='Short', TA='00', Building='1197', Room='112', Div='FWO', Grp='IIM' WHERE ZNum='112763'; $sqlupdresults=odbc_do($odbccon, $sqlupdate); $query=SELECT * FROM UserInfo WHERE ZNum=112763; $qresults=odbc_do($odbccon, $query); odbc_result_all($qresults, border=1); odbc_close($odbccon); echo pConnection Closed./p; } } else { ? form action=?php echo $_SERVER['PHP_SELF'] ? method=post name=test First Name: input type=text name=first /br / input type=submit name=submit / /form ?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] Architecture Question - Opinion
All, I am considering moving to a true 3-tier structure where the web server does not have direct access to the database server - many times a government requirement. I want to keep the PHP front end and use an application server (middle tier) to handle all the DB calls and sessions. I could use Java or something for the middle layer, but I do not really want to. I would like to implement a PHP application server sitting on top of SQL Relay for pooling and DB abstraction to reduce the need to have more expertise necessary for implementation. Interoperability is important, but not 100% necessary. With all that being said, what do you think is the best method of communication between PHP and the application server. Just to throw it out there, I have thought about SOAP and XML-RPC. I like SOAP better because it can decrease payload a great deal by not having to use the whole struct method and it is more complex. But the XML-RPC functions are written in C and the SOAP are in PHP. PHP 5 has better object orientation and new XML libs so the SOAP functions should run much faster, but still not native. What are your thoughts? - Paul
RE: [PHP-DB] Re: Architecture Question - Opinion
That is the major issue at hand, the slow Live DB calls. Is there any way around it while maintaining the constraints listed below using another method of standard communication. Is the slow going to be unacceptable? I used SOAP to call an off site document server and that was slow. I do not think that is a good comparison because my two servers would be on the same gigabit network. I am mostly worried about the web server, app server and DB server all being on different machines and the SOAP layer adding an unacceptable amount of lag in the already heavy backend. callSOAP client call---SOAP server translation-DB call--Data call-SOAP client acceptance---SOAP server transmission-DB response-Base - Paul = I believe people are working on a SOAP extension to PHP in C, but I could be mistaken. I like SOAP myself, it means easy interoperability with any language with a SOAP implementation. The downside is slow processing. Live DB calls on the webserver will be fairly slow. -- paperCrane Justin Patrin -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 16, 2003 12:19 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Architecture Question - Opinion Paul Miller wrote: All, I am considering moving to a true 3-tier structure where the web server does not have direct access to the database server - many times a government requirement. I want to keep the PHP front end and use an application server (middle tier) to handle all the DB calls and sessions. I could use Java or something for the middle layer, but I do not really want to. I would like to implement a PHP application server sitting on top of SQL Relay for pooling and DB abstraction to reduce the need to have more expertise necessary for implementation. Interoperability is important, but not 100% necessary. With all that being said, what do you think is the best method of communication between PHP and the application server. Just to throw it out there, I have thought about SOAP and XML-RPC. I like SOAP better because it can decrease payload a great deal by not having to use the whole struct method and it is more complex. But the XML-RPC functions are written in C and the SOAP are in PHP. PHP 5 has better object orientation and new XML libs so the SOAP functions should run much faster, but still not native. What are your thoughts? - Paul -- 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] NEXTVAL Question
Does anyone know how to make this work??? $sql = select TEAM_SEQ.NEXTVAL as \nextval\ from sys.dual; I get the following error in PHP: ociexecute(): OCIStmtExecute: ORA-00903: invalid table name But when I use my SQL tool to hit the DB will all the same parameters, it works just fine. I have also tried: $sql = select TEAM_SEQ.NEXTVAL from sys.dual; $sql = select TEAM_SEQ.NEXTVAL from dual; all with the same results. I am running Red Hat AS, PHP 4.3, OCI8 Functions and Oracle 9i. - Paul -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Splitting a string by a ,
if the emails are in a CSV file, you can also use fgetcsv ?php $handle = fopen (test.csv,r); while ($data = fgetcsv ($handle, 1000, ,)) { $num = count ($data); for ($c=0; $c $num; $c++) { print $data[$c] . br\n; } } fclose ($handle); ? - Paul -Original Message- From: Chris Payne [mailto:[EMAIL PROTECTED] Sent: Friday, December 05, 2003 1:23 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Splitting a string by a , Hi there everyone, I'm trying to split a string into an Array by a , but I kepe getting errors. Looking at the PHP manual, I thought it would be this way: $keywords = preg_split(,, $email); But it keeps saying that the , isn't an ending delimiter? Any help would be appreciated, i'm trying to split email addresses from an input box seperated by a , Thanks for any help. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Oracle/PHP Issue
Nope, that was not it? Still giving me the *** ORA-12545: Connect failed because target host or object does not exist *** error. Hm - Paul -Original Message- From: Justin Patrin [mailto:[EMAIL PROTECTED] Sent: Thursday, December 04, 2003 4:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Oracle/PHP Issue I'm using the descriptor type of connection and it looks a bit different than yours. Try changing your CONNECT_DATA setion to: (CONNECT_DATA = (SID = BDB1) (GLOBAL_NAME = BDB1.world)) Paul Miller wrote: Hello, I am having a strange issue with Oracle and PHP. I am running PHP Version 4.3.4 on Red Hat AS 2.3 and trying to connect to Oracle 9i also on Red Hat AS 2.3. I compiled PHP successfully with OCI and oracle. My script uses the ocilogon($user, $password, $db); or ora_logon($user.'@'.$db, $password); depending on what interface I want to use in my abstraction layer. Note: All oracle failures (*** some error ***) are when I use the ora_logon, ocilogon, or the ocinlogon. Info about what works: - PHP can at lease partially talk to the remote Oracle DB. - If I give a bad username or password, PHP returns *** Oracle: Connection Failed: ORA-01017: invalid username/password; logon denied.*** So I know PHP is able to validate the username against the remote Oracle database. - If I give an unspecified TNS name, BDB1_broken, instead of BDB1 which is in the tnsnames.ora file, I get the following Oracle message though PHP: *** Oracle: Connection Failed: ORA-12154: TNS:could not resolve service name ***. So I know that the TNS name is being verified against the remote database. - When I try to logon to the remote DB with SQLPlus using the same tnsnames.ora file used by PHP, I can logon just fine. Also, a plsql stored procedure running off a DAD on the server works. THE PROBLEM: When I use the correct username, password and ORACLE_SID, I get the following error: *** Oracle: Connection Failed: ORA-12545: Connect failed because target host or object does not exist *** I have: - Tried specifying the DB connection in the PHP code $DATABASE = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = BDB1.world) ) ); - Tried using the IP address 192.168.2.2 and the host name both in the PHP and the tnsnames file. - Added apache and nobody to the oracle and the dbs groups. - Setting different environment vars in the PHP code putenv(ORACLE_HOME=/opt/ora9/product/9201); putenv(ORACLE_SID=BDB1) - Recompiling PHP - Using BDB1 and BDB1.PROD_DATABASE.MY_DOMAIN.COM in the putenv and the database name in the connection function. - Checked the Apache config ##ORACLE ENVIRONMENT ORACLE_HOME=/opt/ora9/product/9201 ORACLE_BASE=/opt/ora9/ export ORACLE_HOME ORACLE_BASE ORACLE_TERM=vt100 LD_LIBRARY_PATH=$ORACLE_HOME/lib PATH=$ORACLE_HOME/bin:$PATH export PATH LD_LIBRARY_PATH ORACLE_DOC=$ORACLE_BASE/doc ORACLE_SID=BDB1 TNS_ADMIN=/opt/ora9/product/9201/network/admin export ORACLE_DOC ORACLE_SID TNS_ADMIN Does anyone have any thoughts Thanks for any help, Paul ___ Paul Miller System-Wise pmillerATsystemDASHwiseDOTcom AT = @ DASH = - DOT = . -- 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] Oracle/PHP Issue
Hello, I am having a strange issue with Oracle and PHP. I am running PHP Version 4.3.4 on Red Hat AS 2.3 and trying to connect to Oracle 9i also on Red Hat AS 2.3. I compiled PHP successfully with OCI and oracle. My script uses the ocilogon($user, $password, $db); or ora_logon($user.'@'.$db, $password); depending on what interface I want to use in my abstraction layer. Note: All oracle failures (*** some error ***) are when I use the ora_logon, ocilogon, or the ocinlogon. Info about what works: - PHP can at lease partially talk to the remote Oracle DB. - If I give a bad username or password, PHP returns *** Oracle: Connection Failed: ORA-01017: invalid username/password; logon denied.*** So I know PHP is able to validate the username against the remote Oracle database. - If I give an unspecified TNS name, BDB1_broken, instead of BDB1 which is in the tnsnames.ora file, I get the following Oracle message though PHP: *** Oracle: Connection Failed: ORA-12154: TNS:could not resolve service name ***. So I know that the TNS name is being verified against the remote database. - When I try to logon to the remote DB with SQLPlus using the same tnsnames.ora file used by PHP, I can logon just fine. Also, a plsql stored procedure running off a DAD on the server works. THE PROBLEM: When I use the correct username, password and ORACLE_SID, I get the following error: *** Oracle: Connection Failed: ORA-12545: Connect failed because target host or object does not exist *** I have: - Tried specifying the DB connection in the PHP code $DATABASE = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = BDB1.world) ) ); - Tried using the IP address 192.168.2.2 and the host name both in the PHP and the tnsnames file. - Added apache and nobody to the oracle and the dbs groups. - Setting different environment vars in the PHP code putenv(ORACLE_HOME=/opt/ora9/product/9201); putenv(ORACLE_SID=BDB1) - Recompiling PHP - Using BDB1 and BDB1.PROD_DATABASE.MY_DOMAIN.COM in the putenv and the database name in the connection function. - Checked the Apache config ##ORACLE ENVIRONMENT ORACLE_HOME=/opt/ora9/product/9201 ORACLE_BASE=/opt/ora9/ export ORACLE_HOME ORACLE_BASE ORACLE_TERM=vt100 LD_LIBRARY_PATH=$ORACLE_HOME/lib PATH=$ORACLE_HOME/bin:$PATH export PATH LD_LIBRARY_PATH ORACLE_DOC=$ORACLE_BASE/doc ORACLE_SID=BDB1 TNS_ADMIN=/opt/ora9/product/9201/network/admin export ORACLE_DOC ORACLE_SID TNS_ADMIN Does anyone have any thoughts Thanks for any help, Paul ___ Paul Miller System-Wise pmillerATsystemDASHwiseDOTcom AT = @ DASH = - DOT = .