Re: [PHP-DB] [ Re: [PHP-DB] Filling Drop-Down Box.]
Hello Alex: It is really helpfull, :) thanks for your detailed reply regards, On Sat, 25 Dec 2004 23:57:51 +0200, Alexandru Mihai [EMAIL PROTECTED] wrote: SELECT name=student title=Student list OPTION value=---/OPTION ?PHP while ($row = mysql_fetch_array($result)) { ? OPTION value=?php echo $row[3]? title=Select student ?php echo $row[1], , $row[2]? ?php echo $row[3]?/OPTION ?php } ? /SELECT In this case I've assumed that you'll have in mysql the following table: row0: id (autoincrement) row1: Nick name row2: First name row3: Last name You can modify the code as you wish to get what you need. Alexandru Mihai Bastien Koert wrote: i suggest you google for this...there are a million examples of this kind of code bastien From: Nayyar Ahmed [EMAIL PROTECTED] Reply-To: Nayyar Ahmed [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Filling Drop-Down Box. Date: Sat, 25 Dec 2004 20:18:05 +0500 Hello All, I want to fill drop-down box from mysql table, if any body be kind to tell me a sample code :) e.g: In my application i want to gather subject list from current semester-subject table of a student. TIA -- Nayyar Ahmad Lecturer Faculty Of Computer Science, Institute Of Management Sciences, Hayat Abad Peshawar , Pakistan. Office : 92-091-9217404 , 9217452 Cell : 92-0333-9139461 -- 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 -- Nayyar Ahmad Lecturer Faculty Of Computer Science, Institute Of Management Sciences, Hayat Abad Peshawar , Pakistan. Office : 92-091-9217404 , 9217452 Cell : 92-0333-9139461 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto_increment
Thanks Larry. It was mySQL ... Ron On Sun, 26 Dec 2004 20:47:37 -0500, Larry E. Ullman wrote I have the auto_increment on one of my variables. During the past few days I have been doing testing on a live database and created several test records which I now have deleted from my table. Is there any way of setting the auto_increment value to match the last correct number? Ron You don't say what database application you're using, but if it's MySQL, you can change the auto increment value using: ALTER TABLE tablename AUTO_INCREMENT = 1 That being said, you actually don't have to do this (and often shouldn't, really). Having gaps in your auto increment sequence shouldn't be a problem. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP-DB] 'Illegal mix of collations' with PHP 4.3.10 and MySQL 4.1.7
[cut] DG I've got the same problem with PHP 5.0.2 and MySQL 4.1.8. I asked this DG question many times on different mailing lists but still haven't got DG satisfactory answer... That's the problem, I've reviewed different mailing lists as well but saw no reply... all problems that were presented regarding collation / charset were just simple I converted to MySQL 4.1 and now my queries won't work problems :/ [cut] DG AFAIK have to be DG default-character-set=latin2 DG at least this works for 'mysql' utility. This generates an error for my system (unknown configuration option default-character-set). This option works for the mysqld entry (the server), but not for the clients. I read this solution (character_set) in some mailing list reply. What's funny, when I did it, it SEEMED to work - PHP started crashing complaining about the lack of the latin2/Index.xml file. When I made a link to the file and added an additional entry for charset-default-dir, it stopped complaining... but didn't exactly start working :P [cut] DG Will have no effect. So I've noticed :) DG The thing is that source code of libmysql.dll/libmysqli.dll DOESN'T contain DG code for setting connection charset (as I was said on the MySQL list). So DG what we want seems to be impossible. Well, the problem is, it DID work. I mean, I know a solution would be to recompile libmysql.dll and add the default charset in it, but what I mean is not using a default, arbitrarily chosen character set, but chosing the character set implied by the locale or server default character set (or database default character set). DG Are there any comments from libmysql.dll/libmysqli.dll developers? I have not bothered them yet, I still don't know if this is a bug or just a configuration problem on my side :( -- Greetings, Piotr Wilkin [EMAIL PROTECTED] PGP key: http://pwl.yz.pl/pwlpgp.txt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] is this a problem ?
hallo, i have changed file signup1.php with login1.php, in action fied of form form name=form1 method=POST action=-- and saved . but when i run this file and click on submit button, it still shows old sighnup1.php. and data is also not entering in database. while it data was entering in databse before this. but not now with this change. no error shown. only shows previous page and no data entry __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
[PHP-DB] RE: How to process a query form with CHECKBOX RADIO not checkbox !
At 01:23 28/12/2004 +, you wrote: Date: Mon, 27 Dec 2004 17:22:49 -0800 (PST) From: S Kumar [EMAIL PROTECTED] To: php-db@lists.php.net, php-general@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: How to process a query form with CHECKBOX Please help DIVAge group/DIV DIVYounginput type=checkbox name= value=/DIV DIVMiddleinput type=checkbox name= value=/DIV DIVOldinput type=checkbox name= value=/DIV Problem: I want to capture the user options and create an SQL statement: You need to make your form action=post You also need to use a radio button because a patient may not be young *and* old for example. Radio buttons offer an 'either-or' selection, where a checkbox offers an 'and' selection. You also need to give the radio buttons a name (the same for each one in a group of options) eg input type=radio name=age id=age1 value=young / Young input type=radio name=age id=age2 value=middle / Middle input type=radio name=age id=age3 value=old / Old When you submit the form, PHP will have a variable in $_POST array which contains the value of the selection. It will be called the same as the name attribute in your input (radio) button : $allowed_ages = array(young, middle, old); $age_group = $_POST[age]; // We should check that the value is of the types we allow into the database // this will prevent form spoofing because we're checking for an exact match if (in_array($age_group, $allowed_ages)) { // At this point we should make a connection to the database. // Well make the resource called $link and it will be used below $link=mysql_connect(my_server, my_username, my_password); // There may be multiple *databases* on the server, each with lots of *tables* mysql_select_db(my_database_name, $link); $query=INSERT INTO patient_data (age_group) VALUES ('.$age_group.'); // Execute query mysql_query($query, $link); // Check for success if (mysql_error($link)) { // Something went wrong with the query print(Error in query : .$query); } else { // Print success print(Your record was added); } } else { // We were receiving a spoofed form entry which could break the database print(Value is not acceptable); exit; } Select age_group from patient_data where age_group = young and old ; Just use SELECT * FROM patient_data WHERE age_group IN (young, old) There would be no point in selecting age_group because all you'll get is a list of young-old-old-old-young etc without any useful information. If you wanted to know *how many* young and old (a summary) you'd use GROUP BY eg SELECT age_group, COUNT(age_group) FROM patient_data WHERE age_group IN (young, old) GROUP BY age_group so you'd get == young 15 old 24 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] is this a problem ?
amol patil wrote: hallo, i have changed file signup1.php with login1.php, in action fied of form form name=form1 method=POST action=-- and saved . but when i run this file and click on submit button, it still shows old sighnup1.php. and data is also not entering in database. while it data was entering in databse before this. but not now with this change. no error shown. only shows previous page and no data entry Amol: Please slow down and do some basic debugging as Cpt. Holmes suggests. You need to be able to trace your form submittal every step of the way. You can do this by carefully observing your browser, page source (as it is received by your browser), your browser's Javascript console, your server logs (both access and error logs). You should insert debug statments in your script as necessary so you can tell exactly what is happening. You have not responded to my previous reply, namely: --Are you getting any messages in your webserver error log when you click on 'submit'? (And let me add: Are you even getting a second hit on your webserver access log when you submit your form? You may not be leaving the browser when you click on submit.) --Try including an 'else' in your 'if' statement (along with a debug message) so you can see if the 'submit' is detected by your script when the form is submitted. -John -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] is this a problem ?
There are scores of examples / tutorials on this. Google turned up 6,070 hits on this expression: add user php mysql example Here's one of them, although it assumes register globals is on http://www.php-scripts.com/php_diary/072000.php3 Why don't you pick one, work with it and adapt it to your needs. However, why is your form's action parameter set to a string of hyphens? Regards - Miles Thompson At 09:25 AM 12/28/2004, amol patil wrote: hallo, i have changed file signup1.php with login1.php, in action fied of form form name=form1 method=POST action=-- and saved . but when i run this file and click on submit button, it still shows old sighnup1.php. and data is also not entering in database. while it data was entering in databse before this. but not now with this change. no error shown. only shows previous page and no data entry __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] is this a problem ?
On Tue 28 Dec 04, 11:44 AM, Miles Thompson [EMAIL PROTECTED] said: At 09:25 AM 12/28/2004, amol patil wrote: hallo, i have changed file signup1.php with login1.php, in action fied of form form name=form1 method=POST action=-- and saved . but when i run this file and click on submit button, it still shows old sighnup1.php. and data is also not entering in database. while it data was entering in databse before this. but not now with this change. no error shown. only shows previous page and no data entry There are scores of examples / tutorials on this. Google turned up 6,070 hits on this expression: add user php mysql example Here's one of them, although it assumes register globals is on http://www.php-scripts.com/php_diary/072000.php3 Why don't you pick one, work with it and adapt it to your needs. However, why is your form's action parameter set to a string of hyphens? Regards - Miles Thompson Agreed. Also, you'd get *much* better replies to your request for help if you read this: http://www.catb.org/~esr/faqs/smart-questions.html Sometimes it's very difficult to ask a good question, and I think esr breaks his own rule (volume is not precision), but he says all the right things, and has some excellent advice. This isn't meant to be a put-down or a joke. Most people think that asking a question absolves them of thinking. Like a quick-fix. On the contrary, asking a good question can be a lot of work. Respectfully, Pete -- The mathematics of physics has become ever more abstract, rather than more complicated. The mind of God appears to be abstract but not complicated. He also appears to like group theory. -- Tony Zee's Fearful Symmetry GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Site optimization
While my PHP/MySQL-based sites work quickly on my development computer, as well on servers where I know the traffic load is low, I'm concerned about how they'll perform under heavy loads, and whether or not I need to simplify MySQL queries or PHP code in order to speed up page delivery. Does anyone have any suggestions as to how to simulate site performance under heavy traffic load, and then, should results be poor, how to optimize code to perform better? I have a guess this might be a tip of the iceberg question that may lead to more questions, but I guess you have to start somewhere. Thanks, V -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Site optimization
i was wondering this as well :D are there any tools out there to simulate high traffic on your web server say where you specify how many users hit the site at one time and the tool actually hits your server that many times? -- Joseph Crawford Jr. Codebowl Solutions [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Site optimization
On Tue 28 Dec 04, 12:11 PM, Joseph Crawford [EMAIL PROTECTED] said: i was wondering this as well :D are there any tools out there to simulate high traffic on your web server say where you specify how many users hit the site at one time and the tool actually hits your server that many times? Is this what you're looking for? http://www.linuxjournal.com/article/6691 Pete -- The mathematics of physics has become ever more abstract, rather than more complicated. The mind of God appears to be abstract but not complicated. He also appears to like group theory. -- Tony Zee's Fearful Symmetry GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Site optimization
Hello, on 12/28/2004 02:50 PM [EMAIL PROTECTED] said the following: While my PHP/MySQL-based sites work quickly on my development computer, as well on servers where I know the traffic load is low, I'm concerned about how they'll perform under heavy loads, and whether or not I need to simplify MySQL queries or PHP code in order to speed up page delivery. Does anyone have any suggestions as to how to simulate site performance under heavy traffic load, and then, should results be poor, how to optimize code to perform better? You may want to try the ab program that comes with Apache. This may sound curious, but the best way to speedup database driven sites is to avoid database accesses as much as possible. What I do to reduce the eventual performance penalty as the site audience increases is to determine which pages lead to more repeated SELECT queries and use server side caches to reduce the need to execute such queries. For instance, if you have a content site, the content page scripts tend to execute the same queries over and over again. This is the kind of queries that can be optimized away by employing a server side cache system. I use this generic cache class to store cached the pages in server side files. Since the class can store generic data I can cache either full pages, just some parts of the pages or even the contents of variables or query result sets arrays by using the PHP serialize/unserialize functions to store the variables data as a single string. The class lets me set a expiry period or a date to determine when the cached data is no longer valid and forcing the cached data to be regenerated next time it is accessed. However, I use a more efficient way manage cached data that consists in calling a function of the cache class named voidcache that simply removes the cache data in a safe way, when the site executes some operation that updates cached content in the database. This class is very robust as it employs safe locking to prevent that simultaneous accesses attempt to update the cache file at the same time, thus avoiding eventual corruption. I started using this class because I have a site that started growing so much in popularity, that I had to save as much queries as possible on every content page. Currently, this site uses over 35,000 cache files to save as much database queries as possible. The class and its support forum is available here: http://www.phpclasses.org/filecache -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Getting total results
Hello everybody, I am trying to split results comming from a mysql db with php into more html pages. Example: Results 1-10 out of 100 Therefor I limit the sql statement with: limit 1, 10 The sql statement is very complex. So far I have always used the same statement but without the limit and with a count inside to get the total number of results. Now with this statement it would be a huge decrease in performance. Is there a way to work with the limit statement, but to get the total number of results? As far as I know the LIMIT command only limits the visiblity, but mysql queries all the data. Any ideas which could help? Thank you in advance, Merlin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting total results
Merlin wrote: I am trying to split results comming from a mysql db with php into more html pages. Example: Results 1-10 out of 100 Therefor I limit the sql statement with: limit 1, 10 The sql statement is very complex. So far I have always used the same statement but without the limit and with a count inside to get the total number of results. Now with this statement it would be a huge decrease in performance. Is there a way to work with the limit statement, but to get the total number of results? As far as I know the LIMIT command only limits the visiblity, but mysql queries all the data. What version of MySQL? If 4.0+ you could use SELECT SQL_CALC_FOUND_ROWS column1, column2, ... FROM TABLE WHERE ... LIMIT x,y to get the rows you want to retrieve and then use SELECT FOUND_ROWS() to get the total number of rows there would have been without the limit. Still two queries (no way around that, anyhow), but hopefully optimized better by MySQL. Perform your own tests, of course. See the documentation on FOUND_ROWS() at the following URL for more info: http://dev.mysql.com/doc/mysql/en/Information_functions.html -- ---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] Getting total results
this is a good method, however i created a paging class in php 5 and i believe i still have it here locally in php 4 i will get the link soon :D -- Joseph Crawford Jr. Codebowl Solutions [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting total results
http://www.weberdev.com/get_example-4005.html that is the url to the PHP 5 object i created, it was created to show the use of the singleton pattern. This means you can only use this class to have one pager per page. i can edit the code if you do not know how to make it so you can have more than one per page. the php 4 version i will need to zip up locally here and will post it @ http://codebowl.dontexist.org/pager_php4.zip -- Joseph Crawford Jr. Codebowl Solutions [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting total results
php 4 version is posted, let me know if you like it or not. Please keep in mind it is a very basic class, you could extend this in many ways, especially to make the nav bar do something like 1 2 3 4 25 26 27 28 -- Joseph Crawford Jr. Codebowl Solutions [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Problem with permissions Win32 dba_open
Hi all, Season's Greetings! I am testing my PHP scripts locally under XP Home SP2 / Apache 1.3.23 / PHP 4.3.10 but I can't get a simple DBM script to work. No problem running it on my remote site, under Unix with gdbm though. Locally, phpinfo() gives: DBA support: enabled Supported handlers: cdb cdb_make db3 inifile flatfile This encourages me to think that I could open a database with db3, but I just can't get passed the dba_open command, which always fails with Permission denied. $db = dba_open(C:\Apache\htdocs\test.db, c , db3) // for example What am I doing wrong please? Thanks for your help, Ian PS This appears to be a fixed bug (http://bugs.php.net/bug.php?id=28122) but I still get permission denied. Why? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting total results
Joseph Crawford wrote: http://www.weberdev.com/get_example-4005.html that is the url to the PHP 5 object i created, it was created to show the use of the singleton pattern. This means you can only use this class to have one pager per page. i can edit the code if you do not know how to make it so you can have more than one per page. So you're proposing he uses this class and loads the _entire_ result of a query (with no LIMIT) into an array, then passes that to your class which chops it up into pages and then displays one of them? Do you really think that's more efficient? The question was about how to make two queries more efficient: SELECT ... FROM table WHERE ... LIMIT x,y SELECT COUNT(*) FROM table WHERE ... -- ---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] Problem with permissions Win32 dba_open
is your ms firewall turned on? ms sp2 screws a lot of stuff up.. bastien From: Ian [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Problem with permissions Win32 dba_open Date: Tue, 28 Dec 2004 23:36:08 - Hi all, Season's Greetings! I am testing my PHP scripts locally under XP Home SP2 / Apache 1.3.23 / PHP 4.3.10 but I can't get a simple DBM script to work. No problem running it on my remote site, under Unix with gdbm though. Locally, phpinfo() gives: DBA support: enabled Supported handlers: cdb cdb_make db3 inifile flatfile This encourages me to think that I could open a database with db3, but I just can't get passed the dba_open command, which always fails with Permission denied. $db = dba_open(C:\Apache\htdocs\test.db, c , db3) // for example What am I doing wrong please? Thanks for your help, Ian PS This appears to be a fixed bug (http://bugs.php.net/bug.php?id=28122) but I still get permission denied. Why? -- 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 set submit.
HI, Plesase search for post in last some days this issue has been discussed several time in the list. BTW double check the name of form submit button and register_global position. zareef ahmed On Mon, 27 Dec 2004 04:45:58 -0800 (PST), amol patil [EMAIL PROTECTED] wrote: hallo, clicking on submit entered info. is not entering in database. how to set submit , so that query wll execute correctly. ?php if($submit) { $dbh=mysql_connect (localhost, root) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db (dollar1_allinfo); mysql_query(INSERT INTO totalinfo (Username,Password) VALUES ('$loginusername','$loginpassword'))or die (mysql_error()); } ? thank you. - Do you Yahoo!? Send a seasonal email greeting and help others. Do good. -- Zareef Ahmed :: A PHP Developer in India ( Delhi ) Homepage :: http://www.zareef.net -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php