[PHP-DB] read fils
Hello, I just want to read a txt file and let the output in php file. Can someone help me? Walter Franssen
[PHP-DB] Tree structures...
What's the best way to deal with tree structures? Use the following setup in a database as an example: ID | Parent | Description 1 || Colours 2 |1 | Red 3 || Hello 4 |1 | Green 5 | 4 | Light 6 | 4 | Dark This should be represented as: 1. Colours 4. +--Green 6. +--Dark 5. +--Light 2. +--Red 3. Hello (ie, in tree structure and ordered alphabetically by 'descriptiu What's the best way to select the data and render it in HTML? I thought about going thru each element (of the whole table) at a time, and making an array, dynamically adding bits of the tree together until the whole tree has been grown ... but it seems a little bit complicated and slow ... is there anything that could be done [database]server-side which might help me? Or do other people have code snippets, ideas or anything which might help me?? Thanks, Siggy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] file name extentions
Hi there, Currently my ISP has PHP 3 installed and to run php scripts I have to save the file as name.php3 I expect to install my own server and php4 in the foreseeable future - how can I save the files as .php so that they are upwardly compatible? I have tired using the filenmae file.php but the server will not execute the file. Any suggestions? Regards, Dan -- == Regards from Denmark, Europe Please cc your reply to [EMAIL PROTECTED] == I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] How to sort numerically ?
Dear Sunil, First of all make an array of you are reading from file. Like that: ? $sel = "Selcect fild1,fild2 from myfile"; $res= mysql_query($sel); while ($row=mysql_fetch_row($res)) { $my_array[$row[0]] = $row[1]; } // tem: asort($my_array); for(reset($my_array); $ind=key($my_array); next($my_array)) { print ("$ind : $my_array[$ind] br"); } ? Sunil Jagarlamudi wrote: I am trying to read a file which has two columns with names and numbers and I am trying to sort them numerically, with the highest at the top. Is there anyway you can do that in php ? Thank You Sunil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] file name extentions
On Sat, Mar 24, 2001 at 12:40:48PM +0100, Dan Eskildsen wrote: I have tired using the filenmae file.php but the server will not execute the file. This depends on the configuration of the webserver. The webserver needs to be told which file-suffixes should be used to identify files to parse. For apache (1.3.x) this is the following config-directive: | AddType application/x-httpd-php .php -fkr -- gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0 8A48 0D31 9BD3 D9AC 74D0 |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE | |all your base are belong to us | shame on me | fkr@IRCnet | PGP signature
Re: [PHP-DB] Tree structures...
Joe Celko wrote a book called "SQL for Smarties" that has about 20 pages devoted to representation of trees in SQL. I believe he also has a website. His quick take on representing trees in SQL is that hierarchical databases do this far better and a RECURSIVE UNION funtion is needed to do this in SQL. Which we don't have -- maybe SLQ3? But, cribbing freely from his book, try this ... Lets call the table "things" select D1.Description, "Descrip", P2.parent from things as D1, things as P1, things as P2 where D1.Parent = P1.ID and P1.Parent = P2.ID I don't see how this handles the null values, but I hope it can get you started. I'll cheerfully hand this on to persons more expert in SQL than myself. HOw you display it, once you have the values fetched is another exercise. The book is worth getting. ISBN 1-55860-323-9 Regards - Miles Thompson At 11:27 PM 3/24/01 +1200, you wrote: What's the best way to deal with tree structures? Use the following setup in a database as an example: ID | Parent | Description 1 || Colours 2 |1 | Red 3 || Hello 4 |1 | Green 5 | 4 | Light 6 | 4 | Dark This should be represented as: 1. Colours 4. +--Green 6. +--Dark 5. +--Light 2. +--Red 3. Hello (ie, in tree structure and ordered alphabetically by 'descriptiu What's the best way to select the data and render it in HTML? I thought about going thru each element (of the whole table) at a time, and making an array, dynamically adding bits of the tree together until the whole tree has been grown ... but it seems a little bit complicated and slow ... is there anything that could be done [database]server-side which might help me? Or do other people have code snippets, ideas or anything which might help me?? Thanks, Siggy -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] file name extentions
Look for "AddType application/x-httpd-php4" on your Apache configuration file and add the types you want PHP4 be responsible for. Here are my own : AddType application/x-httpd-php4 .php AddType application/x-httpd-php4 .php3 AddType application/x-httpd-php4 .html HTH Jayme. -Mensagem Original- De: Dan Eskildsen [EMAIL PROTECTED] Para: [EMAIL PROTECTED] Enviada em: sbado, 24 de maro de 2001 08:40 Assunto: [PHP-DB] file name extentions Hi there, Currently my ISP has PHP 3 installed and to run php scripts I have to save the file as name.php3 I expect to install my own server and php4 in the foreseeable future - how can I save the files as .php so that they are upwardly compatible? I have tired using the filenmae file.php but the server will not execute the file. Any suggestions? Regards, Dan -- == Regards from Denmark, Europe Please cc your reply to [EMAIL PROTECTED] == I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] comparison table script
Remember it only works on PHP4.0 ! HTH. Jayme. -Mensagem Original- De: olinux [EMAIL PROTECTED] Para: PHP-DB [EMAIL PROTECTED] Enviada em: sexta-feira, 23 de maro de 2001 23:38 Assunto: Re: [PHP-DB] comparison table script Cool! Just came across this, looks like PHP will make life simple. http://www.php.net/manual/en/function.array-flip.php Array_flip() returns an array in flip order. Example 1. Array_flip() example $trans = array_flip ($trans); $original = strtr ($str, $trans); example: $a[0]="abc"; $a[1]="def"; After an array_flip() you get: $a["abc"]=0; $a["def"]=1; gotta love it! olinux De: olinux [EMAIL PROTECTED] Para: [EMAIL PROTECTED] Enviada em: sexta-feira, 23 de maro de 2001 12:37 Assunto: Re: [PHP-DB] comparison table script You can get an idea here of what I would like to do http://www.bestbuy.com/ComputersPeripherals/DrivesStorage/CDRW.asp?m=488cat =511scat=514 So all information is displayed side by side, most of the time used to help decide between 2 or 3 products [bestbuy limits 10 selections in their comparison] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql grant problem?
When we use grant as following: GRANT select(col_name_1) on db_name_1.tbl_name_1 to peter identified by "peter"; Then peter can only select the field of col_name_1 on the tbl_name_1 of db_name_1. However, when peter issue the query: DESC tbl_name_1; he can see all the structure of that table. This makes that peter does not know which column he can use. Does any body know how to make peter only can see the column which he has right to use it when he issue DESC tbl_name_1. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] read fils
In article 004101c0b44b$b8e90640$[EMAIL PROTECTED], [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote: I just want to read a txt file and let the output in php file. Can someone help me? ?php readfile("myfile.txt"); ? For more sophisticated alternatives, see http://php.net/manual/en/ref.filesystem.php. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] uploading files.
K, I am using a script i found at hotscripts.com I need it to upload an image to server. I think that my issue is that i need to use the stripslashes(); somewhere, but i don't know where anyways here tis: ? function do_upload($filename,$newname) { $file = basename($filename); $tmp_upload_path = "c:/program files/apache group/apache/htdocs"; $new_file_name = "c:/program files/apache group/apache/htdocs".$newname; $file = stripslashes($file); $tmp_upload_path = stripslashes($tmp_upload_path); $new_file_name = stripslashes($new_file_name); if (!copy($tmp_upload_path.$file, $new_file_name)) echo "failed to copy filebr\n"; return; } ? and later i calll the function: ? do_upload($userfile,$newname); ? here the error i receive: Warning: Unable to open 'c:/program files/apache group/apache/htdocsphp2' for reading: No such file or directory in c:\program files\apache group\apache\htdocs\uploads\2\upload_go.php on line 9 and script returns this upload tmp file: \\php2 There is an article at phpbuilder called file uploading made easy http://phpbuilder.com/columns/bealers2904.php3 i am having the same issues with this script and though i found an answer to the file://php2 thing [it was a stripslashes() solution] I am getting an error with this script that there is an unset variable... It looks set to me :) puzzled, olinux [who thanks you all greatly]
Re: [PHP-DB] connection id
Use persistent connections it's a matter of performance of your script. When you use persistent connections the next call to mysql_pconnect will catch a opened connection if available. The mysql_connect command always open a new connection which slower than get an opened one. Anyway you can't use the connection_id in other page. May be using PHP4 Sessions. HTH. Jayme. -Mensagem Original- De: andrie [EMAIL PROTECTED] Para: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Enviada em: sexta-feira, 23 de maro de 2001 20:38 Assunto: [PHP-DB] connection id Hello php mania, i was connecting into mysql using mysql_connect, and i just saved the return value from this funtion. now i want to use this connection id in the other page so i dont have to connect into mysql again. is it possible for me to do that ? anybody could tell me the different between persistence connection or not ? and how the implementation ? TIA -- Best regards, andrie mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: [PHP] connection id
TIA, What you described is not possible. When you create that connection to the mysql server, that connection dies when the script ends... As far as persistent connections go, you will always call the code to create the connection, but that connection lives on in that apache child process until that child process dies. So for example, apache spawns a child process to handle a request and it executes your PHP script with the persistent connection code (mysql_pconnect) and then after you script exits, that child process keeps the conection to mysql open. Any PHP script afterwards that uses the same connection information (host, username, password) with the mysql_pconnect() call; apache checks for an existing persistent connection (that was created with the first PHP script execution) so it returns that connection id. If you use the standard mysql_connect call the apache child will drop the connection when the script ends. Cheers, -Jonathan Sharp js_AT_imprev.com -Original Message- From: andrie [mailto:[EMAIL PROTECTED]] Sent: Friday, March 23, 2001 3:38 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: [PHP] connection id Hello php mania, i was connecting into mysql using mysql_connect, and i just saved the return value from this funtion. now i want to use this connection id in the other page so i dont have to connect into mysql again. is it possible for me to do that ? anybody could tell me the different between persistence connection or not ? and how the implementation ? TIA -- Best regards, andrie mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] uploading files.
Yes please Tim Morris - Original Message - From: olinux [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Sunday, March 25, 2001 11:21 AM Subject: Re: [PHP-DB] uploading files. mmmK, i have figured it out, anyone want it? lemme know olinux - Original Message - From: "olinux" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: "PHP-DB" [EMAIL PROTECTED] Sent: Saturday, March 24, 2001 4:27 PM Subject: [PHP-DB] uploading files. K, I am using a script i found at hotscripts.com I need it to upload an image to server. I think that my issue is that i need to use the stripslashes(); somewhere, but i don't know where anyways here tis: ? function do_upload($filename,$newname) { $file = basename($filename); $tmp_upload_path = "c:/program files/apache group/apache/htdocs"; $new_file_name = "c:/program files/apache group/apache/htdocs".$newname; $file = stripslashes($file); $tmp_upload_path = stripslashes($tmp_upload_path); $new_file_name = stripslashes($new_file_name); if (!copy($tmp_upload_path.$file, $new_file_name)) echo "failed to copy filebr\n"; return; } ? and later i calll the function: ? do_upload($userfile,$newname); ? here the error i receive: Warning: Unable to open 'c:/program files/apache group/apache/htdocsphp2' for reading: No such file or directory in c:\program files\apache group\apache\htdocs\uploads\2\upload_go.php on line 9 and script returns this upload tmp file: \\php2 There is an article at phpbuilder called file uploading made easy http://phpbuilder.com/columns/bealers2904.php3 i am having the same issues with this script and though i found an answer to the file://php2 thing [it was a stripslashes() solution] I am getting an error with this script that there is an unset variable... It looks set to me :) puzzled, olinux [who thanks you all greatly] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] SQL Select?
Hello all Is there any way of using a string in an SQL query instead of using the table name. Something along the lines of $result=mysql_query("SELECT * FROM $tablename",$db); this doesnt work it come up with a parse error thankyou Grant -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] SQL Select?
Grant, $link_id = mysql_connect($host, $usr, $pass) or die (mysql_error()); mysql_select_db($database, $link_id); $sql="select fields from $table where criteria = $value"; $result = mysql_query($sql, $link_id) or die ("no results"); //return result set to php you still need to do something with $result. also, if you use mysql_fetch_array instead of mysql_query, you get a row-matched array. Best regards, Andrew --- Andrew Hill - OpenLink Software Director Technology Evangelism Virtuoso, eBusinss iNtegration http://www.openlinksw.com/virtuoso On 3/24/01 3:55 PM, "Grant" [EMAIL PROTECTED] wrote: Hello all Is there any way of using a string in an SQL query instead of using the table name. Something along the lines of $result=mysql_query("SELECT * FROM $tablename",$db); this doesnt work it come up with a parse error thankyou Grant -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] SQL Select?
In article 99jh2n$gr1$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Grant") wrote: Is there any way of using a string in an SQL query instead of using the table name. Something along the lines of $result=mysql_query("SELECT * FROM $tablename",$db); this doesnt work it come up with a parse error "SELECT * FROM $tablename" should be sufficient to permit PHP variable expansion. MySQL will also require a string value to be quoted, so if $tablename is a string, change the query to "SELECT * FROM '$tablename'". AFAIK, the missing inner quotes would not cause a PHP parse error, only a MySQL error. So you may want to look for something else in your code that could be causing the parse error. -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]