Re: [PHP-DB] Re: PHP Max execution time
To be honest, I'm not sure. I didn't write the script or the database, they were written by the guy who worked there before me. I think the solution presented to increase max time will work but if the hang time becomes too great I will look into this suggestion. Thanks! -Lisi At 09:50 AM 7/15/04 -0400, Peter Westergaard wrote: Lisi [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am running a script (called through a browser) that checks entries in a table one at a time. As the table has grown, the script takes longer to run than is allowed - 30 seconds. Of course, I have to ask... is there absolutely no way to optimize your table so as to use an index or two, or to add a few extra columns to handle requisite calculations so that you don't need to process each row every time? -P -- 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] content managment systems
I am looking for open source CMSs that: 1) use PHP/Mysql 2) are relatively easy to install, for someone familiar with both PHP and MySQL 3) also easily allow you to change the layout/template from the default For instance, if I want to hire a graphic designer to create a static page for me with a unique design for my site, I want to be able to create a template file from that (possibly one template for the home page and a second one for inside pages) and then plug in a CMS into that layout (or plug the template into a CMS) so the client can then make any changes to any pages without having to go through me. I've heard PHP-Nuke is a very good portal system - would it work for this? Any other recommendations? The CMS must be open source, the budget is very limited right now. Thanks! -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Creating query with multi-dimensional array
I have a form that allows users to edit an entry in a database. It displays the current values in a textbox/select box/textarea depending on the type of data (text, enum, etc). The same form is used for different tables, so no values are hard coded. Field names are retrieved with a show columns query and then content is retrieved with a select query. This works fine for almost all fields, I am having trouble with the field that is of type set. I build the REPLACE query by listing the values entered into the form. The first thing I do is loop through the $_POST variable and create two arrays - one with the keys, and one with the values. So the variable $vals is an array that holds the data the user has entered, and in theory the REPLACE statement could be REPLACE INTO table ($key) VALUES ($vals), if I could list the values of $keys and $vals as follows: (field1, field2, field3) VALUES ('data1', 'data2', 'data3'). I wrote the following function to loop through the array values and list them as needed for the query (separated by a comma, surrounded by single quotes - yes, I know the quotes haven't been added yet): function print_array($arr) { //This function takes an array and lists all values in a comma-separated list //for easy printing in a query or web page $count = count($arr); $last = $count - 1 ; for ($i = 0; $i $count; $i++) { if (is_array($arr[$i])) { /PROBLEM***/ $count2 = count($arr[$i]); $last2 = $count2 - 1 ; for ($j = 0; $j $count2; $j++) { $list .= $arr[$i][$j]; } /PROBLEM***/ } else { $list .= $arr[$i]; } if ($i != $last) { $list .= , ; } } return $list; } The problem is that if a value in the array is itself an array, for instance a field of type set that has more than one value chosen, it's not listing the values of that array, just the word array. I tried making it a recursive function if (is_array($arr[$i])) { print_array($arr[$i]); } but that also just gave me Array, so I tried duplicating the code, as you can see in the function above, but this didn't work either. I feel like there must be something obvious I'm missing, but I just can't see it. The code for the form itself is select name=Category[] SIZE=5 MULTIPLE so it is being passed as an array, and I can do print_r of the specific variable and see the array values. I just can't get them to print properly in my query. The other odd thing is that when I do print_r($vals) it also shows me Array for the field that is an array, instead of showing me the values. But when I do print_r($Category) it does show me that it is an array. Can anyone help? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] replacing once with ereg_replace
I have a problem with two possible solutions, I'm just not sure how to do either one. I have a number of pages and their links stored in a MySQL db. The links are stored without the leading slash (i.e. animals/birds/birds.htm). $PHP_SELF returns the link with the leading slash (i.e. /animals/birds/birds.htm). I need these two strings to match. There are two ways to do this: 1) Solution: Remove the leading slash from $PHP_SELF Problem: How do remove only the first instance of the slash with ereg-replace and leave the others? Or is there another function that would do this? This may be obvious but I didn't see it in the documentation. 2) Solution: Add the leading slash to each entry in the db (MySQL) Problem: How do I do this with a query without having to change each one manually? I know I can change the link field using UPDATE but how would I tell MySQL to change the entry to / + entry? Each entry is obviously different. Using a plus makes MySQL think it's mathematical addition and sets the field to 0. The field type is varchar. Thanks in advance for any suggestions! -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Dynamic sites, to appear static...?
Sorry I'm a bit late with this, I couldn't remember where I'd seen this: http://www.zend.com/zend/spotlight/searchengine.php has an article on getting around this. I've used it and it's pretty easy to do. HTH, -Lisi At 11:18 AM 9/4/03 +0100, [EMAIL PROTECTED] wrote: I've been building web sites that use a database backend for some time now. I typically use the format. http://www.mysite.com/index.php?page=contact http://www.mysite.com/index.php?page=home http://www.mysite.com/index.php?page=aboutus etc My most recent job wants to use differnt pages, so the search engines will pick up the url's as clearly defined, and not dynamic, as I normally do... They way id do things is great (normally) as it allows the Admin person to add as many pages as they like, without having to pay me to create it for them. But now if my most recent client wants to create a new page, I'll have to do it for them... Is there a way I can still admin the pages, and allow my client to add/delete pages, but use static links , without '?page=home' etc... I hope I've made sence... I've discused this with my client, and he said a friend of his claimed 'that webserver software should have a module or plugin that will do this' I've never heard of that, have I been living under a rock? * The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message. *** -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Calculating daylight savings time
I saw it, at first I didn't think it would work but it's great - just what I need. I guess I was just surprised that there isn't an easier way to do this in PHP by switching from the default. I also like to write my own code rather than use someone else's, since it's the best way to learn, but in this case it wasn't worth rewriting this function from scratch since it does exactly what I need. I'm still confused though about setlocale - what does this do in plain English? Thanks for the info, -Lisi At 10:05 AM 8/19/03 -0700, Micah Stevens wrote: Here's the example code I was talking about in the docs, you should really read the user submitted notes in the docs, they're very helpful, moreso than the docs from time to time. (this is not my code..) leafrink at hotmail dot com 28-Feb-2003 07:26 Wrote this function after a fair bit of searching on the subject. Don't know if it's the best way to do it, but it works. Its not that exact but it's pretty close. Hope it helps someone out there. /** * function for working out if it is daylight savings for a specific date. * must specify when daylight savings starts and ends in the format * [1=First,2=Second,3=Third,4=Fourth,L=Last]:NameOfDay:Of The Month * e.g. L:Sun:3 = Last Sunday in March * some will not meet this criteria but most do. * * see - http://webexhibits.org/daylightsaving/g.html for daylight savings times around the world. * */ function is_daylight_savings($gmtime,$DSTStart = '',$DSTEnd = ''){ //global $locale; //For Most Of Australia //DayLightSavings Starts Last sunday in October $DSTStart = L:Sun:10;//$locale['DSTStart']; //DayLightSavings Ends Last Sunday in March $DSTEnd = L:Sun:3;//$locale['DSTEnd']; $DSTStart = split(:,$DSTStart); $DSTEnd = split(:,$DSTEnd); $gmtMonth = date(n,$gmtime); // if not even in the Important changeover months. if ($gmtMonth $DSTStart[2] $gmtMonth $DSTEnd[2]){ return false; } else if ($gmtMonth $DSTStart[2] || $gmtMonth $DSTEnd[2]) { return true; } else { //it is in the Start or End Month if ($gmtMonth == $DSTStart[2]){ $True = true; $week = $DSTStart[0]; $ImportantDay = $DSTStart[1]; } else {//it is in the End Month $True = false; $week = $DSTEnd[0]; $ImportantDay = $DSTEnd[1]; } //get the day of the month $gmtDay = date(j,$gmtime); //work out what week it starts/ends. if ($week == 'L'){ $week = 4; $ldom = 4;//last day of month factor } //if the week in which it starts/ends has not been reached if($gmtDay ($week-1)*7){ return (!$True); } else { $gmtDate = getdate($gmtime); //go by a Day of the Week Basis for ($i=($week-1)*7;$i(($week*7)+$ldom);$i++){ $checkDate = mktime(0,0,0,$gmtDate[mon],$i,$gmtDate[year]); //get the actual day it starts/ends if (date(D,$checkDate) == Sun date(n,$checkDate) == $gmtMonth ){ $day = date(j,$checkDate); } } if ($gmtDay $day) {//if it has not reached the day return (!$True); } else { return $True; } } } } //Testing if(is_daylight_savings(strtotime(26-Oct-2003))){ echo is DAYLIGHT SAVINGS; }else { echo is NOT DAYLIGHT SAVINGS; } On Tuesday 19 August 2003 2:37 am, Lisi wrote: What I need to do is figure this out for more than one location at a time. I am displaying Sabbath times for several different cities around the world at once (New York, London, Paris, Jerusalem, Sydney) - i.e. a certain amount of time before sunset, different for each city and each city is in a different dst zone. Can I do something using setlocale, to change timezones to the city I need, and then use date(I)? Or does date(I) always work only for the US? And what exactly does setlocale change? I couldn't figure out from the notes on php.net. Thanks for your help, -Lisi At 12:06 AM 8/17/03 -0700, Micah Stevens wrote: As an afterthought, the docs are inspecific on who's daylight savings schedule that the function returns. There's another user submitted function in the comments list that takes into account a specific schedule. -Micah On Sunday 17 August 2003 12:43 am, Lisi wrote: I have sunset times stored in a database and the a PHP page that performs a number of calculations on the retrieved time. One of the things I need to figure out is whether or not to add an hour for Daylight Savings Time. Since there is more than once location, and each one begins and ends DST at a different time, I need to figure this out based on location. My question is, how do I figure out whether it's the first sunday in April yet or not? I know it has to do with the date() function somehow, I'm just not sure how to use it properly in this case - any suggestions? Thanks, -Lisi -- 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
Re: [PHP-DB] Calculating daylight savings time
What I need to do is figure this out for more than one location at a time. I am displaying Sabbath times for several different cities around the world at once (New York, London, Paris, Jerusalem, Sydney) - i.e. a certain amount of time before sunset, different for each city and each city is in a different dst zone. Can I do something using setlocale, to change timezones to the city I need, and then use date(I)? Or does date(I) always work only for the US? And what exactly does setlocale change? I couldn't figure out from the notes on php.net. Thanks for your help, -Lisi At 12:06 AM 8/17/03 -0700, Micah Stevens wrote: As an afterthought, the docs are inspecific on who's daylight savings schedule that the function returns. There's another user submitted function in the comments list that takes into account a specific schedule. -Micah On Sunday 17 August 2003 12:43 am, Lisi wrote: I have sunset times stored in a database and the a PHP page that performs a number of calculations on the retrieved time. One of the things I need to figure out is whether or not to add an hour for Daylight Savings Time. Since there is more than once location, and each one begins and ends DST at a different time, I need to figure this out based on location. My question is, how do I figure out whether it's the first sunday in April yet or not? I know it has to do with the date() function somehow, I'm just not sure how to use it properly in this case - any suggestions? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Calculating daylight savings time
I have sunset times stored in a database and the a PHP page that performs a number of calculations on the retrieved time. One of the things I need to figure out is whether or not to add an hour for Daylight Savings Time. Since there is more than once location, and each one begins and ends DST at a different time, I need to figure this out based on location. My question is, how do I figure out whether it's the first sunday in April yet or not? I know it has to do with the date() function somehow, I'm just not sure how to use it properly in this case - any suggestions? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mktime to subtract minutes (was Time without seconds)
I realized I need to do some processing on the time after it's retrieved, so I decided to retrieve hours and minutes separately and then subtract the necessary time with PHP. Each city has sunset times for each day stored in the database, in a datetime field. I retrieve all cities and times for a today's date, and then loop through the results to display them in a table. Depending on which city it is, though, I need to subtract a certain amount of time - 18 minutes for one, 20 minutes for another, and 40 for the third. I thought the best way to do this would be to use a combination of mktime and date, and this works for adding an hour if daylight savings time is in effect. $hour = $dst ? $sunset_a[hour]+1 : $sunset_a[hour]; $time = mktime ($hour,$minute,0,1,1,2003); $time = date(G:i, $time); But how do I do this for minutes? If I do this: $minute = $sunset_a[minute]-40; and plug that into the mktime line above, I get the wrong answer: 24:00 - 40, not $sunset_a[minute] - 40. Is there no easy way to subtract time n PHP, like in MySQL with DATE_SUB? Or am I missing something easy with mktime? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] time without seconds
If I have a time stored in MySQL, and I only need the hour and minutes without seconds: 1) Can I crop this in PHP after retrieving it? 2) Is there a way to store this without the seconds in MySQL? Same goes for storing a date without the year. I could use a regular char field, but I want to be able to retrieve a row that corresponds to the current month and day, currently I am doing this with $month = date(n); $day = date(d); $query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day; Is there a better way to do this without storing unnecessary data? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] time without seconds
In general, is it better to have MySQL select less using TIME_FORMAT than to have PHP crop the info? -Lisi At 09:50 PM 6/17/03 -0400, John W. Holmes wrote: Lisi wrote: If I have a time stored in MySQL, and I only need the hour and minutes without seconds: 1) Can I crop this in PHP after retrieving it? Sure, just chop off the last : and what's after it if in HH:MM:SS format, or the last two numbers if in HHMMSS format. 2) Is there a way to store this without the seconds in MySQL? Not really. You could use DATE_FORMAT or TIME_FORMAT to format the date/time without the seconds, though. Same goes for storing a date without the year. I could use a regular char field, but I want to be able to retrieve a row that corresponds to the current month and day, currently I am doing this with $month = date(n); $day = date(d); $query = SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day; Is there a better way to do this without storing unnecessary data? I don't think there's any way to not store the year. Just ignore it like you're doing. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A 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] Dealing with ENUM fields
I am forwarding this useful function someone once sent to the list that I use often. Hope this fits your needs. -Lisi -Original Message- From: Russ [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 7:47 PM To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED] Subject: RE: [PHP-DB] Populating a dropdown list with ENUM values... G'day Scott: I wrote this function to do just what you're atfer: You may need to mess with it for you're own needs - but go for your life! //function: enum_select() - automatically generate an HTML select menu from a MySQL ENUM field //1). takes a table name: '$table' //2). a name for the menu '$name' //3). a CSS class function enum_select($table,$name,$class) { $sql = SHOW COLUMNS FROM $table; $result = mysql_query($sql); $select = select name=\$name\ class=\$class\\n\t; while($myrow = mysql_fetch_row($result)){ $enum_field = substr($myrow[1],0,4); if($enum_field == enum){ global $enum_field; $enums = substr($myrow[1],5,-1); $enums = ereg_replace(',,$enums); $enums = explode(,,$enums); foreach($enums as $val) { $select .= option value=\$val\$val/option\n\t; }//end foreach }//end if }//end while $select .= \r/select; return $select; }//end function All the best. Russ -- 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] Dealing with ENUM fields
What's the application? What are the issues with using ENUM verses something else? -Lisi At 05:32 AM 6/2/03 -0400, Becoming Digital wrote: Thanks to both Heilo and Lisi. These scripts should make things easier. Is it safe to assume that we are in agreement about the use of an ENUM field for this application? Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: heilo [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Monday, 02 June, 2003 05:11 Subject: Re: [PHP-DB] Dealing with ENUM fields Hi! there is a much shorter way to do this (which works with ENUM and SET): $qry = 'SHOW COLUMNS FROM `gruzilla_content` LIKE module'; $res = mysql_query($qry); if(mysql_num_rows($res)0) { $row = mysql_fetch_row($res); $pattern = #(enum|set)\('(.+?)'\)#i; $replace = '\\2'; $row[1] = preg_replace($pattern, $replace, $row[1]); $options = explode(',', $row[1]); } $options now contains every value of the enum. I think there is also a possibility to do this within a query - but currently i do not find the script on my HD :) - so this is a nice workaround! .ma Lisi [EMAIL PROTECTED] [EMAIL PROTECTED] 11:53 Uhr: I am forwarding this useful function someone once sent to the list that I use often. Hope this fits your needs. -Lisi -Original Message- From: Russ [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 7:47 PM To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED] Subject: RE: [PHP-DB] Populating a dropdown list with ENUM values... G'day Scott: I wrote this function to do just what you're atfer: You may need to mess with it for you're own needs - but go for your life! //function: enum_select() - automatically generate an HTML select menu from a MySQL ENUM field //1). takes a table name: '$table' //2). a name for the menu '$name' //3). a CSS class function enum_select($table,$name,$class) { $sql = SHOW COLUMNS FROM $table; $result = mysql_query($sql); $select = select name=\$name\ class=\$class\\n\t; while($myrow = mysql_fetch_row($result)){ $enum_field = substr($myrow[1],0,4); if($enum_field == enum){ global $enum_field; $enums = substr($myrow[1],5,-1); $enums = ereg_replace(',,$enums); $enums = explode(,,$enums); foreach($enums as $val) { $select .= option value=\$val\$val/option\n\t; }//end foreach }//end if }//end while $select .= \r/select; return $select; }//end function All the best. Russ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Matthias Steinböck Email: [EMAIL PROTECTED] Web: http://www.abendstille.at Frühabendliches Webdesign. -- Im Übrigen sind wir der Meinung, dass unsere Gesellschaft Gabel-diskriminierend Löffel verwendet. Alle Macht den Gabeln! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Reporting tool for stats pulled from MySQL db
I have a stats tracking program and a page that displays stats for various dates/items depending on what options the user selects. I need to add some kind of external reporting tool, i.e. they'd like to download the information, preferably in Excel. I tried forcing Excel to open the data instead of the browser by sending headers: Header(Content-Type: application/vnd.ms-excel); Header(Content-Disposition: attachment; filename='stats.xls'); When I sent just the first one, all I got was a blank broswer page with a picture (application?) icon in the top left hand corner. Then I added the second header, which I found in a previous post in the archives, and that forced a download but of the page itself (stats_print.php). 1) What am I doing wrong? 2) Every posting I found in the archives said this is the easiest way. Is there another, harder but might work for me, way anyone would suggest of doing this? Thanks in advance, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Reporting tool for stats pulled from MySQL db
In the first line, what do you mean where the file is? Where I want it to be? It doesn't exist yet, I want to generate an Excel file from dynamic data. And I don't want it to be saved on the server, I just want the user to download it. Anyway, I tried changing Header(Content-Disposition: attachment; filename='stats.xls'); to Header(Content-Disposition: inline; filename='stats.xls'); without adding any of your other changes but I got the same icon in the corner. I'm using IE 6. -Lisi At 09:46 AM 2/25/03 +, George Pitcher wrote: Lisi, This is a modification of a script I use to download pdfs. It might just work ?php $fpd = E:\\MyFolder\\ . $fp . .xls; // where the file is $len = filesize($fpd); header(Content-Type: application/vnd.ms-excel); header(Content-Disposition: inline; filename=$fpd); header(Content-Title: $fpd); header(Content-Length: $len); readfile($fpd); ? George -Original Message- From: Lisi [mailto:[EMAIL PROTECTED] Sent: 25 February 2003 9:41 am To: PHP-DB Subject: [PHP-DB] Reporting tool for stats pulled from MySQL db I have a stats tracking program and a page that displays stats for various dates/items depending on what options the user selects. I need to add some kind of external reporting tool, i.e. they'd like to download the information, preferably in Excel. I tried forcing Excel to open the data instead of the browser by sending headers: Header(Content-Type: application/vnd.ms-excel); Header(Content-Disposition: attachment; filename='stats.xls'); When I sent just the first one, all I got was a blank broswer page with a picture (application?) icon in the top left hand corner. Then I added the second header, which I found in a previous post in the archives, and that forced a download but of the page itself (stats_print.php). 1) What am I doing wrong? 2) Every posting I found in the archives said this is the easiest way. Is there another, harder but might work for me, way anyone would suggest of doing this? Thanks in advance, -Lisi -- 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] What about MySQL
If you are looking for books to help get your feet wet, you can try the following: MySQL, by Paul DuBois (there is a new version that just came out), published by New Riders, ISBN: 0-7357-0921-1 Professional PHP Programming, published by Wrox press, ISBN: 1-861002-96-3 -Lisi At 11:30 AM 2/25/03 +0800, [EMAIL PROTECTED] wrote: Ok,Thank for your help very much! Maybe I have make my first step in MySQL and PHP trip! -Original Message- From: Larry E. Ullman [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 25, 2003 11:14 AM To: Jun.Han Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] What about MySQL I am a fresh man in MySQL,Can anyone tell me how i begin to learn it? www.mysql.com is a really good place to start. and what are the different between MySQL and other commerce relative database?As what I known,My SQL is free,but other commerce RDB is very expensive! Why MySQL not in the top? Is MySQL not strong or easy to used than the commerce products? MySQL is free for many--but not all--uses (check the license at www.mysql.com). MySQL has most of the features you'll need but is still missing some biggies (sub-queries, triggers, etc.). Some of these features will be implemented in forthcoming versions of the software. Read more about this at www.mysql.com. MySQL is pretty easy to use. Read the tutorial that comes with the manual at www.mysql.com. MySQL can help me do what or not? Well, you haven't said what you want to do but I suspect MySQL can help. Why don't you head over to www.mysql.com to get a better feel for it? Best wishes, Larry PS There are many books on MySQL available, should you be interested, as well as numerous mailing lists dedicated to MySQL. You can find out more about these at (you guessed it) www.mysql.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Sending HTML output from MySQL query to Excel
I searched the archives and read the postings about using header(Content-Type: application/vnd.ms-excel); to send tables dynamically constructed from a MySQL query to an excel spreadsheet, but when I tried it (using IE 6) all I got was a picture icon in the top left corner of the screen and no output anywhere. I know the query works, and I can create the tables just fine in HTML when I don't add any headers - so how do I get this to go into Excel? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] LEFT JOIN not working
Still not working. I made the change, and I'm still getting all results. I even tried it without the leading '0' in front of the 1, no good. Here's my current query, with suggested changes: SELECT ads_displayrate.name, SUM(ads_displayrate.count) as display, SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name AND YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' AND DAYOFMONTH(ads_displayrate.date) = '05' GROUP BY ads_displayrate.name ORDER BY ads_displayrate.name ads_displayrate.date is a column of date type, so as far as I understand this should work. Is there some typo I'm missing? At 07:15 PM 1/9/03 +0100, you wrote: Oops! I missed again. If you specify conditions pertaining to the right-hand table, such as: ads_clickrate.date = '2001', Then you will lose all result rows for which the right-hand data is NULL. Not the expected result. So your restricting WHERE clauses must apply to the left-hand table only. Therefore: WHERE YEAR(ads_displayrate.date) = '2003' AND MONTH(ads_displayrate.date) = '01' (if your table ads_displayrate has such date fields). HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 6:54 PM Subject: Re: [PHP-DB] LEFT JOIN not working Cool! It's mostly working now, the only problem is it's ignoring the other clauses in the ON clause that select the desired date. Perhaps it's not supposed to be connected this way? How would I select specific dates? Thanks again, -Lisi At 01:20 PM 1/9/03 +0100, you wrote: Oops! Sorry, I missed it the first time. Your query should start as: SELECT ads_displayrate.name instead of SELECT ads_clickrate.name then you will always have a non-NULL name (coming from the table on the left of the LEFT JOIN). HTH Ignatius, from Brussels Where the fuck is Belgium? D. Ivester, CEO, Coca Cola - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 1:11 PM Subject: Re: [PHP-DB] LEFT JOIN not working Exactly my question - why does it not have a name? How would I modify my query to get a row with a name but null value for date? I thought the join would take care of this, but I'm obviously not doing it right. You mention a unique identifier, there is a separate table with a row for each ad, containing name, URL, and a unique ID number (autoincrement). Should this table be included somehow in the query? How would this help? Thanks, -Lisi At 12:45 PM 1/9/03 +0100, Ignatius Reilly wrote: Your 4th row ought to have an identifier of some sort. From your SELECT statement, this seems to be the name. Why does it not have a name? Probably what you want is a row with a name but a NULL value for ads_clickrate.date. (by the way it is EXTREMELY advisable to use an abstract identifier, such as an id, unique and required, instead of name) Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED]; PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 12:18 PM Subject: Re: [PHP-DB] LEFT JOIN not working OK, this helped a bit. Now I have, in addition to the three rows of ads that have ben clicked on, a fourth row with no ad name, 0 clickthroughs, and 24 displays. That plus the other three account for all the displayed ads. However, since it is returning a null value for any ad name that has not been clicked on, and then it's grouped by ad name, it lumps all non-clicked ads into one row. What I need is to see each ad on a separate row, which is what I thought a LEFT JOIN was supposed to do. Any suggestions? Thanks, -Lisi At 11:07 AM 1/9/03 +0100, Ignatius Reilly wrote: problem 1: move the WHERE clauses to the ON clauses problem 2: Obviously your intent with COUNT(ads_clickrate.date) is to count the number of non-null occurences of click. But COUNT() is not the appropriate function to do this (it will simply give you the number of rows inside a group). Try replacing COUNT(ads_clickrate.date) by SUM( IF( ads_clickrate.date IS NULL, 0, 1 ) ) HTH Ignatius - Original Message - From: Lisi [EMAIL PROTECTED] To: PHP-DB [EMAIL PROTECTED] Sent: Thursday, January 09, 2003 10:44 AM Subject: [PHP-DB] LEFT JOIN not working I have a page with many ads that stores both the number of times
[PHP-DB] LEFT JOIN not working
I have a page with many ads that stores both the number of times an ad is displayed and how many times it gets clicked. These are stored in two different tables (since different information is stored for each) but both have identical name columns. I am trying to display both # times displayed and # times clicked in the same table in an admin page. Here is my query: SELECT ads_clickrate.name, ads_clickrate.link, SUM(ads_displayrate.count) as display, COUNT(ads_clickrate.date) as click FROM ads_displayrate LEFT JOIN ads_clickrate ON ads_displayrate.name = ads_clickrate.name WHERE YEAR(ads_clickrate.date) = '2003' AND MONTH(ads_clickrate.date) = '01' GROUP BY ads_clickrate.name ORDER BY ads_clickrate.name I want to display for each ad the number of times displayed, and then number of times clicked if applicable, if not 0. The query is only returning rows for ads that have been clicked on. Is the problem because I have a COUNT column for one table, with a group by? Is this causing the display to be grouped also? If you need more information how the table is set up let me know, I'm really stumped here. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Formatting txt from a database
I am retrieving text stored in a database, and I want to strip out any HTML tags and then only display the first 30 characters with ... to show the user that there is more text to view. My problem is with stripping out HTML tags, the code is stripping out the text enclosed within the HTML tags as well. Here is the code I am using: $pat = {1}.+{1}; if (ereg(text, $type)){ //if the field type is text look for HTML tags to remove $content_array[$c] = ereg_replace($pat, '', $content_array[$c]); $content_array[$c] = substr($content_array[$c], 1, 30); $content_array[$c] = $content_array[$c]; } echo $content_array[$c]; What should the correct $pat be? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Connecting to remote db securely
I am writing a content management section for a site that will use as part of the front page three small sub-sections from another site's home page (with their permission, of course). They are worried about giving us the password to their database, where the information is stored, because we are on a different server and they are afraid someone could steal the password since it's being passed un-encrypted by our web server when we try to retrieve the info. Is this something to worry about? Is there a way around this? They suggested using IFrames to display the static information from their page, but this doesn't work with Netscape - at least version 4.7. Any other ideas? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting to remote db securely
I didn't realize that, is this discussed in Paul DuBois' book? Or, can you point me to the function(s) on the mysql website I need to look at? Thanks, -Lisi At 12:09 AM 11/25/02 -0800, Rasmus Lerdorf wrote: Which DB? MySQL supports encrypted connections. On Mon, 25 Nov 2002, Lisi wrote: I am writing a content management section for a site that will use as part of the front page three small sub-sections from another site's home page (with their permission, of course). They are worried about giving us the password to their database, where the information is stored, because we are on a different server and they are afraid someone could steal the password since it's being passed un-encrypted by our web server when we try to retrieve the info. Is this something to worry about? Is there a way around this? They suggested using IFrames to display the static information from their page, but this doesn't work with Netscape - at least version 4.7. Any other ideas? TIA, -Lisi -- 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] Connecting to remote db securely
I checked with phpinfo() and this is what I got: PHP Version 4.2.2 mysql - Client API version 3.23.51 Is there any secure way to connect using these versions? I am on a virtual host so there's not much I can do about upgrading. Also, does it matter which versions the server I am connecting to are running? -Lisi At 12:22 AM 11/25/02 -0800, Rasmus Lerdorf wrote: See php.net/mysql_connect The client_flags argument is the one you want, so you will need PHP 4.3 for it and MySQL 4.0.x. -Rasmus On Mon, 25 Nov 2002, Lisi wrote: I didn't realize that, is this discussed in Paul DuBois' book? Or, can you point me to the function(s) on the mysql website I need to look at? Thanks, -Lisi At 12:09 AM 11/25/02 -0800, Rasmus Lerdorf wrote: Which DB? MySQL supports encrypted connections. On Mon, 25 Nov 2002, Lisi wrote: I am writing a content management section for a site that will use as part of the front page three small sub-sections from another site's home page (with their permission, of course). They are worried about giving us the password to their database, where the information is stored, because we are on a different server and they are afraid someone could steal the password since it's being passed un-encrypted by our web server when we try to retrieve the info. Is this something to worry about? Is there a way around this? They suggested using IFrames to display the static information from their page, but this doesn't work with Netscape - at least version 4.7. Any other ideas? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting to remote db securely
OK, then I'll throw this back to the list - any other ideas how I can get to their data without compromising their DB? I thought maybe about asking them to set up a separate DB with just the table I need, and sync it to those table in their main db, but it has to be a solution that involves the least amount of work on their end or it won't happen. Thanks, -Lisi At 01:27 AM 11/25/02 -0800, Rasmus Lerdorf wrote: Yup, only MySQL 4.0.x has SSL support. I suppose you could try to set up some sort of tunnel, but it might not be the most reliable thing in the world. On Mon, 25 Nov 2002, Lisi wrote: I checked with phpinfo() and this is what I got: PHP Version 4.2.2 mysql - Client API version 3.23.51 Is there any secure way to connect using these versions? I am on a virtual host so there's not much I can do about upgrading. Also, does it matter which versions the server I am connecting to are running? -Lisi At 12:22 AM 11/25/02 -0800, Rasmus Lerdorf wrote: See php.net/mysql_connect The client_flags argument is the one you want, so you will need PHP 4.3 for it and MySQL 4.0.x. -Rasmus On Mon, 25 Nov 2002, Lisi wrote: I didn't realize that, is this discussed in Paul DuBois' book? Or, can you point me to the function(s) on the mysql website I need to look at? Thanks, -Lisi At 12:09 AM 11/25/02 -0800, Rasmus Lerdorf wrote: Which DB? MySQL supports encrypted connections. On Mon, 25 Nov 2002, Lisi wrote: I am writing a content management section for a site that will use as part of the front page three small sub-sections from another site's home page (with their permission, of course). They are worried about giving us the password to their database, where the information is stored, because we are on a different server and they are afraid someone could steal the password since it's being passed un-encrypted by our web server when we try to retrieve the info. Is this something to worry about? Is there a way around this? They suggested using IFrames to display the static information from their page, but this doesn't work with Netscape - at least version 4.7. Any other ideas? TIA, -Lisi -- 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] Sorting in numerical order, and then randomly
Hi Peter, Thanks for the suggestion, suggestion 3 works perfectly if I also switch the order of the numbering as you suggest, because then I can do order by priority desc, rand(), which returns the numbers first and then the 0's, which is what I really wanted. Also, good point about adding higher priority advertisers - I hadn't thought of that. Thanks again, -Lisi At 02:54 AM 11/18/02 -0500, Peter Beckman wrote: Your options, as I see them, with 3 being the best I could come up with: 1. Make two queries. Depending on how many rows returned, this may be the less taxing option processor wise. 2. Make the random query. As you iterate through them push folks with priority 0 on one stack, priority 1 another stack, etc. At the end of it all you'll have a bunch of stacks with a randomly ordered list of advertisers. 3. (This is the obvious winner) select * from ads_value where status='current' order by priority asc, rand() This will return 0's first, 1,2,3... etc after that in a random order. I might recommend re-ordering your priority making 100 the highest and 1 the lowest priority above 0. This way if you get an advertiser that beats everyone out, they can be 101 or 150 or (if you are lucky in this market) 2000. If you do it your way (as I understand it) you will have to bump down #1 to #2, #2 to #3, etc in order to put a newer higher priority advertiser first. Peter On Sun, 17 Nov 2002, Lisi wrote: I am using MySQL to store ad information in the following table: CREATE TABLE IF NOT EXISTS ads_value ( img_link varchar(50), text text, service varchar(50) default NULL, title varchar(50) default NULL, priority int(2) default '0', status enum('current', 'old'), ID int(3) NOT NULL auto_increment, PRIMARY KEY (ID) ) TYPE=MyISAM; Ads for which advertisers pay more will have a higher priority - i.e. 1, 2, 3, etc. Everything else will have a priority of 0. When the page loads, I want to first display any ads that have a priority higher than 0 to be displayed in order, and then the remaining ads with a priority if 0 to be displayed in random order. They have to be displayed in a different order each time, so that each ad has the same chance of being displayed in a particular spot as any other ad. The only spots a random ad cannot be in is one taken by a higher paying ad. I hope this is clear. Is it possible to do this with one query? Or would I have to use 2 different queries: select * from ads_value where status = 'current' and priority 0 order by priority asc and then select * from ads_value where status = 'current' and priority = 0 order by RAND() TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Sorting in numerical order, and then randomly
I am using MySQL to store ad information in the following table: CREATE TABLE IF NOT EXISTS ads_value ( img_link varchar(50), text text, service varchar(50) default NULL, title varchar(50) default NULL, priority int(2) default '0', status enum('current', 'old'), ID int(3) NOT NULL auto_increment, PRIMARY KEY (ID) ) TYPE=MyISAM; Ads for which advertisers pay more will have a higher priority - i.e. 1, 2, 3, etc. Everything else will have a priority of 0. When the page loads, I want to first display any ads that have a priority higher than 0 to be displayed in order, and then the remaining ads with a priority if 0 to be displayed in random order. They have to be displayed in a different order each time, so that each ad has the same chance of being displayed in a particular spot as any other ad. The only spots a random ad cannot be in is one taken by a higher paying ad. I hope this is clear. Is it possible to do this with one query? Or would I have to use 2 different queries: select * from ads_value where status = 'current' and priority 0 order by priority asc and then select * from ads_value where status = 'current' and priority = 0 order by RAND() TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Variable from PHP to HTML...
form name=form1 method=post action= table border=0 align=center ?php do { $sys = $system['Name']; if ($cnt == 1) { $cnt = 2; echo tr; ? td width=161input name=$sys type=checkbox value=name ?php echo $sys; ?/td Your input box should be the following: input name=sys type=checkbox value=name The $ isn't necessary in the HTML code since HTML doesn't really recognize this as a variable. When the form is passed to the action page, the code in the action page (in this case PHP) creates a variable named whatever the name attribute in the HTML code holds - in this case sys. -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] sort by date
There is a difference between a general, how do I do this question and a specific here's my code, I can't find the bug question. Sometimes people just need a quick answer specific to their code. Also, unfortunately, many times when people want to point to a resource they give the standard RTFM. Believe it or not, many newbies don't always know how to do this!! A polite it's too long to go into on the list, but you can read more about this here with a link is much more helpful. -Lisi At 04:22 PM 11/6/02 +0100, Snijders, Mark wrote: why does everybody always gives the answers?? why not a hint, or where to search that they can learn something about it??? -Original Message- From: Marco Tabini [mailto:marcot;inicode.com] Sent: woensdag 6 november 2002 16:08 To: Terry Romine Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] sort by date Ok, going out on a limb here... have you tried something like select e.id, title, location, address, contact, category, event_time, urllink, descript, min(event_date) from eventTable e inner join dateTable d on e.id = d.id group by e.id ? Marco -- php|architect - The magazine for PHP Professionals The first monthly worldwide magazine dedicated to PHP programmer Come visit us at http://www.phparch.com! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] encode/decode
I am trying to use encode/decode to store passwords in a database and then retrieve it to email to a user who has forgotten their password. I am using the following code to encode the password: INSERT INTO users (name, password) VALUES ('$_POST[username]', 'ENCODE($_POST[password], encrypt)') This does enter a binary entry into the database, presumably the encoded data. I then tried to retrieve the password using the following: SELECT username, DECODE(password, 'encrypt') as password from users but all I got was gobbledygook characters. What am I doing wrong? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Storing passwords in a database
I know there's been discussion on the list before on this topic, but I'm a little fuzzy on the details. I want to create a site where users can create an account online, and then log in to search job postings. I want to store their user info and password in a database. I need a way for them to retrieve their passwords if forgotten. I know there are two basic approaches: 1) Storing the passwords using some form of encryption, which can be reversed and the password can be emailed to the user. This seems to me to be preferable, since they don't have to change their password whenever they forget it. However, are there security issues with this? I know many people recommend the second method: 2) Generating a new random password which the user can then use to log in and change to whatever they want. What are the advantages of this, since someone would need access to the person's email address with either method 1 or 2 in order to steal the password? What functions should I be looking at for encryption, for either method? What are advantages and disadvantages of each method? The site will not take credit card information, all accounts are free. So the security issues are much less, but of course you do not want a site where people's accounts are stolen even if there is not money involved. I hope this is clear, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Unique SQL query?????????????
Try adding 'distinct' before the field you are selecting. -Lisi At 01:42 AM 6/8/02 +0100, Georgie Casey wrote: Is there any SQL command that will return a list of *unique* entries from a fied. ie only repeat one for duplicates i have a database of products, each having a category, and obviously a lot of products have the same category and I want to create an index of all the different categories. thanks -- Regards, Georgie Casey [EMAIL PROTECTED] *** http://www.filmfind.tv Online Film Production Directory *** -- 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] mail() function
If you are on Windows you can just point to your ISP's SMTP server in your .ini file. At 11:02 AM 6/10/02 +0200, Dib, Walid (MED, Stagiaire GEMS) wrote: Hello I want to test the mail() function locally, i'm using esays php, how can I do that? thanks Walid -- 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] stripSlashes function
I have a form that allows a person to enter an announcement into a database using a form. The form and the query work fine. $query = INSERT INTO maztov (fullname1, fullname2, city1, city2, email1, email2, post_fullname, mazal_text, post_city, post_email, other_emails, entered) VALUES ('$fullname1','$fullname2','$city1','$city2','$email1','$email2','$post_fullname','$mazal_text','$post_city','$post_email','$other_emails', NOW()); $result = mysql_query($query); Then I realized MagicQuotes was adding slashes to my query, so I added this line: $query = stripSlashes($query); before I executed the result. Now the result is no longer executing, i.e. the entry is not being added into the database. When I echo the query before and after stripslashes has been applied, it is echoing exactly what I think it should. When I comment out the line with stripslashes, it works again but with adding quotes. What am I doing wrong? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] stripSlashes function
The slashes are being added by the MagicQuotes feature in PHP (I think) when the form is submitted, and the slashes are being put into the database but I don't want them there. When I echo the query it does have the slashes, and when I echo it after applying stripslashes they are gone, but then my query is not being executed. At 04:33 AM 5/20/02 -0400, SP wrote: You need to add slashes when putting data into your database. When you want to display the data from your database, that's when you strip the slashes. -Original Message- From: Lisi [mailto:[EMAIL PROTECTED]] Sent: May 20, 2002 5:33 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] stripSlashes function I have a form that allows a person to enter an announcement into a database using a form. The form and the query work fine. $query = INSERT INTO maztov (fullname1, fullname2, city1, city2, email1, email2, post_fullname, mazal_text, post_city, post_email, other_emails, entered) VALUES ('$fullname1','$fullname2','$city1','$city2','$ema il1','$email2','$post_fullname','$mazal_text','$po st_city','$post_email','$other_emails', NOW()); $result = mysql_query($query); Then I realized MagicQuotes was adding slashes to my query, so I added this line: $query = stripSlashes($query); before I executed the result. Now the result is no longer executing, i.e. the entry is not being added into the database. When I echo the query before and after stripslashes has been applied, it is echoing exactly what I think it should. When I comment out the line with stripslashes, it works again but with adding quotes. What am I doing wrong? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 -- 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] Global Connection object
Just put it in a separate file and include it in whatever page needs to access the DB. -Lisi At 10:03 AM 5/2/02 +1000, Shaun Johnston wrote: Is it possible to make a MySQL connection object global, so that it doesn't need to be declared as a parameter to be accessed from individual functions? -- 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] Simple search engine gone bad
Hi Jennifer, if($searchword = $iname) try it with a double equals sign if($searchword == $iname) { echo TABLE BORDER='0' WIDTH='95%' CELLPADDING='0' CELLSPACING='0'TR; echo TD width=20%a href='usershop.php?user=$user'$user/a/TD; echo TD width=40%font size=2$iname/font/TD; echo TD width=20%font size=2CENTER$q/CENTER/font/TD; echo TD width=30%font size=2CENTER$price/CENTER/font/TD; echo /TD/TR/TABLE; } } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mail
just change the SMTP to your ISP's SMTP server, i.e. the server you use to send mail from your regular mail account. At 06:45 PM 4/22/02 +0100, Alex Francis wrote: Here is the section from my PHP.INI [mail function] ; For Win32 only. SMTP = localhost ; For Win32 only. sendmail_from = [EMAIL PROTECTED] ; For Unix only. You may supply arguments as well (default: 'sendmail -t -i'). ;sendmail_path = I presume you mean the SMTP server set in my mail account. That is at my ISP. -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 [EMAIL PROTECTED] http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. Dl Neil [EMAIL PROTECTED] wrote in message 049e01c1ea16$8a0cf690$0600a8c0@jrbrown">news:049e01c1ea16$8a0cf690$0600a8c0@jrbrown... Alex, I'm still having problems with the mail function. I have installed PHP in a Windows 2000 test server. Is there something I should do to allow this function to work. I am a complete newbie and installed with the default settings. I get a Failed to connect Error when I call the mail() function. // retrieve values $row = mysql_fetch_array($ret); $email = $row[email]; $title = $row[title]; $comments = $row[comments]; $title = $row[title]; mail($email, $title, $comments); Mail is controlled by settings in the php.ini file. Please post the [mail function] section (changing any confidential names to protect the guilty). Setup for Windows differs from *NIX - hence confusion in many tutorials/books... this matter is frequently discussed - see archives. Regards, =dn -- 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] Mail
Yep, that's exactly how it works. Just like the email you send from Eudora or Outlook is all stored on your hard drive, but uses the SMTP server of your ISP, same here. -Lisi At 07:17 PM 4/22/02 +0100, Alex Francis wrote: Can I set this to use the SMTP Server at my ISP but still use the database and PHP files in house. I don't want to make any changes to either the php pages or the database at the ISP until I have got it all working. Although I suppose I could set up another site and database at my ISP. Alex Francis Cameron Design 35, Drumillan Hill, Greenock, PA16 0XD Tel / Fax 01475 798106 http://www.camerondesign.co.uk email: [EMAIL PROTECTED] This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. From: DL Neil [EMAIL PROTECTED] To: Alex Francis [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] References: [EMAIL PROTECTED] 049e01c1ea16$8a0cf690$0600a8c0@jrbrown [EMAIL PROTECTED] Subject: Re: [PHP-DB] Mail Date: Mon, 22 Apr 2002 18:53:58 +0100 Message-ID: 060401c1ea26$fcebc050$0600a8c0@jrbrown MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 X-UIDL: jj`!!6LA!QlX!!e7!! -- 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] Delete from mysql table is there a way to....
Thanks for the explanation! Very clear. How do you know how fragmented your DB is? I apologize if this is covered somewhere, like I said I was very confused buy this whole topic. Thanks, -Lisi At 01:00 PM 4/16/02 -0700, Frank Flynn wrote: Picture a Church, full of pews. This is your empty table. As people (your data) come in to the church they fill the pews but unlike real life the first person goes all the way to the left hand side of the first pew, the second sits next to them and the third... When one pew is full they start to fill the second pew and so on. There is no empty space. Now if you want to delete some data it's like a person leaving the Church. If it was the last person in fine but if you're deleting a particular row (as you most certainly would be) it's like a person getting up out of the middle of a pew and leaving. Now there is a hole there, the next person coming in will still be seated in the back and now you delete a few more rows (a few more people leave) and you have Fragmentation which is holes in the data as it's stored. This is not a problem with the data but the table takes up more space than it otherwise could. Q - So why doesn't the database use the empty space in the middle of the table? A - Sometimes it will but usually not because it would take too long to find it (when you want to save a new record you don't want to search through a large table for an empty space) This fragmentation can also happen when you update a record especially if you use varchar datatypes because they can change size - if you updated a record that had a field with the value hi and you set it to hello world this record would not fit in the same space it came out of. Not a problem for the DB but it will delete the old record and save it in a new space (leaving the hole). This gets more complicated if you have the data Clustered - that is sorted in a particular order. But the same idea applies when you add, update or delete data you wind up with blank space in your database. Sometimes you actually want to put empty space into your table because you know you'll be updating the records and they will grow - typically this is called a Fillfactor and you could set it to 70% meaning 30% of your table will be empty and available for use. This kind of fragmentation is unavoidable and when it becomes a performance problem you reorganize your table. Some DBMS have special commands to do it otherwise you can dump, truncate and reload the table. But I'll suggest that fragmentation up to 50% isn't really a big problem. If it is noticeable at 50% I'd suggest you're probably not using an index properly. Good Luck, Frank From: Lisi [EMAIL PROTECTED] What exactly does it mean when a table becomes fragmented? How do you know when it's happened and something should be done? All the docs and books talk about how bad it is but I'm still confused on what this is and when it happens. Thanks, -Lisi At 05:00 PM 4/14/02 -0700, Jennifer Downey wrote: Hi all, Is there a way to delete a record from a mysql table without fragmenting the db? Here is the query I am using and it does a horrible job. Fragment city. if ($quantity == 0) { $gone = mysql_query(DELETE FROM {$config[prefix]}_my_items WHERE uid={$session[uid]} AND id = '$item'); } -- Frank Flynn Poet, Artist Mystic -- 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] Extracting the essence!
How about: $test= preg_replace ($search, $replace, $dokument); while (list ($key, $val) = each($test)) { if ($key == 0 || $key == 3) { //do nothing } else { echo $key = $val; } } Let me know if this works. -Lisi At 11:24 PM 4/14/02 +0200, #Linux wrote: Tanks so far, but if I want don't want to display the 1st and 4th line. - Original Message - From: Lisi [EMAIL PROTECTED] To: #Linux [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, April 14, 2002 10:55 PM Subject: Re: [PHP-DB] Extracting the essence! Try something like the following to extract the contents of the array by looping through it: $test= preg_replace ($search, $replace, $dokument); while (list ($key, $val) = each($test)) { echo $key = $val; } HTH -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Delete from mysql table is there a way to....
What exactly does it mean when a table becomes fragmented? How do you know when it's happened and something should be done? All the docs and books talk about how bad it is but I'm still confused on what this is and when it happens. Thanks, -Lisi At 05:00 PM 4/14/02 -0700, Jennifer Downey wrote: Hi all, Is there a way to delete a record from a mysql table without fragmenting the db? Here is the query I am using and it does a horrible job. Fragment city. if ($quantity == 0) { $gone = mysql_query(DELETE FROM {$config[prefix]}_my_items WHERE uid={$session[uid]} AND id = '$item'); } Thanks Jennifer -- The sleeper has awaken --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 -- 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] Extracting the essence!
Try something like the following to extract the contents of the array by looping through it: $test= preg_replace ($search, $replace, $dokument); while (list ($key, $val) = each($test)) { echo $key = $val; } HTH -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: how to notify admin by e-mail only once if mysql server is down
Pardon my ignorance, but what's webmin? Thanks, -Lisi At 11:14 AM 4/12/02 -0600, Ray Hunter wrote: You can use webmin and set up the alert there for mysql. I use it for my webserver and database servers. It sends out 1 email for me telling me what is down. Ray Hunter Andy [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there, I am wondering if it would be possible to set up a php application like this: If the mysql server is down notify by e-mail, but only once. Right now I am getting an e-mail per view if the server is down (might be lots of e-mails :-) thanx for any hint, Andy -- 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] Finding highest number in auto increment
Each record in my table has a unique ID number generated by auto increment each time a new record is added. This is stored in a field called ID. I have a page that displays records as they are selected, but I want the default to be the latest entry if none has been selected. How do I write the query to find the highest number an display that record? It should be something like this I think: SELECT organization FROM ayny WHERE ID ... how does this end? Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Error creating new table
I am trying to create the following table using PHPMyAdmin: CREATE TABLE IF NOT EXISTS ayny( organization varchar(50) NOT NULL, subtitle varchar(50) NOT NULL, img varchar(20) NOT NULL, width varchar(5), height varchar(5), link varchar(30) NOT NULL, maintext text(50) NOT NULL, boxtext text(50) NOT NULL, ID INT(9) NOT NULL AUTO_INCREMENT, PRIMARY KEY(ID) ); But I keep getting the following error: MySQL said: You have an error in your SQL syntax near '(50) NOT NULL, boxtext text(50) NOT NULL, ID INT(9) NOT NULL AUTO_INCREMENT,' at line 8 Any ideas what I'\m doing wrong? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Error creating new table
Worked like a charm, thanks. How do I avoid varchar if I the size of the text will vary with each entry? It's going to be a pretty small database anyway so I'm not that worried, but how often do I optimize the table to avoid fragmentation? -Lisi At 10:29 AM 4/8/02 +0200, you wrote: I don't think you can use text(50), It should be one of the following tinytext, mediumtext or text Or you should use char(50). I would try to avoid using varchar() it fragments the database. Remco - Original Message - From: Lisi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, April 08, 2002 11:11 AM Subject: [PHP-DB] Error creating new table I am trying to create the following table using PHPMyAdmin: CREATE TABLE IF NOT EXISTS ayny( organization varchar(50) NOT NULL, subtitle varchar(50) NOT NULL, img varchar(20) NOT NULL, width varchar(5), height varchar(5), link varchar(30) NOT NULL, maintext text(50) NOT NULL, boxtext text(50) NOT NULL, ID INT(9) NOT NULL AUTO_INCREMENT, PRIMARY KEY(ID) ); But I keep getting the following error: MySQL said: You have an error in your SQL syntax near '(50) NOT NULL, boxtext text(50) NOT NULL, ID INT(9) NOT NULL AUTO_INCREMENT,' at line 8 Any ideas what I'\m doing wrong? TIA, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] No results from query
I have the following query: SELECT * FROM ayny WHERE organization LIKE 'Hatzoloh' which produces no results, when I set $numrows = mysql_num_rows($result); it equals 0. When I do the following: SELECT * FROM ayny and then loop through the results, echoing them to the screen with the following code: while ( list($key,$val) = each($result_array) ) { echo $key = $valBR; } I do get a line organization = Hatzoloh So why can't I pull just the record for Hatzoloh using my first query? Please let me know if you need more code to figure this out. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] hosts
There was a discussion on the list a few weeks ago about reliable web hosts offering PHP and MySQL support. I did not need the info then but it has become relevant now. I'd appreciate if people could re-post recommendations, if someone has a compiled list, even better. Thanks, -Lisi -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php