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
RE: [PHP-DB] Passing by reference
Rasmus, Peter and I were discussing the use of .$myvar. vs quoted string {$myvar} more quoted string in a separate thread. Is there a performance or compatibility advantage to using the concatenated version as you suggest in your message below? I currently use the concatenated version in all of my scripts, but Peter suggested the curly braces as a way to make the code more readable. While I agree that the curly brace method IS more readable, I want to know what the difference is before changing coding conventions. Thanks, Rich -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Sunday, November 17, 2002 12:21 AM To: Peter Beckman Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Passing by reference PHP uses copy-on-write for by-value passes. So, if you are not changing the passed string inside the function there is no copy done on a pass-by-value and this is actually faster than doing a pass-by-reference. But, I'd suggest doing .$myvar. (ie. break out of the quoted string and concat the var.) -Rasmus On Sun, 17 Nov 2002, Peter Beckman wrote: I'm building some software that will be passing a string variable which could potentially be up to 125K bytes (characters) in size. I know that passing a reference to the variable will be much more efficient than copying the variable: copying, as I understand it: foo($var) [...later...] function foo ($myvar) { $sql = insert into table (this) values (\$myvar\); } passing by reference, not copying: foo($var) [...later...] function foo ($myvar) { $sql = insert into table (this) values (\$myvar\); } A few questions: 1. Am I correct that PHP makes a copy of the variable when I call the function with the variable, since the scope will not be global in the function (unless I declare it such)? 2. Will I be saving some CPU cycles and memory by passing by reference? 3. Is my pseudo code above correct? If not, can you show me how one might pass by reference correctly? I've tested both pieces of code, but can't determine if there is a speed/memory difference, and I don't actually have 125K in data handy! Thanks, Peter -- - 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 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] Fastest, easiest Flatfile DB with PHP
hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Fastest, easiest Flatfile DB with PHP
For massive amounts of data, you really want to use some type of SQL database. Not only will you save time programming, but massive server resources aswell since the disk doesn't have to parse and seek a large flatfile everytime. On Mon, 2002-11-18 at 09:15, Teemu Pentinsaari wrote: hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Adam Voigt ([EMAIL PROTECTED]) The Cryptocomm Group My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc signature.asc Description: This is a digitally signed message part
RE: [PHP-DB] Fastest, easiest Flatfile DB with PHP
Hi If you have a lot of queries then use a database. If 'the frequency and number of queries are really massive so ' is a typo I am still not sure it's worth the hassle Peter --- Excellence in internet and open source software --- Sunmaia Birmingham UK www.sunmaia.net tel. 0121-242-1473 International +44-121-242-1473 --- -Original Message- From: Teemu Pentinsaari [mailto:[EMAIL PROTECTED]] Sent: 18 November 2002 14:16 To: [EMAIL PROTECTED] Subject: [PHP-DB] Fastest, easiest Flatfile DB with PHP hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- 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] Fastest, easiest Flatfile DB with PHP
For one, I don't see how it would be beneficial to store large quantities of data in a non-database type of format. As far as reducing the overhead of using MySQL, there are many methods one can use to reduce the number of queries to a database. For instance, if you are worried about making many small queries, you might want to look into creating large arrays of data from few queries, and then breaking out those arrays into the pieces you need throughout your program. I just revamped some code I did a while back and did the very same thing, making one db call to create a big array, and passing sections of that array that I had broken into multi-dimensional arrays to various functions. This change cut the processing time in half. Another option is using reduced data sets for certain tasks, if you can tell from the beginning of the program that only certain groups of data will be needed, such as per date entered, age, etc. | John Krewson | | 865-974-3263 | | [EMAIL PROTECTED]| |Senior Programmer/Analyst | Social Work Office of Research and Public Service The true art of memory is the art of attention. Samuel Johnson On Mon, 18 Nov 2002, Teemu Pentinsaari wrote: hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- 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] Fastest, easiest Flatfile DB with PHP
I've read the other posts and agree with them wholeheartedly - sounds like you actually should investigate using some sort of relational db, MySQL or otherwise. However, if there is some major reason you don't or can't use a relational database, you may want to consider storing your flat files as XML and using a native XML database to store and query those documents. Tamino by SoftwareAG comes to mind. It's proprietary, expensive and I don't know if or how you'd blend PHP with it, but if you absolutely must use flat files, XML might help. If you can get your head around XQuery (not an approved standard yet: http://www.w3.org/TR/xquery/) then you might be able to stay away from a proprietary solution like Tamino and use PHP to manipulate the flat files and possibly MySQL to store metadata if you need it(?). Don't know, just rambling at this point. Rich -Original Message- From: Teemu Pentinsaari [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 9:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Fastest, easiest Flatfile DB with PHP hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- 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] php sessions using mysql (or any db)
Thanks for the clarification with the returns. I made the changes however and it still doesn't work. This code comes pretty much straight off the presses from http://www.onlamp.com/lpt/a/832 What I have is quite modified from what is on there as it is quite buggy to begin with. Anyway, It still doesn't work. In perl, this would have been done already. I can't be the first person to try running sessions on a database. Does anyone have a session.inc file that would be appropriate for me. I feel like it should just be in the php base files. -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 4:59 PM To: Adam Nelson Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] php sessions using mysql (or any db) CREATE TABLE `SessionsTable` ( `SID` varchar(32) NOT NULL default '', This doesn't need to be a varchar. The sid will always be 32 chars, so make it a char(32) This is just an artifact of InnoDB/Mysql. I don't know the specifics, but I think char is no longer used by InnoDB (ie. it is just an alias for varchar). Anyway, I put in char, the ddl pops out as varchar. `expiration` int(11) NOT NULL default '0', I would suggest using a timestamp type here so MySQL will handle updating it for you automatically. timestamp would change with every update. This is a field to describe when the record should expire function mysql_session_open($session_path, $session_name) { mysql_pconnect(localhost, root, ) or die(Can't connect to MySQL server! ); mysql_select_db(globalDB) or die(Can't select MySQL sessions database); } // end mysql_session_open() You need to return true; at the end of this. true. function mysql_session_close() { return 1; No, use return true; function mysql_session_select($SID) { GLOBAL $sess_db; GLOBAL $sess_table; $query = SELECT value FROM $sess_table WHERE SID = '$SID' AND expiration . time(); $result = mysql_query($query); } // end mysql_session_select() Uh, you need to return the actual value here or an empty string on an error. function mysql_session_write($SID,$value) { GLOBAL $sess_db; GLOBAL $sess_table; GLOBAL $lifetime; $expiration = time() + $lifetime; $query = INSERT INTO $sess_table VALUES('$SID', '$expiration', '$value'); $result = mysql_query($query); if (! $result) : $query = UPDATE $sess_table SET expiration = '$expiration', value = '$value' WHERE SID = '$SID' AND expiration . time(); $result = mysql_query($query); endif; } // end mysql_session_write() Again, you *must* return true; on a sucessful write. function mysql_session_destroy($sessionID) { GLOBAL $sess_table; $query = DELETE FROM $sess_table WHERE SID = '$sessionID'; $result = mysql_query($query); } // end mysql_session_destroy() return true; -Rasmus -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php sessions using mysql (or any db)
?php // I got this somewhere. It works. // This code is released under the same license as PHP. (http://www.php.net/license.html) assert(get_cfg_var(session.save_handler) == user); // Without save_handler being set to user, everything works fine until it calls the write handler. $SessionTableName = get_cfg_var(session.save_path); // [$database.]tablename assert(!empty($SessionTableName)); function db_error_message() { return mysql_error(); } function mysql_session_open ($save_path, $session_name) { return true; } function mysql_session_close() { return true; } function mysql_session_read ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $session_data = mysql_query(SELECT Data FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_mess age()); if (mysql_numrows($session_data) == 1) { return mysql_result($session_data, 0); } else { return false; } } function mysql_session_write ($SessionID, $val) { global $SessionTableName; $SessionID = addslashes($SessionID); $val = addslashes($val); $SessionExists = mysql_result(mysql_query(SELECT COUNT(*) FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]), 0 ); if ($SessionExists == 0) { $retval = mysql_query(INSERT INTO $SessionTableName (SessionID, LastActive, Data) VALUES ('$SessionID', UNIX_TIMESTAMP(NOW()),'$val'),$GLOBALS[acdb]) or die(db_error_message()); } else { $retval = mysql_query(UPDATE $SessionTableName SET Data = '$val', LastActive = UNIX_TIMESTAMP(NOW()) WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); if (mysql_affected_rows() 0) { error_log(unable to update session data for session $SessionID); } } return $retval; } function mysql_session_destroy ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $retval = mysql_query(DELETE FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); return $retval; } function mysql_session_gc ($maxlifetime = 604800) { global $SessionTableName; $CutoffTime = time() - $maxlifetime; $retval = mysql_query(DELETE FROM $SessionTableName WHERE LastActive $CutoffTime,$GLOBALS[acdb]) or die(db_error_message()); return $retval; } session_set_save_handler ( 'mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc' ); ? On Mon, 18 Nov 2002, Adam Nelson wrote: Thanks for the clarification with the returns. I made the changes however and it still doesn't work. This code comes pretty much straight off the presses from http://www.onlamp.com/lpt/a/832 What I have is quite modified from what is on there as it is quite buggy to begin with. Anyway, It still doesn't work. In perl, this would have been done already. I can't be the first person to try running sessions on a database. Does anyone have a session.inc file that would be appropriate for me. I feel like it should just be in the php base files. -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 4:59 PM To: Adam Nelson Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] php sessions using mysql (or any db) CREATE TABLE `SessionsTable` ( `SID` varchar(32) NOT NULL default '', This doesn't need to be a varchar. The sid will always be 32 chars, so make it a char(32) This is just an artifact of InnoDB/Mysql. I don't know the specifics, but I think char is no longer used by InnoDB (ie. it is just an alias for varchar). Anyway, I put in char, the ddl pops out as varchar. `expiration` int(11) NOT NULL default '0', I would suggest using a timestamp type here so MySQL will handle updating it for you automatically. timestamp would change with every update. This is a field to describe when the record should expire function mysql_session_open($session_path, $session_name) { mysql_pconnect(localhost, root, ) or die(Can't connect to MySQL server! ); mysql_select_db(globalDB) or die(Can't select MySQL sessions database); } // end mysql_session_open() You need to return true; at the end of this. true. function mysql_session_close() { return 1; No, use return true; function
Re: [PHP-DB] Fastest, easiest Flatfile DB with PHP
In article 1EA7D3AE70ACD511BE6D006097A78C1E022BF9B8@USROCEXC, Richard Hutchins [EMAIL PROTECTED] wrote: I've read the other posts and agree with them wholeheartedly - sounds like you actually should investigate using some sort of relational db, MySQL or otherwise. However, if there is some major reason you don't or can't use a relational database, you may want to consider storing your flat files as XML and using a native XML database to store and query those documents. Tamino by SoftwareAG comes to mind. It's proprietary, expensive and I don't know if or how you'd blend PHP with it, but if you absolutely must use flat files, XML might help. While on the subject of proprietary solutions, some of you might like to know that the Valentina database will shortly be available as a PHP module. Valentina is rather unusual, coming as it does from its origins as an embedded SQL database for things like Macromedia Director and RealBasic, but it's maturing very nicely and is also available for Java, VB, C++ and several other environments. In OO environments (like RealBasic C++) it has an OO API which is just great. I already get speeds out of it well beyond what I can get with MySQL, and it has a more useful SQL environment (foreign keys etc). I recently built an essentially flat file with 20 million records recently and I easily get searches in under 0.1 sec in Director (which is a slow environment) on a P3/600 where the DB was 2x the size of available RAM, and it has at least an order of magnitude improvement in development. As yet it isn't client/server (will be in 2.0), but for the kind of solution being discussed, it's really excellent, especially as it will be running as a PHP extension, rather than as a separate server. You can read more at www.paradigmasoft.com. BTW, I'm just a satisfied customer. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date()
When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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] php sessions using mysql (or any db)
This works great :-) Thanks. I'll write a letter to onlamp.com to get that misleading code off their website (maybe it's PHP3 based?). Perhaps this should be added to PEAR? It appears that this is the proper repository for such things. I'll look into it although I would be much obliged if somebody in the know could handle this since I am new to PHP. One thing I left out - I had to take out the $GLOBALS[acdb] part from mysql_query. This doesn't work with my version of php (4.2.3) I guess. Also, assert(!empty($SessionTableName)); didn't work, so I commented it out. -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 12:01 PM To: Adam Nelson Cc: [EMAIL PROTECTED]; 'Rasmus Lerdorf' Subject: RE: [PHP-DB] php sessions using mysql (or any db) ?php // I got this somewhere. It works. // This code is released under the same license as PHP. (http://www.php.net/license.html) assert(get_cfg_var(session.save_handler) == user); // Without save_handler being set to user, everything works fine until it calls the write handler. $SessionTableName = get_cfg_var(session.save_path); // [$database.]tablename ' function db_error_message() { return mysql_error(); } function mysql_session_open ($save_path, $session_name) { return true; } function mysql_session_close() { return true; } function mysql_session_read ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $session_data = mysql_query(SELECT Data FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_mess age()); if (mysql_numrows($session_data) == 1) { return mysql_result($session_data, 0); } else { return false; } } function mysql_session_write ($SessionID, $val) { global $SessionTableName; $SessionID = addslashes($SessionID); $val = addslashes($val); $SessionExists = mysql_result(mysql_query(SELECT COUNT(*) FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]), 0 ); if ($SessionExists == 0) { $retval = mysql_query(INSERT INTO $SessionTableName (SessionID, LastActive, Data) VALUES ('$SessionID', UNIX_TIMESTAMP(NOW()),'$val'),$GLOBALS[acdb]) or die(db_error_message()); } else { $retval = mysql_query(UPDATE $SessionTableName SET Data = '$val', LastActive = UNIX_TIMESTAMP(NOW()) WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); if (mysql_affected_rows() 0) { error_log(unable to update session data for session $SessionID); } } return $retval; } function mysql_session_destroy ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $retval = mysql_query(DELETE FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); return $retval; } function mysql_session_gc ($maxlifetime = 604800) { global $SessionTableName; $CutoffTime = time() - $maxlifetime; $retval = mysql_query(DELETE FROM $SessionTableName WHERE LastActive $CutoffTime,$GLOBALS[acdb]) or die(db_error_message()); return $retval; } session_set_save_handler ( 'mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc' ); ? On Mon, 18 Nov 2002, Adam Nelson wrote: Thanks for the clarification with the returns. I made the changes however and it still doesn't work. This code comes pretty much straight off the presses from http://www.onlamp.com/lpt/a/832 What I have is quite modified from what is on there as it is quite buggy to begin with. Anyway, It still doesn't work. In perl, this would have been done already. I can't be the first person to try running sessions on a database. Does anyone have a session.inc file that would be appropriate for me. I feel like it should just be in the php base files. -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 4:59 PM To: Adam Nelson Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] php sessions using mysql (or any db) CREATE TABLE `SessionsTable` ( `SID` varchar(32) NOT NULL default '', This doesn't need to be a varchar. The sid will always be 32 chars, so make it a char(32) This is just an
RE: [PHP-DB] date()
Ok.. I guess it depends on how your date is stored. I always use unix_timestamps. If you are too.. then the format I supplied should work as indicated. Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:19 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Insert path string into Mysql
Hi, I have the following code, but it doesn't works. How can I insert a path string into a MySql Varchar cell? The result is always FALSE, but if $path is a normal string ($path ='demo') than it works fine. What can I do? (I use WInXp, Apache, and Php4.2.2) Thanks! ?php $database=PH; mysql_connect(localhost,root,); @mysql_select_db($database) or die( Unable to select database); $path = 'c:\\demo\\' ; $query = insert into PH_PHOTO (PHOTO_PATH) VALUES ('$path'); $result=mysql_query($query); mysql_close(); ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Insert path string into Mysql
On Monday, November 18, 2002, at 01:10 PM, Alan Kelly wrote: $path = 'c:\\demo\\' ; $query = insert into PH_PHOTO (PHOTO_PATH) VALUES ('$path'); $result=mysql_query($query); I would guess that the backslashes are being interpreted once by php when the variable $path is interpolated into the query string (to become c:\demo\) and again by mysql at which point it tries to insert a value for \d. You might try $path = 'c:demo' and see if that works. Or maybe leave the path alone and do the query line like this: $query = insert into PH_PHOTO (PHOTO_PATH) VALUES (' . $path . '); -Steve -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date()
it is just a datetime field and the clients use a javascript calander to pick the date, here is the exact date as it appears in the db. 2002-11-08 00:00:00 Eddie -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:05 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() Ok.. I guess it depends on how your date is stored. I always use unix_timestamps. If you are too.. then the format I supplied should work as indicated. Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:19 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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 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] Insert path string into Mysql
You might also want to look into using addslashes($path), especially if you're going to be accepting this path info from a text box. http://www.php.net/manual/en/function.addslashes.php -Original Message- From: Steve Cayford [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:21 PM To: Alan Kelly Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Insert path string into Mysql On Monday, November 18, 2002, at 01:10 PM, Alan Kelly wrote: $path = 'c:\\demo\\' ; $query = insert into PH_PHOTO (PHOTO_PATH) VALUES ('$path'); $result=mysql_query($query); I would guess that the backslashes are being interpreted once by php when the variable $path is interpolated into the query string (to become c:\demo\) and again by mysql at which point it tries to insert a value for \d. You might try $path = 'c:demo' and see if that works. Or maybe leave the path alone and do the query line like this: $query = insert into PH_PHOTO (PHOTO_PATH) VALUES (' . $path . '); -Steve -- 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] date()
Hmm.. I would get it into a unix_timestamp (unless someone can suggest a reasoning for now doing so). Select unix_timestamp(storedDate) as date FROM SomeTable where blah blah Should work like that? Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:50 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() it is just a datetime field and the clients use a javascript calander to pick the date, here is the exact date as it appears in the db. 2002-11-08 00:00:00 Eddie -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:05 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() Ok.. I guess it depends on how your date is stored. I always use unix_timestamps. If you are too.. then the format I supplied should work as indicated. Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:19 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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 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] date()
On Tuesday 19 November 2002 03:26, Aaron Wolski wrote: Hmm.. I would get it into a unix_timestamp (unless someone can suggest a reasoning for now doing so). It really depends on where you want to manipulate the dates. If mostly from within MySQL then store with DATE, DATETIME TIMESTAMP, if within PHP then use UNIX_TIMESTAMP. Select unix_timestamp(storedDate) as date FROM SomeTable where blah blah Should work like that? Yes, something like that. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* I didn't order any WOO-WOO ... Maybe a YUBBA ... But no WOO-WOO! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date()
you can use the mysql date function and format it as you're pulling it out of MySql select date(column_name, %m/%d/%Y) from table; this will return it formatted like 11/18/2002 or there are other options. http://www.mysql.com/doc/en/Date_and_time_functions.html this seems to be whar you're looking for... hth jeff Aaron Wolski aaronjw@marte To: 'Edward Peloke' [EMAIL PROTECTED], 'Php-Db' kbiz.com [EMAIL PROTECTED] cc: 11/18/2002 Subject: RE: [PHP-DB] date() 02:26 PM Hmm.. I would get it into a unix_timestamp (unless someone can suggest a reasoning for now doing so). Select unix_timestamp(storedDate) as date FROM SomeTable where blah blah Should work like that? Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:50 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() it is just a datetime field and the clients use a javascript calander to pick the date, here is the exact date as it appears in the db. 2002-11-08 00:00:00 Eddie -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:05 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() Ok.. I guess it depends on how your date is stored. I always use unix_timestamps. If you are too.. then the format I supplied should work as indicated. Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:19 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] date()
whooops. I meant DATE_FORMAT. Sorry. Jeffrey_N_Dyke @Keane.com To: 'Edward Peloke' [EMAIL PROTECTED] cc: 'Php-Db' [EMAIL PROTECTED] 11/18/2002 Subject: RE: [PHP-DB] date() 02:34 PM you can use the mysql date function and format it as you're pulling it out of MySql select date(column_name, %m/%d/%Y) from table; this will return it formatted like 11/18/2002 or there are other options. http://www.mysql.com/doc/en/Date_and_time_functions.html this seems to be whar you're looking for... hth jeff Aaron Wolski aaronjw@marte To: 'Edward Peloke' [EMAIL PROTECTED], 'Php-Db' kbiz.com [EMAIL PROTECTED] cc: 11/18/2002 Subject: RE: [PHP-DB] date() 02:26 PM Hmm.. I would get it into a unix_timestamp (unless someone can suggest a reasoning for now doing so). Select unix_timestamp(storedDate) as date FROM SomeTable where blah blah Should work like that? Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:50 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() it is just a datetime field and the clients use a javascript calander to pick the date, here is the exact date as it appears in the db. 2002-11-08 00:00:00 Eddie -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 2:05 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() Ok.. I guess it depends on how your date is stored. I always use unix_timestamps. If you are too.. then the format I supplied should work as indicated. Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 18, 2002 2:19 PM To: 'Php-Db' Subject: RE: [PHP-DB] date() When I use this, I get 12/31/69 as my date. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, November 13, 2002 4:04 PM To: 'Edward Peloke'; 'Php-Db' Subject: RE: [PHP-DB] date() $date = date(m:d:y, $myrow[datefield]); Will produce: 11:13:02 http://www.php.net/manual/en/function.date.php Aaron -Original Message- From: Edward Peloke [mailto:[EMAIL PROTECTED]] Sent: November 13, 2002 4:27 PM To: Php-Db Subject: [PHP-DB] date() I have a date field in my mysql db, when I output the data to the screen, I don't want to see the minutes, just the mmddyy. I can format a date but can't seem to get it to work passing in the value from $myrow[datefield]any ideas? I don't want to have to worry about just pulling what I want in the select clause, I just want to format it when I diplay it. Thanks, Eddie -- 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 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 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] Fastest, easiest Flatfile DB with PHP
I dont think TAMINO will do the JOB! Tamino is too slow compared to Mysql or PosgreSql. and you will need a lot of disk space if you use Tamino. By the way I know this because we just migrate from Tamino to Posgresql and MySql...(and 1 more thing JSP and Java are only options you have if u use tamino). garry - Original Message - From: Hutchins, Richard [EMAIL PROTECTED] To: 'Teemu Pentinsaari' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, November 18, 2002 10:54 PM Subject: RE: [PHP-DB] Fastest, easiest Flatfile DB with PHP I've read the other posts and agree with them wholeheartedly - sounds like you actually should investigate using some sort of relational db, MySQL or otherwise. However, if there is some major reason you don't or can't use a relational database, you may want to consider storing your flat files as XML and using a native XML database to store and query those documents. Tamino by SoftwareAG comes to mind. It's proprietary, expensive and I don't know if or how you'd blend PHP with it, but if you absolutely must use flat files, XML might help. If you can get your head around XQuery (not an approved standard yet: http://www.w3.org/TR/xquery/) then you might be able to stay away from a proprietary solution like Tamino and use PHP to manipulate the flat files and possibly MySQL to store metadata if you need it(?). Don't know, just rambling at this point. Rich -Original Message- From: Teemu Pentinsaari [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 9:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Fastest, easiest Flatfile DB with PHP hi, Maybe someone here can point me the way ... I'm looking for a fast and easy to use flatfile database working with PHP. The amount of stored data, the frequency and number of queries are really massive so I'm hoping to be able to skip MySql and build this service with some alternative technique. Anyone ? thanks Teemu -- 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] Lotus Notes
Hi folks, I'm thinking of integrating an existing Lotus Notes Database into PHP-pages and found the following functions: http://www.php.net/manual/en/ref.notes.php Unfortunately they are not very well documentated. For example notes_list_msgs (http://www.php.net/manual/en/function.notes-list-msgs.php) schould return a list, but gives bool. Are the Notes-functions working? Is the module still being developed? Are there any existing applications using these functions? Is there a better documentation? Thank you for your answers, Philipp -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php sessions using mysql (or any db)
Hi, Just wondering, which is the better method: 1. Using PHP sessions ($_SESSION['var'] = val;) 2. Using mySQL-based sessions (as described in this thread) I know if you're using multiple servers, a DB-based session would be handy. Any comments, anyone? Adam
[PHP-DB] Real Time Processing with PHP
Dear All, I have question, I have table (dynamic_store) and I want to reply back while the table was add new data, of course no user to do but the function will automatic reply will do it? how to check the table was add or not? is it running like daemon CMIIW? are php have function to check data? do you have idea how to I start Real Time Processing with PHP? any suggest? or article how to? highly appreciate for yr help -- Warm regards, Afif mailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php sessions using mysql (or any db)
On Mon, 18 Nov 2002, Adam Nelson wrote: One thing I left out - I had to take out the $GLOBALS[acdb] part from mysql_query. This doesn't work with my version of php (4.2.3) I guess. Also, assert(!empty($SessionTableName)); didn't work, so I commented it out. Whoops, the $GLOBALS[acdb] was legacy code for the site I was using. Ignore it. Sorry! Your SessionTableName is set in php.ini -- if $sessiontablename is empty, there is an issue that will prevent sessions from being written/read from! Peter -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 12:01 PM To: Adam Nelson Cc: [EMAIL PROTECTED]; 'Rasmus Lerdorf' Subject: RE: [PHP-DB] php sessions using mysql (or any db) ?php // I got this somewhere. It works. // This code is released under the same license as PHP. (http://www.php.net/license.html) assert(get_cfg_var(session.save_handler) == user); // Without save_handler being set to user, everything works fine until it calls the write handler. $SessionTableName = get_cfg_var(session.save_path); // [$database.]tablename ' function db_error_message() { return mysql_error(); } function mysql_session_open ($save_path, $session_name) { return true; } function mysql_session_close() { return true; } function mysql_session_read ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $session_data = mysql_query(SELECT Data FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_mess age()); if (mysql_numrows($session_data) == 1) { return mysql_result($session_data, 0); } else { return false; } } function mysql_session_write ($SessionID, $val) { global $SessionTableName; $SessionID = addslashes($SessionID); $val = addslashes($val); $SessionExists = mysql_result(mysql_query(SELECT COUNT(*) FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]), 0 ); if ($SessionExists == 0) { $retval = mysql_query(INSERT INTO $SessionTableName (SessionID, LastActive, Data) VALUES ('$SessionID', UNIX_TIMESTAMP(NOW()),'$val'),$GLOBALS[acdb]) or die(db_error_message()); } else { $retval = mysql_query(UPDATE $SessionTableName SET Data = '$val', LastActive = UNIX_TIMESTAMP(NOW()) WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); if (mysql_affected_rows() 0) { error_log(unable to update session data for session $SessionID); } } return $retval; } function mysql_session_destroy ($SessionID) { global $SessionTableName; $SessionID = addslashes($SessionID); $retval = mysql_query(DELETE FROM $SessionTableName WHERE SessionID = '$SessionID',$GLOBALS[acdb]) or die(db_error_message()); return $retval; } function mysql_session_gc ($maxlifetime = 604800) { global $SessionTableName; $CutoffTime = time() - $maxlifetime; $retval = mysql_query(DELETE FROM $SessionTableName WHERE LastActive $CutoffTime,$GLOBALS[acdb]) or die(db_error_message()); return $retval; } session_set_save_handler ( 'mysql_session_open', 'mysql_session_close', 'mysql_session_read', 'mysql_session_write', 'mysql_session_destroy', 'mysql_session_gc' ); ? On Mon, 18 Nov 2002, Adam Nelson wrote: Thanks for the clarification with the returns. I made the changes however and it still doesn't work. This code comes pretty much straight off the presses from http://www.onlamp.com/lpt/a/832 What I have is quite modified from what is on there as it is quite buggy to begin with. Anyway, It still doesn't work. In perl, this would have been done already. I can't be the first person to try running sessions on a database. Does anyone have a session.inc file that would be appropriate for me. I feel like it should just be in the php base files. -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 4:59 PM To: Adam Nelson Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] php sessions using mysql (or any db) CREATE TABLE `SessionsTable` ( `SID` varchar(32) NOT NULL default '', This doesn't need to be a varchar. The sid will always be 32 chars, so make it a char(32) This
Re: [PHP-DB] Insert path string into Mysql
Don't you also have to put quotes around localhost in mysql_connect? Peter On Mon, 18 Nov 2002, Alan Kelly wrote: Hi, I have the following code, but it doesn't works. How can I insert a path string into a MySql Varchar cell? The result is always FALSE, but if $path is a normal string ($path ='demo') than it works fine. What can I do? (I use WInXp, Apache, and Php4.2.2) Thanks! ?php $database=PH; mysql_connect(localhost,root,); @mysql_select_db($database) or die( Unable to select database); $path = 'c:\\demo\\' ; $query = insert into PH_PHOTO (PHOTO_PATH) VALUES ('$path'); $result=mysql_query($query); mysql_close(); ? -- 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] creating a new mysql automatically every day?
i'm currently building a traffic analysis application for a website. it is my first time working on such a project, so i'm not even sure if this would be the best way to do it all, but here it goes. what i would like to do is count the number of hits that go to different sections of the site. i can think of two ways of doing this, although i'm not sure what would be the most efficient. option 1- i already have a table thast records each session on the site (including browser type, time they entered site, referring page, etc). on this, i could think of adding a field for each section of the site i wish to log, and simply implement a counter each time they visit a certain section. then when i wanted to analyze it i could use the mySQL sum() functions. (because i'm really only interested in how many total visits to each section, not who went where exactly). option 2- having another table with a new row being created daily, and fields with a counter for each section. then i would have the problem of automatically creating a row each day at midnight though. my other question is i'm worried about database size. i've been reading posts on this board about mySQL goin to hell with over a million records. this table is definitely going to eventually grow pretty large, but it wond be accessed all that much (as it would just be for traffic analysis for the two site admins every now and then). should i be worried? thanks -jon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] creating a new mysql automatically every day?
Not sure what the best answer is, but if you are going to have a table that's mostly going to be inserted into, and rarely read, then don't create any indexes or keys on it. When it comes time to search the table, copy it to another table, create indexes, and search away. Indexes slow down inserts. ---John Holmes... -Original Message- From: Jonathan Narong [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 8:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] creating a new mysql automatically every day? i'm currently building a traffic analysis application for a website. it is my first time working on such a project, so i'm not even sure if this would be the best way to do it all, but here it goes. what i would like to do is count the number of hits that go to different sections of the site. i can think of two ways of doing this, although i'm not sure what would be the most efficient. option 1- i already have a table thast records each session on the site (including browser type, time they entered site, referring page, etc). on this, i could think of adding a field for each section of the site i wish to log, and simply implement a counter each time they visit a certain section. then when i wanted to analyze it i could use the mySQL sum() functions. (because i'm really only interested in how many total visits to each section, not who went where exactly). option 2- having another table with a new row being created daily, and fields with a counter for each section. then i would have the problem of automatically creating a row each day at midnight though. my other question is i'm worried about database size. i've been reading posts on this board about mySQL goin to hell with over a million records. this table is definitely going to eventually grow pretty large, but it wond be accessed all that much (as it would just be for traffic analysis for the two site admins every now and then). should i be worried? thanks -jon -- 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] Real Time Processing with PHP
I have question, I have table (dynamic_store) and I want to reply back while the table was add new data, of course no user to do but the function will automatic reply will do it? how to check the table was add or not? is it running like daemon CMIIW? are php have function to check data? do you have idea how to I start Real Time Processing with PHP? any suggest? or article how to? highly appreciate for yr help How is the data being inserted into the table? ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] creating a new mysql automatically every day?
John, That is good advice. I wasn't aware of indexes/keys slowing down inserts. Whats the best way to copy a table over to another table though? -jon -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 5:36 PM To: 'Jonathan Narong'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] creating a new mysql automatically every day? Not sure what the best answer is, but if you are going to have a table that's mostly going to be inserted into, and rarely read, then don't create any indexes or keys on it. When it comes time to search the table, copy it to another table, create indexes, and search away. Indexes slow down inserts. ---John Holmes... -Original Message- From: Jonathan Narong [mailto:[EMAIL PROTECTED]] Sent: Monday, November 18, 2002 8:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] creating a new mysql automatically every day? i'm currently building a traffic analysis application for a website. it is my first time working on such a project, so i'm not even sure if this would be the best way to do it all, but here it goes. what i would like to do is count the number of hits that go to different sections of the site. i can think of two ways of doing this, although i'm not sure what would be the most efficient. option 1- i already have a table thast records each session on the site (including browser type, time they entered site, referring page, etc). on this, i could think of adding a field for each section of the site i wish to log, and simply implement a counter each time they visit a certain section. then when i wanted to analyze it i could use the mySQL sum() functions. (because i'm really only interested in how many total visits to each section, not who went where exactly). option 2- having another table with a new row being created daily, and fields with a counter for each section. then i would have the problem of automatically creating a row each day at midnight though. my other question is i'm worried about database size. i've been reading posts on this board about mySQL goin to hell with over a million records. this table is definitely going to eventually grow pretty large, but it wond be accessed all that much (as it would just be for traffic analysis for the two site admins every now and then). should i be worried? thanks -jon -- 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] If conditional behaviour
If you develop the habit of writing conditionals like this: if (Victoria == $city) instead of like this: if ($city == Victoria) Your compiler (interpreter in PHP's case) will catch the assignment vs. comparison error for you, because assigning to $city is valid but assigning to a constant string Victoria isn't. Of course you'd have to have display_errors On for PHP to report the problem Evan At 9:17 PM -0800 on 2002.11.15, Bradley Crockett wrote about Re: [PHP-DB] If conditional behaviour: That was it. How embarrassing. Thanks! On Fri, 15 Nov 2002 21:12:42 -0800 (PST), Mihail Bota wrote: Did you try $city==Victoria ? On Fri, 15 Nov 2002, Bradley Crockett wrote: AT http://crockett.ca/joinoptional.php I have a page posted. PHP isn't set up on the server, so I've posted a screenshot of what it looks like at http://crockett.ca/joinoptionalrendered.bmp (1/2 MB, sorry). For some reason, it wants to repeat 'Victoria' in the form. If I comment out the If conditional: // if ($city = Victoria) { // Ýecho selected ; // } ..the problem goes away and the different cities appear as expected. The result of the query is at http://crockett.ca/queryresults.txt Can someone point me in the right direction? Brad Crockett Duncan BC -- 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 -- The Engine of Mischief http://www.enginesofmischief.com/engine 1976 GMC Eleganza II TZE166V100089 I do whatever the voices tell me to do. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Email Encryption?
$encrypted_string = md5(base64_encode($var.'secret key')); Pass the user name or password to $var and place text in to replace the words 'secret key'. -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 8:45 AM To: 'Jason Vincent'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Email Encryption? Well. Its not what they want.. it what one of their clients want (very big corporation with very unrealistic security standards - you'd think they were NASA or something *grumble*) Their thought is that someone could hack the received email, login to the store using the publically displayed logins details and reek havoc on the store, etc. *shrugs* Sadly this isn't open for debate as a solutions IS required. Any thoughts? Aaron -Original Message- From: Jason Vincent [mailto:[EMAIL PROTECTED]] Sent: November 15, 2002 11:42 AM To: Aaron Wolski; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Email Encryption? Why email? If the Admin tool uses SSL, that is all you need. Regards, J -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: Friday, November 15, 2002 11:39 AM To: 'Aaron Wolski'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Email Encryption? Just thinking here.. PGP is not an option as it would mean EACH user being setup would need the company's public key to decrypt. Not possible as they setup a few hundred accounts each month. Hmm.. anything else? Argh :( Aaron -Original Message- From: Aaron Wolski [mailto:[EMAIL PROTECTED]] Sent: November 15, 2002 11:36 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Email Encryption? OFFTOPIC Sorry for the off topic guys.. But I've just been informed that an application we developed for a client whereby they use an Admin tool to setup user accounts into their store needs to have the login (username and password) encrypted. I am thinking PGP for this but to be honest I've never really worked with PGP and wouldn't have the first clue. Does anyone have any experience with this or can offer and advise at all? Again, sorry for the OT discussion. Aaron -- 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