[PHP-DB] More help with mysql
Hi all I have successfully managed to connect to the mysql database, using the following code: mysql_connect('localhost','php','***') || die ("Unable to connect to MySQL server."); $db = mysql_select_db("DB_NAME") || die ("Unable to select requested database."); I then issue the following command: $result = mysql_query("SELECT * FROM SOME_TABLE") || die(mysql_error()); This does not result in any error. Now, of course, I want to work with the data returned, so I go: if (mysql_num_rows($result) > 0) { // do some stuff } else { // do some other stuff }; However, this gives me: "Supplied argument is not a valid MySQL result resource." If I go: echo "$result", I get '1', so I know $result actually has some value. What am I doing wrong? Basically, I want to do the simplest thing: get data out of a table and step through the results, displaying them one by one. Why is this hard? Evan Morris [EMAIL PROTECTED] Tel: +27 11 792 2777 Fax: +27 11 792 2711 Cell: +27 82 926 3630 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ftp search script
Does anyone know of a script out there that allows a user to seach through an FTP site for files. Like a search engine for a site, but searching throught FTP instead. Let me know if you do. Thanks. Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Recordsets and associative arrays
Hi Don, Use this process: $value){ $data[$row][$key] = $value; } $row++; } ?> The array structure would be something like this: $data[0]['Name'] = 'Name 1'; $data[0]['Address'] = 'Address1'; $data[0]['City'] = 'City1'; $data[1]['Name'] = 'Name 2'; $data[1]['Address'] = 'Address2'; $data[1]['City'] = 'City2'; $data[2]['Name'] = 'Name 3'; $data[2]['Address'] = 'Address3'; $data[2]['City'] = 'City3'; etc etc HTH Adam - Original Message - Message-ID: <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] From: "Don Briggs" <[EMAIL PROTECTED]> Date: Mon, 17 Feb 2003 16:42:51 -0600 Subject: Recordsets and associative arrays Hello. I am having a problem with syntax. Here is what I am doing. I have the follwing table |Name|Address |City| = |Name 1 | Address1 | City1 | |Name 2 | Address2 | City2 | |Name 3 | Address3 | City3 | |Name 4 | Address4 | City4 | = I can fetch a single record into an associative array. But I need to put these records into an multi-dimentional associatave array. I have tried to figure out what the syntax should be, but it has not worked. The only thing is that the key names will be different from the field names, and we won't be putting all of the record fields into the table. So we can't just make an array of the associative arrays returned by mysql_fetcharray($result). Hope you can help me out. Don! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP and Oracle
helloo Everyone... A new guest to the list needs your hlep!!. I am about to start working on a project in which im going to use Oralce with PHP4. I am new to PHP. I am looking for a good book about working with "PHP4 and Oracle" to help me pick up the basics as well as get the depth that i am looking for. To give you a better idea regaring depth, I'll be working on a Web-enabled college registration system. Students log into a web page to view, choose, and register courses. They should be able to view their time tables, grades, personal information ...etc. I need help as soon as possible. Please help. Thanks - Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day
[PHP-DB] Recordsets and associative arrays
Hello. I am having a problem with syntax. Here is what I am doing. I have the follwing table |Name|Address |City| = |Name 1 | Address1 | City1 | |Name 2 | Address2 | City2 | |Name 3 | Address3 | City3 | |Name 4 | Address4 | City4 | = I can fetch a single record into an associative array. But I need to put these records into an multi-dimentional associatave array. I have tried to figure out what the syntax should be, but it has not worked. The only thing is that the key names will be different from the field names, and we won't be putting all of the record fields into the table. So we can't just make an array of the associative arrays returned by mysql_fetcharray($result). Hope you can help me out. Don! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: WG: [PHP-DB] Confirmation e-mail
On Mon, 17 Feb 2003 13:57:35 -0800, Leo G. Divingracia III <[EMAIL PROTECTED]> wrote: you dont. your confirmation email will tell them once they are logged in with a random password your script made, then they can go into the profiles section and change the password. just have a boolean column that is set once they are confirmed. you can check that against another column that holds the value when they first signed up. Davy Obdam wrote: Hi Andreas, Thanks for you responce. I am also wondering how you would do that in the database, i have a table users in my MySQL database containing the users information that submitted when they registerd. Now i want to activate thier account only after they have clicked on the confirmation link... if possible without any additional tables in my db. I users do not confirm thier account i wanna remove thier data from the database after 48hours. Thanks for your time.. Best regards, Davy Obdam info@phpken wrote: hi, too please don't send password over the internet. better you ask the user if they click the link below your email. then the user get a formular and there you can ask him for his password. then you can make sure the emails wasn't read by other user. this is a secure method. Just create a hash, insert it into the users table. (update users set 'confirmhash' = '$confirmhash' where xyz) Create an email to the user with the hash in the link. e.g. http://site.com/verify.php?ch=823jfs98d283r92h Do a update/select for the hash, and activate the account. _BB -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] consistently format large amounts of content
I'm looking for an easy and efficient way to format lots of similar content in a database for easy retrieval and possible ways to alter formatting of all the content in the future using a template. Basically, the content is knowledgebase type information like articles on a topic, etc. The content (each row of the database) is all formatted simmilarly. Some ideas I have. -Use common tages, H1, H2, P, UL, etc. and use CSS against these. -XML? - don't know anything about this. -Invent my own tagging system and preprocess the data before it's displayed. Anyone have experience doing something like this? Should I look into other technologies? _BB -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: WG: [PHP-DB] Confirmation e-mail
you dont. your confirmation email will tell them once they are logged in with a random password your script made, then they can go into the profiles section and change the password. just have a boolean column that is set once they are confirmed. you can check that against another column that holds the value when they first signed up. Davy Obdam wrote: Hi Andreas, Thanks for you responce. I am also wondering how you would do that in the database, i have a table users in my MySQL database containing the users information that submitted when they registerd. Now i want to activate thier account only after they have clicked on the confirmation link... if possible without any additional tables in my db. I users do not confirm thier account i wanna remove thier data from the database after 48hours. Thanks for your time.. Best regards, Davy Obdam info@phpken wrote: hi, too please don't send password over the internet. better you ask the user if they click the link below your email. then the user get a formular and there you can ask him for his password. then you can make sure the emails wasn't read by other user. this is a secure method. -- Leo G. Divinagracia III [EMAIL PROTECTED] z -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Erro na passagem de parametros
Hi Bruno Pereira, > Then in english > I can´t pass values from a form in html to a php file. Be so kind and post the code of your html-page and your php-script. So we can try to test it and can say if there are some errors in the code or the problem must be in misconfiguration of the httpd-configfiles or the php.ini. Regards, Ruprecht -- Ruprecht Helms IT-Service und Softwareentwicklung Tel/Fax.: +49[0]7621 16 99 16 Homepage: http://www.rheyn.de email: [EMAIL PROTECTED] -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mac OS X.2.4 Upgrade Breaks PHP... need help !!!
Weston, I feel absolutely ignorant, but again I'm still pretty new to Unix. I looked at httpd.conf and httpd.conf.applesaved. Upon upgrading to Mac OS X.2.4, the new httpd.conf file commented out the LoadModule php4_module and the AddModule mod_php4.c commands. Once I uncommented out those to lines and restarted Apache (sudo apachectl restart) php functionality returned! I deserve to reinstall from scratch again as a memory of this occasion. Will always be learning, and hopefully someday I'll have a much better handle on Unix. Thanks for helping. :) On Monday, February 17, 2003, at 03:39 PM, Weston Houghton wrote: The OS 10.2.4 upgrade merely adds a new httpd.conf file at /etc/httpd/httpd.conf, while archiving your old conf file in the same location. All you need to do is merge the 2 conf files, as there are additions in the new one installed. Once you do that and restart apache, you'll be fine. Wes On Monday, February 17, 2003, at 03:36 PM, Allens wrote: Quick alert to all, upgraded to OS X.2.4 last Thursday evening. PHP no longer works when testing locally. Here is what is happening: 1. Installed the upgrade. Am using my Mac as a test server. 2. Before upgrade, was runnning Mac OS X.2.3, MySQL 3.23.47, PHP 4.3 3. Used http://localhost/... to test my db's. Web sharing itself via localhost worked fine... http://localhost would show the Apache default page... version 1.3.27. Tried http://localhost/test.php, only showed the text in the browser, . 4. Worked until upgrading to Mac OS X.2.4. Once I did this, the php pages loaded as text files (could see the code, but no php interaction to activate the page) in the browser (OmniWeb, IE 5.2.2, Safari 1.0beta v60). Basic web sharing worked fine though from #3 above. 5. Tried to reinstall php 4.3, then all the browsers listed started to just download each php page to the desktop. Came up with a prompt of what to do in IE 5.2.2... MIME = application/x-httpd/php. Again, http://localhost/test.php downloaded the file to the desktop for all browsers. 6. Called Apple Support Pro and let them know. Was asked to perform and Archive Install of Mac OS X.2. Did this. Reinstalled PHP 4.3. Worked fine. Was able to see my test site via http://localhost/ PHP activity was back to normal on testing my local db's. http://localhost/test.php worked, showing the information you would expect from this page. 7. Reinstalled the Mac OS X.2.4 upgrade via Software Update. 8. Upon restart, PHP functionality again failed on http://localhost/test.php. Showed the text in the browser, . No PHP functionality, but MySQL works from the >> Terminal. 9. I do have some remote sites that use MySQL/PHP and was able to connect to those sites just fine. Seems that Mac OS X.2.4 has broke PHP from working locally as a test server somehow? Called Apple back and they are sending this up to the Engineering Group. I use my laptop as a test server as well, and the same is true for it as well, PHP is broke for local use. Please don't upgrade to Mac OS X.2.4 if you use your workstation as a test server using PHP! Hope this gets out before many upgrade and enjoy reinstalling from scratch as I must to get back to Mac OS X.2.3. Must use my Mac and laptop as a test server for Mysql/PHP site. :( :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (: --- The selection and placement of letters on this page was determined automatically by a computer program. Any resemblance to actual words, sentences, or paragraphs is pure coincidence, and no liability will be assumed for such coincidences. --- :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (:
Re: [PHP-DB] Mac OS X.2.4 Upgrade Breaks PHP... need help !!!
The OS 10.2.4 upgrade merely adds a new httpd.conf file at /etc/httpd/httpd.conf, while archiving your old conf file in the same location. All you need to do is merge the 2 conf files, as there are additions in the new one installed. Once you do that and restart apache, you'll be fine. Wes On Monday, February 17, 2003, at 03:36 PM, Allens wrote: Quick alert to all, upgraded to OS X.2.4 last Thursday evening. PHP no longer works when testing locally. Here is what is happening: 1. Installed the upgrade. Am using my Mac as a test server. 2. Before upgrade, was runnning Mac OS X.2.3, MySQL 3.23.47, PHP 4.3 3. Used http://localhost/... to test my db's. Web sharing itself via localhost worked fine... http://localhost would show the Apache default page... version 1.3.27. Tried http://localhost/test.php, only showed the text in the browser, . 4. Worked until upgrading to Mac OS X.2.4. Once I did this, the php pages loaded as text files (could see the code, but no php interaction to activate the page) in the browser (OmniWeb, IE 5.2.2, Safari 1.0beta v60). Basic web sharing worked fine though from #3 above. 5. Tried to reinstall php 4.3, then all the browsers listed started to just download each php page to the desktop. Came up with a prompt of what to do in IE 5.2.2... MIME = application/x-httpd/php. Again, http://localhost/test.php downloaded the file to the desktop for all browsers. 6. Called Apple Support Pro and let them know. Was asked to perform and Archive Install of Mac OS X.2. Did this. Reinstalled PHP 4.3. Worked fine. Was able to see my test site via http://localhost/ PHP activity was back to normal on testing my local db's. http://localhost/test.php worked, showing the information you would expect from this page. 7. Reinstalled the Mac OS X.2.4 upgrade via Software Update. 8. Upon restart, PHP functionality again failed on http://localhost/test.php. Showed the text in the browser, . No PHP functionality, but MySQL works from the Terminal. 9. I do have some remote sites that use MySQL/PHP and was able to connect to those sites just fine. Seems that Mac OS X.2.4 has broke PHP from working locally as a test server somehow? Called Apple back and they are sending this up to the Engineering Group. I use my laptop as a test server as well, and the same is true for it as well, PHP is broke for local use. Please don't upgrade to Mac OS X.2.4 if you use your workstation as a test server using PHP! Hope this gets out before many upgrade and enjoy reinstalling from scratch as I must to get back to Mac OS X.2.3. Must use my Mac and laptop as a test server for Mysql/PHP site. :( :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (: --- The selection and placement of letters on this page was determined automatically by a computer program. Any resemblance to actual words, sentences, or paragraphs is pure coincidence, and no liability will be assumed for such coincidences. --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql +php
Thanks got it working -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mac OS X.2.4 Upgrade Breaks PHP... need help !!!
Quick alert to all, upgraded to OS X.2.4 last Thursday evening. PHP no longer works when testing locally. Here is what is happening: 1. Installed the upgrade. Am using my Mac as a test server. 2. Before upgrade, was runnning Mac OS X.2.3, MySQL 3.23.47, PHP 4.3 3. Used http://localhost/... to test my db's. Web sharing itself via localhost worked fine... http://localhost would show the Apache default page... version 1.3.27. Tried http://localhost/test.php, only showed the text in the browser, . 4. Worked until upgrading to Mac OS X.2.4. Once I did this, the php pages loaded as text files (could see the code, but no php interaction to activate the page) in the browser (OmniWeb, IE 5.2.2, Safari 1.0beta v60). Basic web sharing worked fine though from #3 above. 5. Tried to reinstall php 4.3, then all the browsers listed started to just download each php page to the desktop. Came up with a prompt of what to do in IE 5.2.2... MIME = application/x-httpd/php. Again, http://localhost/test.php downloaded the file to the desktop for all browsers. 6. Called Apple Support Pro and let them know. Was asked to perform and Archive Install of Mac OS X.2. Did this. Reinstalled PHP 4.3. Worked fine. Was able to see my test site via http://localhost/ PHP activity was back to normal on testing my local db's. http://localhost/test.php worked, showing the information you would expect from this page. 7. Reinstalled the Mac OS X.2.4 upgrade via Software Update. 8. Upon restart, PHP functionality again failed on http://localhost/test.php. Showed the text in the browser, . No PHP functionality, but MySQL works from the Terminal. 9. I do have some remote sites that use MySQL/PHP and was able to connect to those sites just fine. Seems that Mac OS X.2.4 has broke PHP from working locally as a test server somehow? Called Apple back and they are sending this up to the Engineering Group. I use my laptop as a test server as well, and the same is true for it as well, PHP is broke for local use. Please don't upgrade to Mac OS X.2.4 if you use your workstation as a test server using PHP! Hope this gets out before many upgrade and enjoy reinstalling from scratch as I must to get back to Mac OS X.2.3. Must use my Mac and laptop as a test server for Mysql/PHP site. :( :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (:
RE: [PHP-DB] Newbie Question - PHP and MSACCESS
//Place your request into a variable: $result = odbc_do($connection,"select * from events where id=$id"); $var = odbc_fetch_row($result); // Now you have an array to work on foreach($var as $line){ //Do your formatting thusly: echo ' ' . $line[0] . ' ' . $line[1] . ' ... } Hi, Am using php to open a customer's msaccess file. First time for everything. It's a very small database of less then 25 rows, and will always be this small. Am needing to return all the rows to a web page using php at all times. Very simplistic. Am apparently set up correctly on the DSN, and am able to do an odbc_connect: $connection = odbc_connect("meetings","",""); Am able to fetch rows, or so it seems: $result = odbc_do($connection,"select * from events where id=$id"); odbc_fetch_row($result); Am not understanding how to "print()" the fields in the rows, one after the next, on the same line, and then do the same with the next record, until all records have been presented. Sorry to be lame. Any help would be gratefully received. -Joe
RE: [PHP-DB] ping
see: http://www.php.net/manual/en/ref.exec.php -Original Message- From: bo [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 12:29 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] ping Hi, This is not exactly fall in the category of php and mysql, but hopefully that you can shed a light for me. My question is how can we write a php ping script to ping some website and output the ip address of the website automatically on webpage? It's the same idea that ping www.google.com in cmd prompt(@win2k)but output the result in a webpage. Any feedbacks and info will be appreciated. Thanks. Bo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] ping
Hi, This is not exactly fall in the category of php and mysql, but hopefully that you can shed a light for me. My question is how can we write a php ping script to ping some website and output the ip address of the website automatically on webpage? It's the same idea that ping www.google.com in cmd prompt(@win2k)but output the result in a webpage. Any feedbacks and info will be appreciated. Thanks. Bo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql +php
BTW... you'll need something in the anchor: while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo "Something"; -Original Message- From: Ryan Jameson (USA) Sent: Monday, February 17, 2003 12:16 PM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql +php while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo ""; That's how I'd do it. <>< Ryan -Original Message- From: G [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 8:16 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql +php Hi I was wonder if any knows how 2 display sound clips held in a mysql database using a php page ? I have stored the urls of the clips in mysql database and I belive I need some like to (below) to display them but its not quite working. while ($row= mysql_fetch_row($result)) //retrieve a row and store in array $row { for($i=0; $i"); // any ideas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql +php
while ($row= mysql_fetch_array($result)) //retrieve a row and store in echo ""; That's how I'd do it. <>< Ryan -Original Message- From: G [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 8:16 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql +php Hi I was wonder if any knows how 2 display sound clips held in a mysql database using a php page ? I have stored the urls of the clips in mysql database and I belive I need some like to (below) to display them but its not quite working. while ($row= mysql_fetch_row($result)) //retrieve a row and store in array $row { for($i=0; $i"); // any ideas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql +php
Hi I was wonder if any knows how 2 display sound clips held in a mysql database using a php page ? I have stored the urls of the clips in mysql database and I belive I need some like to (below) to display them but its not quite working. while ($row= mysql_fetch_row($result)) //retrieve a row and store in array $row { for($i=0; $i echo (""); // any ideas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Erro na passagem de parametros
ERRO meu, my mistake 1º em portugues Boa tarde, Não consigo passar os valores de uma form para um ficheiro em php, em vex de mostrar só o valor da variavel, mostra o proprio código, penso que seja uma configuração no httpd.conf, mas não sei qual? Obrigado Then in english I can´t pass values from a form in html to a php file. It should just show the value from the var but it is showing the interied code php. I think if some kind configuration of the httpd.conf file, but i dont no where? Thanks Cumprimentos Bruno Pereira [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Erro na passagem de parametros
1º em portugues Boa tarde, Não consigo passar os valores de uma form para um ficheiro em php, em vex de mostrar só o valor da variavel, mostra o proprio código, penso que seja uma configuração no httpd.conf, mas não sei qual? Obrigado Then in english I can´t pass values from a form in html to a php file. It should just show the value from the var but it is showing the interied code php. I think if some kind configuration of the httpd.conf file, but i dont no where? Thanks Cumprimentos Bruno Pereira [EMAIL PROTECTED] -Original Message- From: Dimas Alberto Ayala Escobar [mailto:[EMAIL PROTECTED]] Sent: segunda-feira, 17 de Fevereiro de 2003 16:31 To: [EMAIL PROTECTED] Subject: [PHP-DB] Suscribirse Espero poder suscribirme a su lista. Como lo hago. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Suscribirse
Espero poder suscribirme a su lista. Como lo hago.
RE: [PHP-DB] array with two dimensions
There are really a few ways that you can solve this problem. I would use and associative array to do this. Making the array associative would work like this: $ALL_VALUES["$year"] += $value; To retrieve the information back you would use the following loop: While($element = each($ALL_VALUES)) { echo $element[ "key" ]; //this would display the year echo $element[ "value" ]; //displays the value associated with the year } Hope that helps, I have tested it and it works for me Kelly Protsko -Original Message- From: Lars Rasmussen [mailto:[EMAIL PROTECTED]] Sent: February 17, 2003 8:28 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] array with two dimensions Hi all, Got a little problem here, I have a mysql query that looks like this SELECT SUM(value) as value, YEAR(dileveret) as year FROM table GROUP BY YEAR(dileveret) It works just fine, but i need to make a array that can could do somthing like this (know it doesent work) $ALL_VALUES[$year] += $value; The script is running the script up to 100 times to get all the specific data's, i hope that you know a way that i can hold the values, and year and later print one value for each year.. THANKS A LOT! Regards Lasse (newbie) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Fwd: When to do free()?
I use pearDB to abstract the databse. It has a free() call which says it frees the resources for that result set. It is a method on DB_Result (which is what you get back when you do a query()). http://pear.php.net/manual/en/core.db.free.php -Dave Allens wrote: From: Allens <[EMAIL PROTECTED]>David, I'm still very new to PHP and MySQL, but here is what I've found. Couldn't find any references to the free() function except for this at the www.mysql.com website. On "How memory is used in MySQL", "lmost all parsing and calculating is done in a local memory store. No memory overhead is needed for small items and the normal slow memory allocation and freeing is avoided. Memory is allocated only for unexpectedly large strings (this is done with malloc() and free() ). " From what I've read, MySQL frees memory automatically when regular function calls from the web back to the server that return data are executed. I'm going out on a limb because I'm not sure and this is a good way for me to learn as well. Couldn't find any real info on the free() function in the php manual or mysql manual nor in any of the manuals I have. I have about 50 users hitting our lone db, but no memory issues have occurred to date. Using Mac OS X Server 10.2.3 on Mac Server 533MHz 1GB of memory with MySQL 3.23.51. Hope this isn't wasted reading? :) On Sunday, February 16, 2003, at 07:39 PM, [EMAIL PROTECTED] wrote: Re: When to do free()? 25667 by: David Chamberlin From: David Chamberlin <[EMAIL PROTECTED]> Date: Sun Feb 16, 2003 11:19:17 AM US/Eastern To: [EMAIL PROTECTED] Subject: Re: When to do free()? Hmmm...still no takers on this one I decided out of curiosity to start liberally adding free() calls whenever I did a db->query(). Unfortunately it seems that the free() call causes it to die. Not quite sure why, but it did. Most of the calls that I use a query() for (as opposed to getAll() or getOne()) are INSERT/UPDATE/DELETE. Is there some reason you shouldn't do a free() after one of those? I'm still baffled. And still don't know if I should be using disconnect() at the end of each of my pages Any thoughts? Thanks, Dave David Chamberlin wrote: Hello, I'm currently using pear DB to abstract out use of my mysql database. Everything is generally working fine, except that it seems that performance seems to degrade the more it is used, then I get my ISP to restart mysql and everything seems to be good again for a while, then it degrades, lather-rinse-repeat. I'm currently one of the only ones using mysql at my ISP, so it seems that whatever I'm doing is causing issues. For the most part I'm not doing anything complex, queries are relatively simple and the dbases are currently pretty small. So while thinking about the issue, one thing that occured to me is that I'm not doing a free() on the query results when I'm done with them. That's mostly because very few of the examples I've seen ever do this, so I assumed it was an optimization that generally wasn't necessary. Furthermore, I figured that after my page got loaded, the connection to the db would be terminated and the resources freed, so the extent of the "resource leak" would be pretty minimal. Well, now I'm questioning the validity of those assumptions and I'm wondering if I need to start adding liberal use of free(), and I'm wondering to what extent it needs to be done? So first question, for those familiar with pearDB. It seems that certainly after doing a query() I should do a free(). What about getAll() (and related question, is there much difference between doing a query() and getAll())?). The docs seem to indicate a getOne() automatically frees resources, so I don't need to do it there. Next question is, what happens when no one refers to a result any more? Will a destructor get called that automatically frees the result? Or should I make sure to do the free before the reference is lost? How long are resources held if you don't free them? Finally, I assume that when you fetch data from a result that the data is copied and that it's not a reference, right? So as soon as I've done the necessary fetchRows() or whatever, I can safely free the result, right? Any other ideas what might be causing problems for mysql and/or how to track the problems? I believe my ISP is using linux with apache, and a fairly recent PHP and mysql. I can get more details on exact versions if that helps. Also, just as a general note, the basic format for most of my pages is: 1) connect to database 2) do some queries from PHP using pearDB 3) display results I don't specifically call disconnect() when I'm done. Should I? Sorry for the abundance of questions, and thanks for any help. Regards, Dave :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] array with two dimensions
Hi all, Got a little problem here, I have a mysql query that looks like this SELECT SUM(value) as value, YEAR(dileveret) as year FROM table GROUP BY YEAR(dileveret) It works just fine, but i need to make a array that can could do somthing like this (know it doesent work) $ALL_VALUES[$year] += $value; The script is running the script up to 100 times to get all the specific data's, i hope that you know a way that i can hold the values, and year and later print one value for each year.. THANKS A LOT! Regards Lasse (newbie)
[PHP-DB] Fwd: When to do free()?
From: Allens <[EMAIL PROTECTED]>David, I'm still very new to PHP and MySQL, but here is what I've found. Couldn't find any references to the free() function except for this at the www.mysql.com website. On "How memory is used in MySQL", "lmost all parsing and calculating is done in a local memory store. No memory overhead is needed for small items and the normal slow memory allocation and freeing is avoided. Memory is allocated only for unexpectedly large strings (this is done with malloc() and free() ). " From what I've read, MySQL frees memory automatically when regular function calls from the web back to the server that return data are executed. I'm going out on a limb because I'm not sure and this is a good way for me to learn as well. Couldn't find any real info on the free() function in the php manual or mysql manual nor in any of the manuals I have. I have about 50 users hitting our lone db, but no memory issues have occurred to date. Using Mac OS X Server 10.2.3 on Mac Server 533MHz 1GB of memory with MySQL 3.23.51. Hope this isn't wasted reading? :) On Sunday, February 16, 2003, at 07:39 PM, [EMAIL PROTECTED] wrote: Re: When to do free()? 25667 by: David Chamberlin From: David Chamberlin <[EMAIL PROTECTED]> Date: Sun Feb 16, 2003 11:19:17 AM US/Eastern To: [EMAIL PROTECTED] Subject: Re: When to do free()? Hmmm...still no takers on this one I decided out of curiosity to start liberally adding free() calls whenever I did a db->query(). Unfortunately it seems that the free() call causes it to die. Not quite sure why, but it did. Most of the calls that I use a query() for (as opposed to getAll() or getOne()) are INSERT/UPDATE/DELETE. Is there some reason you shouldn't do a free() after one of those? I'm still baffled. And still don't know if I should be using disconnect() at the end of each of my pages Any thoughts? Thanks, Dave David Chamberlin wrote: Hello, I'm currently using pear DB to abstract out use of my mysql database. Everything is generally working fine, except that it seems that performance seems to degrade the more it is used, then I get my ISP to restart mysql and everything seems to be good again for a while, then it degrades, lather-rinse-repeat. I'm currently one of the only ones using mysql at my ISP, so it seems that whatever I'm doing is causing issues. For the most part I'm not doing anything complex, queries are relatively simple and the dbases are currently pretty small. So while thinking about the issue, one thing that occured to me is that I'm not doing a free() on the query results when I'm done with them. That's mostly because very few of the examples I've seen ever do this, so I assumed it was an optimization that generally wasn't necessary. Furthermore, I figured that after my page got loaded, the connection to the db would be terminated and the resources freed, so the extent of the "resource leak" would be pretty minimal. Well, now I'm questioning the validity of those assumptions and I'm wondering if I need to start adding liberal use of free(), and I'm wondering to what extent it needs to be done? So first question, for those familiar with pearDB. It seems that certainly after doing a query() I should do a free(). What about getAll() (and related question, is there much difference between doing a query() and getAll())?). The docs seem to indicate a getOne() automatically frees resources, so I don't need to do it there. Next question is, what happens when no one refers to a result any more? Will a destructor get called that automatically frees the result? Or should I make sure to do the free before the reference is lost? How long are resources held if you don't free them? Finally, I assume that when you fetch data from a result that the data is copied and that it's not a reference, right? So as soon as I've done the necessary fetchRows() or whatever, I can safely free the result, right? Any other ideas what might be causing problems for mysql and/or how to track the problems? I believe my ISP is using linux with apache, and a fairly recent PHP and mysql. I can get more details on exact versions if that helps. Also, just as a general note, the basic format for most of my pages is: 1) connect to database 2) do some queries from PHP using pearDB 3) display results I don't specifically call disconnect() when I'm done. Should I? Sorry for the abundance of questions, and thanks for any help. Regards, Dave :) Gale L. Allen Jr Macintosh Support Specialist 865/947-5740 "Remember, Love wins over all" (:
[PHP-DB] DBA
If anybody has a experience with DBA (CDB) please help me? I've compiled PHP4.0.3 with options ./configure' '--with-apache=../apache_1.3.27' '--with-pgsql' '--enable-dba=shared' '--with-cdb' and tried like : http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Web Page Caching
You can append to the URL a dummy variable that is sure to change every time: http://.../mypage?nocache= This will force the refresh. Ignatius - Original Message - From: "Philip Zee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, February 16, 2003 9:46 PM Subject: [PHP-DB] Web Page Caching > Hello, > > I don't know if this is the right list to send this question to. It appears that the browser caches the result after a PHP page updates the database. I have to manually reload it in order to see the updates. Does anyone know how to overcome this? > > Thanks, > > Philip > > -- > 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