[PHP-DB] endless loop / running as a service?
I'd like to have a serverside script (php) who checks 24 hours a day wether theres a file uploaded to my server. But I don't know if that is possible, since, as far as I know, php only recognizes user actions. But I don't know how to do this, can aynone help me? Thanks in advance!! PS: It's not likely to run this script after the file is uploaded, because it would take way too much time to load the next page _ Talk with your online friends with MSN Messenger http://messenger.msn.nl/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] endless loop / running as a service?
Hi, maybe something like this would do: ( warning: it is just a sketch,and probably will not run ) 1. there are 4 files on the server: a) check-flag b) start-watch.php c) stop-watch.php d) watch.php 2. watch.php: // in the check-flag file we have a flag which turns off/on the checker $flag_file = 'check-flag'; $fd = fopen($flag_file, 'r'); $go = fread($fd);// we shall get 0 - stop, 1 - go // the loop runs as long as there is 1 in 'check-flag' file while ( $go ) { $dir_state = get_the_state_of_the_dir(); $old_dir_state = get_previous_state_of_the_dir(); if( compare_the_dirs( $dir_state, $old_dir_state)) { // the state is different - something has been uploaded // do somethnig } $result = write_previous_dir_state($old_dir_state); rewind_the_file_position_to_start($fd); $go = fread($fd); } // end of the loop 3. start-watch.php if(check_the_identity_and_privileges_of_the_user() ) { set_flag_in_the_file( 'check-flag', 1); } 4. stop-watch.php if( check_the_identity_and_privileges_of_the_user() ) { set_flag_in_the_file( 'check-flag', 0); } it is just a rough idea written down with pseudo-php, but You shall get the idea greetings. Marcin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Getting a result from MAX() query
Sadly, I don't have any answers, only more questions. First, how do you know your query is returning a FALSE result? What test are you performing and what are the results of the test? Second, what type of column is fee_recd? I've been toying with the MAX() function on the command line with a number of my own tables using different column types (DATE, TEXT, VARCHAR, INT) and have yet to see it fail to return some sort of result set. Rich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 8:57 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Getting a result from MAX() query Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise -- 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] Getting a result from MAX() query
Usually you need to group on something for a max to work (at least in Oracle) -Original Message- From: Hutchins, Richard [EMAIL PROTECTED] Sent: Jul 13, 2004 8:40 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Getting a result from MAX() query Sadly, I don't have any answers, only more questions. First, how do you know your query is returning a FALSE result? What test are you performing and what are the results of the test? Second, what type of column is fee_recd? I've been toying with the MAX() function on the command line with a number of my own tables using different column types (DATE, TEXT, VARCHAR, INT) and have yet to see it fail to return some sort of result set. Rich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 8:57 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Getting a result from MAX() query Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise -- 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 - Dylan Barber : AOL Messenger - dylanbarb (CIW Professional, A+ Technician): MSN Messenger - [EMAIL PROTECTED] Web Designer / Developer / Host - Clip those URLs! - Short links are easier to remember. http://clipurl.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting a result from MAX() query
[EMAIL PROTECTED] wrote: Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); but this one doesn't $latest=mysql_query(SELECT fee_recd FROM members ORDER BY fee_recd DESC LIMIT 1,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Louise Here's a concept: RTM In MySQL versions prior to Version 3.22.5, you can use MAX() instead of GREATEST. What does your inquiry have to do with PHP? Doug -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Getting a result from MAX() query
[EMAIL PROTECTED] wrote: Would somebody be kind enough to explain why this query produces a false result $latest=mysql_query(SELECT MAX(fee_recd) FROM members,$connectup)or die (Query failed:br$latestbrError: . mysql_error()); Would you be kind enough to tell us what text mysql_error() shows? You probably just need to use an alias in your query: SELECT MAX(fee_recd) AS max_fee_recd FROM members and then you'll have $row['max_fee_recd'] when you fetch the value from your result set. Other wise you need to use $row['MAX(fee_recd)']... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql auto increment
I've done exactly this for a really cheap-and-dirty instance where two people were doing bulk data entry into two different instances of a mysql table which would eventually be stitched together. by giving one a higher range, the data migration afterwords was very easy. Other than that, can't imagine a use for this approach. -P -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql auto increment
There might be some system that requires a 4 digit number and the PK is being used directly. Also, this same system might need to be exported to Excel, which trims leading zeros and is generally a pain in the ass. Peter Westergaard wrote: I've done exactly this for a really cheap-and-dirty instance where two people were doing bulk data entry into two different instances of a mysql table which would eventually be stitched together. by giving one a higher range, the data migration afterwords was very easy. Other than that, can't imagine a use for this approach. -P -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Mysql and rollbacks
I'm developing a site where I anticipate the need to make several updates to several forms, and I'll want to commit them all at once (i.e. if there's a failure with any of the transactions, I'd like to be able to back out to before I started). Is there a decent way to do this with PHP and Mysql? Obviously start with ignoring user interrupt, and I was thinking a fairly easy way to reduce the risk is to perform numerous tests before attempting any activity, but that means at least doubling my database activity - does that pose more performance issues than it solves? Or has someone else got a good strategy for dealing with this? Perhaps writing temp-rows, and then executing some sort of stored procedure to move all the temp-rows to the real tables in one fell swoop? Or, really, any wisdom to impart? -P -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Mysql and rollbacks
... or, am I barking up the wrong tree with Mysql, and should I change database platforms? (You'll never convince me to give up PHP though. muahaha. Except for sql-level stored procedures where necessary, that is). -P -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mysql and rollbacks
Peter Westergaard wrote: I'm developing a site where I anticipate the need to make several updates to several forms, and I'll want to commit them all at once (i.e. if there's a failure with any of the transactions, I'd like to be able to back out to before I started). Is there a decent way to do this with PHP and Mysql? Use InnoDB tables which have transaction support. Or use a database abstraction layer that simulates transactions such as ADOdb: http://phplens.com/adodb/tutorial.smart.transactions.html -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Re: Mysql and rollbacks
If memory serves me correctly, a couple of the PEAR database abstraction classes support rollback functionality. Of course, YMMV. Rich -Original Message- From: Peter Westergaard [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 13, 2004 11:24 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Mysql and rollbacks ... or, am I barking up the wrong tree with Mysql, and should I change database platforms? (You'll never convince me to give up PHP though. muahaha. Except for sql-level stored procedures where necessary, that is). -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
Re: [PHP-DB] Re: Mysql and rollbacks
Peter Westergaard wrote: ... or, am I barking up the wrong tree with Mysql, and should I change database platforms? (You'll never convince me to give up PHP though. muahaha. Except for sql-level stored procedures where necessary, that is). Maybe? :) PostgreSQL and Firebird are two other open source free databases that have transaction support and stored procedures, IIRC. Check them out. If you run your own server, it's easy to get these. You may have trouble finding a hosting company consistently offering them, though. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Security Issues
so I've been doing a little thinking about web server security.. #1. Since all files on the web are 644, what is to stop someone on the same server from copying your files to their own directory? (specifically your database connection info) #2. if a folder if 777, what's to stop someone from writing to that folder? Jonathan Haddad -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Security Issues
Jonathan Haddad wrote: so I've been doing a little thinking about web server security.. #1. Since all files on the web are 644, what is to stop someone on the same server from copying your files to their own directory? (specifically your database connection info) #2. if a folder if 777, what's to stop someone from writing to that folder? Answer to both questions is a combination of SAFE_MODE and open_basedir restrictions among other things discussed on the manual pages for those functions / features. If those restrictions are not in place, then nothing is stopping someone on the same server to read/write in your filespace with PHP. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Security Issues
so I've been doing a little thinking about web server security.. #1. Since all files on the web are 644, what is to stop someone on the same server from copying your files to their own directory? (specifically your database connection info) #2. if a folder if 777, what's to stop someone from writing to that folder? Virtual Servers http://searchnetworking.techtarget.com/sDefinition/0,,sid7_gci213304,00.html People can only see their own directories and files. PHP Safe Mode http://us2.php.net/features.safe-mode Check the section titled Safe Mode in the php.ini file. It has settings that help lock things down. Apache open_basedir Also detailed in the PHP Safe Mode documentation. There are a few other things that can be done to limit the scope of access, but all of it really depends on how the server is setup. I've seen many situations where hosting providers set accounts up with basic Virtual Hosting without doing any sort of lock down. If you're not careful and chose one of those providers, then you're definitely open to the sort of security breach that you've described. -Ed -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Column help needed (Table)
Hello Chris, easy as this? ?php $odd=1; while ($row=mysql_fetch_row($Res)) { if ($odd) { echo \ntr; $odd=0; } else $odd=1; echo td . $row[0] . /td; } ? CP Hi there everyone, CP I need my MySQL query to be displayed in a table, which is no problem, but I CP only want 2 results per row to be displayed - so if I had 10 returned CP results from my Database, it would display 2 per column on 5 rows. How can CP I do this dynamically? CP Any help would be really appreciated. CP Thanks CP Chris -- Best regards, Pablo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Multiple SELECT
Hello Marcjon, do this: SELECT forumusers.*, forumuserprofiles.* from .$godlyness['database_database']..forumusers LEFT JOIN .$godlyness['database_database']..forumuserprofiles ON forumusers.username = forumusersprofiles.username where order by so.. if you do: where forumusers.username like %doe% you will receive all users like %doe%, and null values if she/he has not profile. http://dev.mysql.com/doc/mysql/en/JOIN.html M SELECT M forumusers.email AS email,forumusers.username AS username,forumusers.level AS level, M forumusers.lastlogon1 AS lastlogon1,forumusers.lastlogon2 AS lastlogon2,forumusers.settings1 AS settings1,forumusers.confirmationcode AS confirmationcode, M forumuserprofiles.sex AS sex, forumuserprofiles.birthdate AS birthdate, M forumuserprofiles.address_msnm AS address_msnm, forumuserprofiles.address_aim AS address_aim, M forumuserprofiles.address_yahoo AS address_yahoo, forumuserprofiles.address_icq AS address_icq M FROM .$godlyness['database_database']..forumusers,.$godlyness['database_database']..forumuserprofiles .$filterbu. M ORDER BY username M -- Best regards, Pablo -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: map algorithm
Hello, On 07/07/2004 03:41 PM, Matt Perry wrote: I have written a shortest point algorithm that takes a number of addresses and finds the best delivery route. Yahoo maps finds the distances between two addresses but I cannot seem to find out how to grab the results and use them in my algorithm. How should I approach this problem? You may want to try this class that includes an example to solve that problem with combinatorial analysis: Class: Combinatorics http://www.phpclasses.org/combinatorics -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP sitemap
Hi, Is it possible/easy to create a simple sitemap page using PHP which would automatically parse all files and directories from index.html and create a structured HTML document from the results? I'm just a newcomer to this field, but have some experience in programming and web development. I know that I can parse a given directory, it would just be cool to do a grown up version of this code. Regards, Dermot Mc Laughlin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mysql and rollbacks
I was about to suggest the same, the latest builds of MySQL have theese functions from what I knew... I think youll find what you need there. -- Kim Steinhaug - There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. - www.steinhaug.com - www.easywebshop.no - www.easycms.no www.webkitpro.com - John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Peter Westergaard wrote: I'm developing a site where I anticipate the need to make several updates to several forms, and I'll want to commit them all at once (i.e. if there's a failure with any of the transactions, I'd like to be able to back out to before I started). Is there a decent way to do this with PHP and Mysql? Use InnoDB tables which have transaction support. Or use a database abstraction layer that simulates transactions such as ADOdb: http://phplens.com/adodb/tutorial.smart.transactions.html -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PHP 5.0.0 Released!
The PHP development team is proud to announce the official release of PHP 5. Some of the key features of PHP 5 include: - The Zend Engine II with a new object model and dozens of new features. - XML support has been completely redone in PHP 5, all extensions are now focused around the excellent libxml2 library (http://www.xmlsoft.org/). - A new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa. - A brand new built-in SOAP extension for interoperability with Web Services. - A new MySQL extension named MySQLi for developers using MySQL 4.1 and later. This new extension includes an object-oriented interface in addition to a traditional interface; as well as support for many of MySQL's new features, such as prepared statements. - SQLite has been bundled with PHP. For more information on SQLite, please visit their website (http://www.sqlite.org/). - Streams have been greatly improved, including the ability to access low-level socket operations on streams. - And lots more... Enjoy! PHP Development Team -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] fetch row DISTINCT
On Fri, 9 Jul 2004, Peter Westergaard wrote: One idea that occurs to me, and it's a tradeoff from Torsten's idea (which is to read the whole database, and parse out the unique rows), is to first execute your SELECT DISTINCT distinct_col FROM table, and then walk through that, and for each one issue a SELECT * FROM table WHERE distinct_col = {value} LIMIT 1 (For some reason I can't remember the 'LIMIT' syntax right now, so it might be LIMIT 0,1). More transactions with the database, but less data actually retrieved from the database. And if it's indexed by distinct_col, you should be fine. It´s not to start a war, but after having to hear so much about how good MySQL is. What you need is a database with sub-select capability, or to have a feature like: SELECT DISTINT ON(col1), col2, col5 FROM table1 WHERE... People say that they don´t need sub-selects (transactions, procedural languages, etc.) just because the don´t have an idea of the power that the hold. Just a par of cents on my part. -- 19:55:02 up 8 days, 11:32, 2 users, load average: 0.12, 0.15, 0.10 - Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral - -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Grab a range of rows from a mysql result
[EMAIL PROTECTED] wrote: The resource is made up of 1000+ records from a mysql table that I am breaking up to make my PHP application run faster. I have figured out how to compute the range but I dont know how to pull out a group of rows within a range from a mysql result resource. $query = SELECT * FROM yourtable WHERE range BETWEEN 400 AND 500; -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php