[PHP-DB] Sending variables between PHP pages
Hi users, how can I send a connection database variable, from one PHP page to other PHP page, and maintance the database connection open during both pages? Thanks -- 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] Sending variables between PHP pages
Yes, thanks a lot, but i need to mantain the connection open for manage a transaction, an everytime that I open a new database connection, the system begins a new transaction and I lose the last one. Do you understand, me? Do you know the way for do that? I think it is imposimble in web applications at all, because there is no persistent connection between db server and web server + PHP service. You can try for example mysql_pconnect() function (or it's analog for your db engine) but still I don't think it is possible ;((( Only applications can make this for you NOT PHP and Web ;((( -- 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] Sending variables between PHP pages
how can I send a connection database variable, from one PHP page to other PHP page, and maintance the database connection open during both pages? I don't think one can do that. There is NO need for that. You can write header.php file and include it in the beginning of each PHP page where you need db connection and footer.php which you can include at the bottom of each page with X_close() function in it. -- 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] Sending variables between PHP pages
Yes, Im thinking the same... :-(( Thanks again Intruder - Original Message - From: Intruder [EMAIL PROTECTED] To: Berlina [EMAIL PROTECTED]; php-general-list [EMAIL PROTECTED]; php-dev-list [EMAIL PROTECTED]; php-db-list [EMAIL PROTECTED] Sent: Friday, January 04, 2002 12:38 PM Subject: RE: [PHP] Sending variables between PHP pages Yes, thanks a lot, but i need to mantain the connection open for manage a transaction, an everytime that I open a new database connection, the system begins a new transaction and I lose the last one. Do you understand, me? Do you know the way for do that? I think it is imposimble in web applications at all, because there is no persistent connection between db server and web server + PHP service. You can try for example mysql_pconnect() function (or it's analog for your db engine) but still I don't think it is possible ;((( Only applications can make this for you NOT PHP and Web ;((( -- 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] phpmyadmin
That I can't help you with, as I've never worked with phpmyadmin, always manipulated the database at the MySQL console. By default MySQL stores the database in it's ../var directory, like so: /path/to/mysql/var /mysql - the database which contains info about the other databases /resume /some_other_db /still_another_db and so forth. The fly in this ointment is that the databases can be stored on other drives or directories and symlinked from the default location. Are you thinking that the phpmyadmin is used to build your scripts? If so, you have he wrong impression, as it is a database administration tool. If you need guidance on where to start developing your application, Julie Meloni has some very useful tutorials ar http://www.thickbook.com; there are also tutorials at WeberDev, PHPMonkey, DevShed and so forth. Regards - Miles Thompson At 10:26 PM 1/3/2002 -0500, Viper wrote: OK so great. Where does phpmyadmin store the db file as I am making it? the default area.. I have looked for it on the ftp when I login but do not see it. Thanks - Original Message - From: Miles Thompson [EMAIL PROTECTED] Newsgroups: php.db To: Viper1 [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, January 03, 2002 7:59 PM Subject: Re: [PHP-DB] phpmyadmin You're really asking a database design question, and it can be answered only by asking more questions. The first has to be how much do you know about relational databases? The basic theory on normalization, simple queries, etc., covers about 6~10 pages. There are some very good tutorials on the 'Net; search on something like SQL tutorial Here are a couple: http://www.cs.unibo.it/~ciaccia/COURSES/RESOURCES/SQLTutorial/sqlcont.htm This deals with MySQL, and gets you to third normal form quite painlessly: http://www.mysql.com/articles/ddws/index.html The next question is What information do you want from the database? Write out all the possible questions you will ask of your data. This will tell you what you need to include. When you have this answered, along with some basic table design information, you're in a good position to answer your question. Unfortunately there is no canned answer. Here are a few tips though: For dates, MySQL has a very useful date format. Use it. Most numbers don't have to be stored as a numeric data type, they are more usefully stored as character data. Examples would be phone numbers, street numbers. Numbers which represent quantities, and on which you will do work, multiplying, adding ,dividing, etc., should be stored with a numeric data type. Examples would be price, quantity, number_of_members. MySQL provides an easily used auto-increment field which you can use for a unique primary key on each table. Use it. I know this isn't what you wanted to hear, but I hope it is helpful. The important steps are to determine the possible combinations of data you want to retrieve, and to set up your tables so that you do not needlessly duplicate data, what is otherwise known as third normal form. Will it be somewhat hard work? Yes, but you only have to do it once. I'd also recommend that once you have your perfect design, sit down with some people who are somewhat familiar with your problem and have them ask questions about what is stored and how it will be retrieved. Have fun - Miles Thompson At 06:18 PM 1/3/2002 -0500, Viper1 wrote: I am trying to use the phpmyadmin to create an online resume site. I have created a table and it seems to be fine but I need some more help on the next steps also how to test the database out. I started by making a table called resumes # of fields is 11 first field is name var is 20 and so on. Can someone please help? Thanks, very much appreciated. -- 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] Sending variables between PHP pages
Another way of doing this, is including a file at the beginning of each script: Example: ?php # Include the file containing general variables/constants/funstions require (general.inc); # Open a connection to MySQL using variables from general.inc $link = mysql_connect ($host, $username, $password); ? Regards, -Bjarte- -Original Message- From: markus|lervik [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 12:40 PM To: Berlina Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Sending variables between PHP pages On Friday 04 January 2002 13:15, you wrote: Hi users, how can I send a connection database variable, from one PHP page to other PHP page, and maintance the database connection open during both pages? Thanks This is exactly what I've been fighting with for quite some time. Actually, what I did was, session_register username and password and the required variables and reconnect to the db when needed. Not quite the most elegant way of solving the problem, but it works... If anyone has got a better way of doing it, I'd be more than happy to hear about it. Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] Sending variables between PHP pages
On Friday 04 January 2002 14:26, Bjarte Husebø wrote: Another way of doing this, is including a file at the beginning of each script: Example: ?php # Include the file containing general variables/constants/funstions require (general.inc); # Open a connection to MySQL using variables from general.inc $link = mysql_connect ($host, $username, $password); ? Yes, but then we come across the other problem, namely, if you click a submit button that has a ACTION=?php echo $PHP_SELF?, technically the script ends when it reloads the page, and therefore also forgets $host, $username and $password, so I'd probably still have to somehow register the variables, ie. using session_register, no? -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] How to compress a jpeg (qualitysetting) before saving it to the server?
Hi there, I am uploading jpegs in my app. How can I control the compression setting before saving? Currently my code looks like: $inputImg = ImageCreateFromJPEG($image); # old size $srcX = imagesx($inputImg); $srcY = imagesy($inputImg); if ($same == true){ // Image must have the given size. Empty parts are filled black. # new size $ratio = ($srcY / $dstY); $dstX = ($srcX / $ratio); $outputImg = ImageCreateTrueColor($maxX, $dstY); imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 0, 0,0)); imagecopyresampled($outputImg, $inputImg, (($maxX - $dstX) / 2),0,0,0, $dstX, $dstY, $srcX, $srcY); } else{ // Image has a y ratio size. Results in not all images same y size. # new size $ratio = ($srcX / $maxX); $dstY = ($srcY / $ratio); $outputImg = ImageCreateTrueColor($maxX, $dstY); imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 0, 0,0)); imagecopyresampled($outputImg, $inputImg, 0,0,0,0, $maxX, $dstY, $srcX, $srcY); } # save file imagejpeg($outputImg, $path.$name..jpg); Thanx for any help. Cheers Andy -- 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] How to querry two db in a single statement?
Hi there, I would like to make a querry on 2 db. There is info in tables I would like to compare. As I know, there has first to be a conect on the db before the querry. But how to do this on 2 db?? Thanx for any help. Andy -- 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] Redirecting to a new page
Can't find the right instructions on php.net, basically, i want a page where someone logs in, and then according to the database entry for them, either they are an admin user or a normal user, and it should then send them to a page depending on which they are. I've accessed the db ok, and checked which they are, then i've used if ($myrow[Admin] == Y){ print Location:admin.php; }else{ print Location:user.php; ) this doesn't sem to work - just gives a blank screen with the standard html headers and footers, rather than the desired location page. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 -- 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] Redirecting to a new page
Matt, Instead of print you want to issue a header(). Check the manual for various caveats. Miles At 01:57 PM 1/4/2002 +, matt stewart wrote: Can't find the right instructions on php.net, basically, i want a page where someone logs in, and then according to the database entry for them, either they are an admin user or a normal user, and it should then send them to a page depending on which they are. I've accessed the db ok, and checked which they are, then i've used if ($myrow[Admin] == Y){ print Location:admin.php; }else{ print Location:user.php; ) this doesn't sem to work - just gives a blank screen with the standard html headers and footers, rather than the desired location page. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 -- 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] How to querry two db in a single statement?
Try the following: ?php mysql_connect(firstDB,username,password) or die (Unable to connect to Server); mysql_select_db(DB) or die (Unable to select DB); ---GET THE INFO YOU WANT AND PLACE IT IN AN APPROPRIATE VARIABLES --FOR LATER COMPARISON mysql_connect(secondDB,username,password) or die (Unable to connect to Server); mysql_select_db(DB) or die (Unable to select DB); --COMPARE WITH THE VALUES FROM THE VARIABLES ? I believe that this should work (I haven't tried it though!!!) May the force be with you!!! George - Original Message - From: Andy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 04, 2002 3:50 PM Subject: [PHP-DB] How to querry two db in a single statement? Hi there, I would like to make a querry on 2 db. There is info in tables I would like to compare. As I know, there has first to be a conect on the db before the querry. But how to do this on 2 db?? Thanx for any help. Andy -- 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] Redirecting to a new page
Hi Matt, http://nl.php.net/manual/nl/function.header.php Note: HTTP/1.1 requires an absolute URI as argument to Location: including the scheme, hostname and absolute path. Thus, print Location:http:/www.host.com/admin.php; should work. Regards, Roel Mulder At 13:57 04-01-2002 +, you wrote: Can't find the right instructions on php.net, basically, i want a page where someone logs in, and then according to the database entry for them, either they are an admin user or a normal user, and it should then send them to a page depending on which they are. I've accessed the db ok, and checked which they are, then i've used if ($myrow[Admin] == Y){ print Location:admin.php; }else{ print Location:user.php; ) this doesn't sem to work - just gives a blank screen with the standard html headers and footers, rather than the desired location page. Mulder Technisch Advies Postbus 69 NL-2740 AB WADDINXVEEN tel. 0182-640184 fax. 0182-640185 http://www.mta.nl -- 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] Re: [PHP] Sending variables between PHP pages
Berlina, Are you attempting to set a variable in one page and use its value in the next page? If so, I'll show you how. -Original Message- From: Berlina [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 5:50 AM To: [EMAIL PROTECTED]; php-general-list; php-dev-list; php-db-list Subject: [PHP-DB] Re: [PHP] Sending variables between PHP pages Yes, Im thinking the same... :-(( Thanks again Intruder - Original Message - From: Intruder [EMAIL PROTECTED] To: Berlina [EMAIL PROTECTED]; php-general-list [EMAIL PROTECTED]; php-dev-list [EMAIL PROTECTED]; php-db-list [EMAIL PROTECTED] Sent: Friday, January 04, 2002 12:38 PM Subject: RE: [PHP] Sending variables between PHP pages Yes, thanks a lot, but i need to mantain the connection open for manage a transaction, an everytime that I open a new database connection, the system begins a new transaction and I lose the last one. Do you understand, me? Do you know the way for do that? I think it is imposimble in web applications at all, because there is no persistent connection between db server and web server + PHP service. You can try for example mysql_pconnect() function (or it's analog for your db engine) but still I don't think it is possible ;((( Only applications can make this for you NOT PHP and Web ;((( -- 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] -- 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]
Fwd: Re: [PHP-DB] How to querry two db in a single statement?
Didn't notice that this didn't get cc:d to the list, so here it hoes. -- Forwarded Message -- Subject: Re: [PHP-DB] How to querry two db in a single statement? Date: Fri, 4 Jan 2002 15:58:35 +0200 From: markus|lervik [EMAIL PROTECTED] To: Andy [EMAIL PROTECTED] On Friday 04 January 2002 15:50, you wrote: Hi there, I would like to make a querry on 2 db. There is info in tables I would like to compare. As I know, there has first to be a conect on the db before the querry. But how to do this on 2 db?? As far as I know there aren't any relational databases that support querying multiple databases in one query. I guess you'd be best off querying the first database, save the result, query the second database, save the result and then compare the two results. Please do correct me if I'm wrong, people. Cheers, Markus --- -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] querystring text
rawurlencode() does this trick. Matthew Tedder wrote: Quick question for anyone who knows, Is there a PHP function to make data safe for sending in the query string? $var = something or other; // TODO: What is function to translate $var for querystring compatibility? print a href=\http://yada.com/index.php?var=$vardataothervar=whatever\; Yada/a; --Matthew -- 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] How to querry two db in a single statement?
If the two databases are on the same server, you can use joins to select data from multiple databases. For instance: Database 1, Table A: | id | name| | 1 | George | | 2 | Mark| | 3 | Harry | Database 2, Table A: | id | name| | 1 | Bill| | 2 | Henry | | 3 | Ford| You can: SELECT a.name as db1Name, b.name as db2Name FROM Database1.TableA a LEFT JOIN Database2.TableA b ON a.id=b.id; Now you'll get: --- | db1Name | db2Name | --- | George | Bill | | Mark | Henry| | Harry| Ford | --- Hope this helps. - Jonathan -Original Message- From: Andy [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 5:50 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] How to querry two db in a single statement? Hi there, I would like to make a querry on 2 db. There is info in tables I would like to compare. As I know, there has first to be a conect on the db before the querry. But how to do this on 2 db?? Thanx for any help. Andy -- 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] How to insert to DB from txt??? Please help
Hi everyone, I have a txt file which is contained the following: ,aaa,ccc,ddd ,aaa,ccc,ddd .etc. Now, I need to read the data from that file and than insert it into the table. insert into Table (name,pass,phone,somethingelse) Could someone help me out here, How to write the code? I know how to read from a txt file, but I don't know how to separate the data determine by , Please help, I'll be very appreciate.Thanks Kelvin. -- 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 insert to DB from txt??? Please help
How about LOAD DATA INFILE 'filename.txt' INTO TABLE Table FIELDS TERMINATED BY ',' comma delimited for tabs use '\t' LINES TERMINATED BY '\n' *nix line terminator, for Dos/Win use '\r\n' IGNORE 1 LINES use if the first line of the file has col. hdrs. (column1name, column2name, column3name, column4name); -- __ _Tyler Nally / /__ _(_)___ _ _ [EMAIL PROTECTED] / / _ \/ __ `/ / __ \/ __ \ / __ \/ ___/ __ `/ 317-860-3016 / / __/ /_/ / / /_/ / / / // /_/ / / / /_/ / American Legion Website /_/\___/\__, /_/\/_/ /_(_)/_/ \__, /http://www.legion.org // // -Original Message- From: Kelvin [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 11:44 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] How to insert to DB from txt??? Please help Hi everyone, I have a txt file which is contained the following: ,aaa,ccc,ddd ,aaa,ccc,ddd .etc. Now, I need to read the data from that file and than insert it into the table. insert into Table (name,pass,phone,somethingelse) Could someone help me out here, How to write the code? I know how to read from a txt file, but I don't know how to separate the data determine by , Please help, I'll be very appreciate.Thanks Kelvin. -- 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: Redirecting to a new page
if ($myrow[Admin] == Y){ header (Location:admin.php); }else{ header (Location:user.php); } -- Best regards, George Nicolae IT Manager ___ X-Playin - Professional Web Design www.x-playin.f2s.com Matt Stewart [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Can't find the right instructions on php.net, basically, i want a page where someone logs in, and then according to the database entry for them, either they are an admin user or a normal user, and it should then send them to a page depending on which they are. I've accessed the db ok, and checked which they are, then i've used if ($myrow[Admin] == Y){ print Location:admin.php; }else{ print Location:user.php; ) this doesn't sem to work - just gives a blank screen with the standard html headers and footers, rather than the desired location page. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 -- 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 insert to DB from txt??? Please help
On Saturday 05 January 2002 00:44, Kelvin wrote: Hi everyone, I have a txt file which is contained the following: ,aaa,ccc,ddd ,aaa,ccc,ddd .etc. Now, I need to read the data from that file and than insert it into the table. insert into Table (name,pass,phone,somethingelse) Could someone help me out here, How to write the code? I know how to read from a txt file, but I don't know how to separate the data determine by , Use explode(). For example: $line = ,aaa,ccc,ddd; $bits = explode(,, $line); Would result in: $bits[0] = $bits[1] = aaa $bits[2] = ccc etc. hth -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Love conquers all things; let us too surrender to love. -- Publius Vergilius Maro (Virgil) */ -- 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 querry two db in a single statement?
How about: SELECT c.country FROM db2.users u LEFT JOIN db1.countries c ON u.country_id=c.country_id GROUP BY c.country; This assumes the following layout: db1.countries | country_id | country | | 67 | USA | | 68 | Uganda | | 69 | Canada | db2.users --- | user_id | username | country_id | --- | 1 | george | 69 | | 2 | harry| 67 | | 3 | bob | 68 | | 4 | bill | 69 | | 5 | joe | 68 | | 6 | martha | 68 | --- This should result in --- | country | --- | USA | | Uganda | | Canada | --- You should be able to add an ORDER BY c.country to that SELECT query if you want to sort the results alphabetically. - Jonathan -Original Message- From: Andreas Pucko [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 9:40 AM To: Jonathan Hilgeman Subject: AW: [PHP-DB] How to querry two db in a single statement? I wrote them: # database: connect function db_connect() { global $sys_dbhost,$sys_dbuser,$sys_dbpasswd, $mailadress_webmaster; $conn = @mysql_connect($sys_dbhost,$sys_dbuser,$sys_dbpasswd); if (!$conn) { # send error mail to webmaster $mailHeaders = From: .$mailadress_webmaster.\n; // from $mailHeaders .= X-Priority: 1\n; // Urgent message! mail($mailadress_webmaster,'MySQL error. Website is down!',mysql_error(),$mailHeaders); HEADER(Location:/app_global/errors/unavailable.html);//redirect to unavailable } return $conn; } # Select the Database function select_db($link,$DB){ global $mailadress_webmaster, $header_1_boxcolor_2; if (!mysql_select_db($DB, $link)){ header_1('Error', $header_1_boxcolor_2); echo(' br We are sorry, an error has occured.brPlease contact our webmaster at: a href=mailto:'.$mailadress_webmaster.''.$mailadress_webmaster.'/a br br Occured during executing '); DisplayErrMsg(sprintf(%s, $stmt)); echo( statement br\n br\n Error: ); DisplayErrMsg(sprintf( %d %s, mysql_errno($link), mysql_error($link))) ; exit() ; } } The layout of the db is verry complex. Too long to show all the tables. But in short form there is one table in db1 called country and another in db2 called user. The user has the country as a field. I am trying to find out the countries the users come from. Building a select field containing only the countries where user come from. Cheers Andy -Ursprüngliche Nachricht- Von: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 4. Januar 2002 17:46 An: '[EMAIL PROTECTED]' Betreff: RE: [PHP-DB] How to querry two db in a single statement? Are select_db and db_connect functions that you wrote or someone else wrote? They are not generic PHP4.x functions... In any case, it would help to see your database layouts... - Jonathan -Original Message- From: Andreas Pucko [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 8:29 AM To: Jonathan Hilgeman Subject: AW: [PHP-DB] How to querry two db in a single statement? Hello Jonathan, my problem is how to connect to 2 db in the same time. They are on the same server. Here is the code I wrote so far: ### # connect to db1 $link = db_connect(); //connect to db select_db($link,$DB); // select db ### ### # Get countries who are currently used by registered members: // $geo_T1 is in $DB2 // $T5 is in $DB $stmt= SELECT DISTINCT C.* /*Distinct means no equal results*/ from $geo_T1 C, $T5 U where C.country_id = U.country order by country_name ; $result = execute_stmt($stmt, $link);
Re: Fwd: Re: [PHP-DB] How to querry two db in a single statement?
Hi all: AFAIK, it is possible in a bunch of database software to query multiple DBs through joining. I have a Foxpro background (so most of what I say is therefore, b.s.) but you can define your query tables using this notation: database.table Which allows you to query multiple DBs. You should be able to do this (using joins) in MySQL. However, I don't know how off the top of my head. That might be more of a MySQL-list-geek type of question. Cheers, db markus|lervik wrote: Didn't notice that this didn't get cc:d to the list, so here it hoes. -- Forwarded Message -- Subject: Re: [PHP-DB] How to querry two db in a single statement? Date: Fri, 4 Jan 2002 15:58:35 +0200 From: markus|lervik [EMAIL PROTECTED] To: Andy [EMAIL PROTECTED] On Friday 04 January 2002 15:50, you wrote: Hi there, I would like to make a querry on 2 db. There is info in tables I would like to compare. As I know, there has first to be a conect on the db before the querry. But how to do this on 2 db?? As far as I know there aren't any relational databases that support querying multiple databases in one query. I guess you'd be best off querying the first database, save the result, query the second database, save the result and then compare the two results. Please do correct me if I'm wrong, people. Cheers, Markus --- -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- 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] -- -- Dan Barton Terrestrial Program Biologist Asst. Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [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] Please help asap
In the printf() line after 5 6 7 you try to print %s 24 times but only provide 10 values. That may have something to do with it... Bogdan Jeff Moncrieff wrote: Hello I am trying make a script fatch my data form my mysql database. I use this script but when execute it is says Warning: printf(): too few arguments in /home/httpd/html/larken/database.php on line 47 any hints Thanks Jeff html body ?php $db = mysql_connect(, root); mysql_select_db(larken,$db); $result = mysql_query(SELECT * FROM custgeninfo,$db); echo table border=1\n; echo trtdName of contact/tdtdName of company/tdtd Address/tdtdPostal Code/tdtdFormat Mail/tdtdEmail Addresstdmodel/tdtdComment/tdtdtelephone/tdtdNotes/tdtdCounty/tdtd ID /td/tr\n; while ($myrow = mysql_fetch_row($result)) { // 1 2 34 5 6 7 printf(trtd%s%s/tdtd%s%s/tdtd%s%s/tdtd%s%s%s/tdtd%s%s/tdtd%s/tdtd%s%s%s/tdtd%s/tdtd%s%s/tdtd%s/tdtd%s%s%s%s%s/td/tr\n,$myrow[1],$myrow[2],$myrow[3],$myrow[4],$myrow[5],$myrow[6],$myrow[7],$myrow[8],$myrow[9],$myrow[10]); } echo /table ? /body /html -- 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] Array not supported for strings???
Hi there, I have a problem with an array: This code: $country[] = $row-country; Creates following error msg: Fatal error: [] operator not supported for strings The wired thing is, that the same procedure works through my whole application, but not in this case. Did anybody make the same experience? Thanx for any help buddys. Regards Andy -- 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] Fixed Quote Marks in Inputs
I finally came up with a reliable solution that I can use when I'm dealing with form inputs that can contain quote marks (single or double quotes). To store quote marks, you can str_replace them with their HTML code equivalents. For single quote marks, this is #039;, and for double quote marks it's #034; So before I insert any input into my database, I run my below function on all the data: // Replace quotes with their #039; and #034; equivalents function PrepareQuotes($Var) { $Var = str_replace(',#039;,$Var); $Var = str_replace('',#034;,$Var); return $Var; } Hope this helps someone else. - Jonathan -- 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] Fixed Quote Marks in Inputs
Those are two different things. You never mentioned your HTML problem, that's why nobody adressed it. So, the proper way to do it is: 1. Insert into the database using addslashes(); 2. Use stripslashes() after retrieving the data if you need to; 3. Use htmlspecialchars() for displaying the data in HTML or htmlentities() if you still have problems. Bogdan Jonathan Hilgeman wrote: I've tried those methods, but they cause problems when the values are loaded back into INPUTs for editing. For instance, even if the database-stored value is Mark\'s Pet Named \Flea Muffin\, try loading that value into an INPUT so it looks like: INPUT NAME='FullPetName' VALUE='Mark\'s Pet Named \Flea Muffin\' Or try double-quotes: INPUT NAME=FullPetName VALUE=Mark\'s Pet Named \Flea Muffin\ You'll see what I mean. By using the HTML equivalents, the value can be loaded back into an input box flawlessly for easy updating, and it will display correctly when being pulled from the database for other usage. - Jonathan -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 12:11 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Fixed Quote Marks in Inputs Another option is to use PHP's addslashes() and stripslashes() functions. These will add/remove slashes in front of quotes to make them database friendly. -Original Message- From: Jonathan Hilgeman [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 2:05 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Fixed Quote Marks in Inputs I finally came up with a reliable solution that I can use when I'm dealing with form inputs that can contain quote marks (single or double quotes). To store quote marks, you can str_replace them with their HTML code equivalents. For single quote marks, this is #039;, and for double quote marks it's #034; So before I insert any input into my database, I run my below function on all the data: // Replace quotes with their #039; and #034; equivalents function PrepareQuotes($Var) { $Var = str_replace(',#039;,$Var); $Var = str_replace('',#034;,$Var); return $Var; } Hope this helps someone else. - Jonathan -- 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 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: Redirecting to a new page
Please note, that this is a very insecure way of determining which page a person gets to view. All they would have to do is enter the admin.php url in the browser and they get admin access even if they are not admins. Fred Matt Stewart [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Can't find the right instructions on php.net, basically, i want a page where someone logs in, and then according to the database entry for them, either they are an admin user or a normal user, and it should then send them to a page depending on which they are. I've accessed the db ok, and checked which they are, then i've used if ($myrow[Admin] == Y){ print Location:admin.php; }else{ print Location:user.php; ) this doesn't sem to work - just gives a blank screen with the standard html headers and footers, rather than the desired location page. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.312 / Virus Database: 173 - Release Date: 31/12/01 -- 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] How to put data
Hello How do you Normal put you mysql data in to a php table. Jef -- 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] Fixed Quote Marks in Inputs
How is it the \proper\ way to do it and why does it have to remain the \proper\ way of doing it? Simply because it retains the same character in the database? What good is that if the data will simply be extracted and unslashed at a later point anyway? How the data is kept internally should not be an issue if it is only stored to be later extracted and parsed anyway. That's a partial reason we use timestamps instead of storing the full date everywhere. It's called proper representation. And I think in cases where HTML forms are used in conjunction with databases, the HTML equivalents are a heck of a lot more proper than slashes, not to mention more efficient. The only downside I see is that instead of taking up 2 characters, it takes up 6, but since many fields we all use won't ever contain quotes, I see it as a more than reasonable trade-off. I personally consider it a bad habit to use slashes unless you're dealing with regexes. And not everybody does it that way. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 1:41 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs That would be because this way you'll end up with the proper data in the database instead of HTML-encoded strings. Plus it's the proper way to do it -- everybody does it this way and it's a good habit. Bogdan Jonathan Hilgeman wrote: I thought I made it somewhat clear: when I'm dealing with form inputs that can contain quote marks Why run 3 functions at separate times when you can run one once just before data is inserted into the database? -- 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] Fixed Quote Marks in Inputs
It seems obvious to me that you can do whatever you please - I was just suggesting what seems to me as the proper way to do it. Why I say it's the proper way to do the job is because you never know about future development and storing the data in ASCII seems to me as the most convenient approach to avoid possible problems later on. But then again, this is my own opinion - you are free to implement whatever solution you find most suitable. Bogdan Jonathan Hilgeman wrote: How is it the \proper\ way to do it and why does it have to remain the \proper\ way of doing it? Simply because it retains the same character in the database? What good is that if the data will simply be extracted and unslashed at a later point anyway? How the data is kept internally should not be an issue if it is only stored to be later extracted and parsed anyway. That's a partial reason we use timestamps instead of storing the full date everywhere. It's called proper representation. And I think in cases where HTML forms are used in conjunction with databases, the HTML equivalents are a heck of a lot more proper than slashes, not to mention more efficient. The only downside I see is that instead of taking up 2 characters, it takes up 6, but since many fields we all use won't ever contain quotes, I see it as a more than reasonable trade-off. I personally consider it a bad habit to use slashes unless you're dealing with regexes. And not everybody does it that way. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 1:41 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs That would be because this way you'll end up with the proper data in the database instead of HTML-encoded strings. Plus it's the proper way to do it -- everybody does it this way and it's a good habit. Bogdan Jonathan Hilgeman wrote: I thought I made it somewhat clear: when I'm dealing with form inputs that can contain quote marks Why run 3 functions at separate times when you can run one once just before data is inserted into the database? -- 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] Fixed Quote Marks in Inputs
I realize that part - my whole point was that it didn't really matter how it was stored as long as it gets extracted/parsed correctly. With that in mind, instead of using 3 functions to store, extract, and parse the data, I can use one function to prepare the data to be stored in a format that can be extracted directly into an form-friendly format. Not to mention that HTML entities are still ASCII characters, and I do not foresee any problems with using the HTML entities in place of quote marks. To me, it makes the most sense. Quote marks are generally special characters used everywhere, and storing them as quote marks instead of the entities seems to be asking for trouble, in my opinion. I've stored values using slashes for the past few years, and that method has given so many problems... Speaking as an experienced web programmer, I believe this is a much more practical method for a lot of us. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 2:39 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs Oh, one more thing - maybe you don't understand what the slashing is for: you don't store \ in the database -- the slash is there just so the MySQL statement is correct. MySQL knows about slashing and will replace your \ with so what you store in the database is exactly what the user typed in the input box. Bogdan Jonathan Hilgeman wrote: How is it the \proper\ way to do it and why does it have to remain the \proper\ way of doing it? Simply because it retains the same character in the database? What good is that if the data will simply be extracted and unslashed at a later point anyway? How the data is kept internally should not be an issue if it is only stored to be later extracted and parsed anyway. That's a partial reason we use timestamps instead of storing the full date everywhere. It's called proper representation. And I think in cases where HTML forms are used in conjunction with databases, the HTML equivalents are a heck of a lot more proper than slashes, not to mention more efficient. The only downside I see is that instead of taking up 2 characters, it takes up 6, but since many fields we all use won't ever contain quotes, I see it as a more than reasonable trade-off. I personally consider it a bad habit to use slashes unless you're dealing with regexes. And not everybody does it that way. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 1:41 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs That would be because this way you'll end up with the proper data in the database instead of HTML-encoded strings. Plus it's the proper way to do it -- everybody does it this way and it's a good habit. Bogdan Jonathan Hilgeman wrote: I thought I made it somewhat clear: when I'm dealing with form inputs that can contain quote marks Why run 3 functions at separate times when you can run one once just before data is inserted into the database? -- 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] Fixed Quote Marks in Inputs
Apparently, the experienced way is to store them with slashes, which is what I've followed for years. I consider years of programming to be a fair amount of experience, thus qualifying me to be experienced. ANYHOW, after finally thinking a bit outside the box and with some valuable input from some co-workers, we came up with this function which is a much more efficient solution in this matter than the experienced way you proposed. My purpose in even posting this function was so that other people could avoid having to go through the same problems I faced when using the proper and apparently experienced method that I only used because I listened to programmers like you (mind you, I said LIKE you, not YOU) who believe in standard procedure in all cases without considering more efficient options. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 3:11 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs Ok, as I said before, you can store whatever you please in your database. However, please don't speak as an experienced web programmer when not longer than three hours ago you finally found a solution to store quoted text in a database. Bogdan Jonathan Hilgeman wrote: I realize that part - my whole point was that it didn't really matter how it was stored as long as it gets extracted/parsed correctly. With that in mind, instead of using 3 functions to store, extract, and parse the data, I can use one function to prepare the data to be stored in a format that can be extracted directly into an form-friendly format. Not to mention that HTML entities are still ASCII characters, and I do not foresee any problems with using the HTML entities in place of quote marks. To me, it makes the most sense. Quote marks are generally special characters used everywhere, and storing them as quote marks instead of the entities seems to be asking for trouble, in my opinion. I've stored values using slashes for the past few years, and that method has given so many problems... Speaking as an experienced web programmer, I believe this is a much more practical method for a lot of us. -- 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] Fixed Quote Marks in Inputs
Ok, seems like I misjudged you and I apologize for that. I haven't changed my opinion about the very issue we've been discussing - only wanted to post the sentence above, just for the record. Bogdan Jonathan Hilgeman wrote: Apparently, the experienced way is to store them with slashes, which is what I've followed for years. I consider years of programming to be a fair amount of experience, thus qualifying me to be experienced. ANYHOW, after finally thinking a bit outside the box and with some valuable input from some co-workers, we came up with this function which is a much more efficient solution in this matter than the experienced way you proposed. My purpose in even posting this function was so that other people could avoid having to go through the same problems I faced when using the proper and apparently experienced method that I only used because I listened to programmers like you (mind you, I said LIKE you, not YOU) who believe in standard procedure in all cases without considering more efficient options. -- 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] Fixed Quote Marks in Inputs
And I apologize if I came off as ultra-defensive/rude. I had a bad day, a bright idea, and then felt like someone was tearing it to pieces. This is like the PHP soap opera. - Jonathan -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 3:44 PM To: Jonathan Hilgeman Cc: '[EMAIL PROTECTED]' Subject: Re: [PHP-DB] Fixed Quote Marks in Inputs Ok, seems like I misjudged you and I apologize for that. I haven't changed my opinion about the very issue we've been discussing - only wanted to post the sentence above, just for the record. Bogdan Jonathan Hilgeman wrote: Apparently, the experienced way is to store them with slashes, which is what I've followed for years. I consider years of programming to be a fair amount of experience, thus qualifying me to be experienced. ANYHOW, after finally thinking a bit outside the box and with some valuable input from some co-workers, we came up with this function which is a much more efficient solution in this matter than the experienced way you proposed. My purpose in even posting this function was so that other people could avoid having to go through the same problems I faced when using the proper and apparently experienced method that I only used because I listened to programmers like you (mind you, I said LIKE you, not YOU) who believe in standard procedure in all cases without considering more efficient options. -- 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 insert to DB from txt??? Please help
egrep_split? But then, there's the learning curve for grep... On Fri, 4 Jan 2002, Leotta, Natalie (NCI/IMS) wrote: There are a few ways to split up text based on a delimiter. I recommend you look at split and explode on the PHP.net site and see what seems to be best for your situation. Once you go to one of them they link you to other functions that do similar things. I believe explode is faster but I can't remember for sure. -Natalie -Original Message- From: Kelvin [SMTP:[EMAIL PROTECTED]] Sent: Friday, January 04, 2002 11:44 AM To: [EMAIL PROTECTED] Subject:[PHP-DB] How to insert to DB from txt??? Please help Hi everyone, I have a txt file which is contained the following: ,aaa,ccc,ddd ,aaa,ccc,ddd .etc. Now, I need to read the data from that file and than insert it into the table. insert into Table (name,pass,phone,somethingelse) Could someone help me out here, How to write the code? I know how to read from a txt file, but I don't know how to separate the data determine by , Please help, I'll be very appreciate.Thanks Kelvin. -- 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 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 insert to DB from txt??? Please help
you should maybe try the free dbtools mysql program from http://www.dbtools.com.br this can handle text file imports direct into a mysql db , also it can import or export from excell , access, paradox, foxpro , dbase or odbc data sources, very handy tool if all you ever use it for is the transfer of datatypedatatype.. Steven - Original Message - From: Kelvin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 04, 2002 4:44 PM Subject: [PHP-DB] How to insert to DB from txt??? Please help Hi everyone, I have a txt file which is contained the following: ,aaa,ccc,ddd ,aaa,ccc,ddd .etc. Now, I need to read the data from that file and than insert it into the table. insert into Table (name,pass,phone,somethingelse) Could someone help me out here, How to write the code? I know how to read from a txt file, but I don't know how to separate the data determine by , Please help, I'll be very appreciate.Thanks Kelvin. -- 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] Fixed Quote Marks in Inputs
Ok, finally found a valid argument! :-) What if the user enters I'm aware that 23!? Bogdan Jonathan Hilgeman wrote: And I apologize if I came off as ultra-defensive/rude. I had a bad day, a bright idea, and then felt like someone was tearing it to pieces. This is like the PHP soap opera. -- 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] match
Hi is it possible to match a certain string when a user submit's a form I mean, ex: i put pre on a form field, and php will match it and example deny it, oh well.. im new sorry.. :) thank you mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); # form.php ## ?php mysql_connect ('my_db_host','my_user','my_pass'); mysql_select_db ('my_db'); mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); print ($ircname); print ( ); print (p); print (Thanks for joining!); ? # form.php ## # form.html # html body form action=form.php method=GET Ircname: input type=text name=ircname size=25 maxlength=25br Email: input type=text name=email size=25 maxlength=25br Realname: input type=text name=realname size=25 maxlength=25br A/S/L: input type=text name=asl size=25 maxlength=25br Info: input type=text name=info size=25 maxlength=25br p input type=submit /form /body /html # form.html # -- 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] match
Why would this be a problem (i.e. the fact that a user may insert pre in a form field)? If you're worried about security (i.e. users adding JavaScript code) you can always htmlspecialchars() the string... Bogdan louie miranda wrote: Hi is it possible to match a certain string when a user submit's a form I mean, ex: i put pre on a form field, and php will match it and example deny it, oh well.. im new sorry.. :) thank you mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); # form.php ## ?php mysql_connect ('my_db_host','my_user','my_pass'); mysql_select_db ('my_db'); mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); print ($ircname); print ( ); print (p); print (Thanks for joining!); ? # form.php ## # form.html # html body form action=form.php method=GET Ircname: input type=text name=ircname size=25 maxlength=25br Email: input type=text name=email size=25 maxlength=25br Realname: input type=text name=realname size=25 maxlength=25br A/S/L: input type=text name=asl size=25 maxlength=25br Info: input type=text name=info size=25 maxlength=25br p input type=submit /form /body /html # form.html # -- 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] match
If you're trying to prevent HTML tags from being submitted then try htmlentities($your_variable). That'll convert for example pre to lt;pregt. David - Original Message - From: louie miranda [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 04, 2002 6:22 PM Subject: [PHP-DB] match Hi is it possible to match a certain string when a user submit's a form I mean, ex: i put pre on a form field, and php will match it and example deny it, oh well.. im new sorry.. :) thank you mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); # form.php ## ?php mysql_connect ('my_db_host','my_user','my_pass'); mysql_select_db ('my_db'); mysql_query (INSERT INTO members (ircname, email, realname, asl, info) VALUES ('$ircname','$email','$realname','$asl','$info') ); print ($ircname); print ( ); print (p); print (Thanks for joining!); ? # form.php ## # form.html # html body form action=form.php method=GET Ircname: input type=text name=ircname size=25 maxlength=25br Email: input type=text name=email size=25 maxlength=25br Realname: input type=text name=realname size=25 maxlength=25br A/S/L: input type=text name=asl size=25 maxlength=25br Info: input type=text name=info size=25 maxlength=25br p input type=submit /form /body /html # form.html # -- 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] Fixed Quote Marks in Inputs
Bogdan Stancescu wrote: Ok, finally found a valid argument! :-) What if the user enters I'm aware that 23!? Bogdan Tested it - it works. However, you'll have big problems if you'll ever need to echo the data. Consider this example: Enter description: input box The user enters Edited by Bogdan's wife [EMAIL PROTECTED]. You now want to store this. You'll first use your algorithm to convert the ' into #039;. You store the result in the database. Now you want to display this data. You retrieve Edited by Bogdan#039;s wife [EMAIL PROTECTED] from the database. What next? You can't simply echo this because that would apparently omit [EMAIL PROTECTED]. You can't htmlspecialchars() either because that would result in Edited by Bogdanamp;#039;s wife lt;[EMAIL PROTECTED]gt; which is not right. So there, that's why you should store the text as everybody else does. :-) Bogdan -- 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]