Re: [PHP-DB] Paging large recordsets
On Fri, 13 Feb 2004, Karen Resplendo wrote: > I guess the time has come that my boss wants "Next", "Previous", "First", > "Last" paging for our data displays of large recordsets or datasets. First, do a query to find out how many rows. select count(*) from table where (your where clauses for the query); That's your # of records. Then do: select count(*) from table where (your clauses) limit ($pagenum*$itemlimit)-$itemlimit), $itemlimit; so if your $itemlimit = 10 items per page, and you are on page 3, it would be ... limit 20, 10 page #1, limit 0,10 etc > Also, how to deal with printing? I would assume that the ideal page size > is not the ideal printed page size. oi vay! In IE 6, this works: Even if your text follows, IE will print a page break. Haven't researched how to do it in Mozilla or Netscape. Beckman ------- Peter Beckman Internet Guy [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] Paging large recordsets
On Fri, 13 Feb 2004, Paul Miller wrote: > I have always heard it was bad to store that much data in a session array? > > Can someone clarify this for me? IMO It is bad to store lots of data in session variables. The $_REQUEST var for the post/get should be enough. URL: search.php?page=10 code: $conf['maxresultsperpage'] = 10; $ref = mysql_query("select count(*) as c from table where subject like '%foo%'"); list($cnt) = mysql_fetch_array($ref); // will assoc work here? dunno, didn't test echo "Displaying ".($conf['maxresultsperpage']*$_REQUEST['page'])-9." through ".($conf['maxresultsperpage']*$_REQUEST['page'])."."; $ref = mysql_query("select subject, data from table where subject like '%foo%' limit ".$conf['maxresultsperpage'].", ".($conf['maxresultsperpage']*$_REQUEST['page'])-10); // loop through array returned from mysql echo "Next"; I think. It might need some tweaking, but you get the idea (I hope). No need to store variables here. Beckman > -Original Message- > From: Robert Twitty [mailto:[EMAIL PROTECTED] > Sent: Friday, February 13, 2004 12:34 PM > To: Karen Resplendo > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] Paging large recordsets > > > Most of the PHP solutions I have seeen require the use of session > variables. You could create an array containing only the unique > identifiers of all the records, and then store it into a session > variable. You would then use another session variable to retain the page > size, and then include the page numbers in the "Next", "Prev", "First", > "Last" and "Absolutr" page links. Printing is probably best done with > dynamically generated PDF instead of HTML. > > -- bob > > On Fri, 13 Feb 2004, Karen Resplendo wrote: > > > I guess the time has come that my boss wants "Next", "Previous", > > "First", "Last" paging for our data displays of large recordsets or > > datasets. > > > > Any good solutons out there already? I have pieces of a few examples. > > > > Also, how to deal with printing? I would assume that the ideal page > > size is not the ideal printed page size. oi vay! > > > > TIA > > > > > > ----- > > Do you Yahoo!? > > Yahoo! Finance: Get your refund fast by filing online > > -- > 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 > --- Peter Beckman Internet Guy [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] Paging large recordsets
On Fri, 13 Feb 2004, Robert Twitty wrote: > If you are not opearating in a stateless environment, then you could use a > cursor. The web is a stateless environment, and therefore the record set > needs to be cached either to disk or memeory. The other alternative is to > rerun the query for each page request. Using disk space to store query > results for the purpose of paging over the web is commonly done by search > engines, and even some database engines use disk space for cursor > implementation. I agree that using session variables for this purpose is > not ideal, but what's the alternative in PHP? Storing only the > identifiers instead of all the data significantly lessons the impact. > > I agree, it should be avoided if possible. If you are running it out of a DB, limiting the results to result 1-10 or 91-100 is pretty fast; caching results seems like more of a headache to me, and depending on how loaded your DB is, not worth the effort. If the query takes 3-5 seconds, then either your DB is configured wrong (no indexes), or your SQL is not written well, or you should consider some sort of DB query caching. Look to the manual for that. ------- Peter Beckman Internet Guy [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] newbie question
On Fri, 13 Feb 2004, t wrote: > hi, > > i am relatively new to php and new to this email list. > > i have what i think are fairly simple questions about using mysql and > php. i have done some research and can't seem to find the answer i > need. > > # 1. i want to set the date format to display dates in a format other > than the standard mysql -mm-dd format. i have tried using the mysql > DATE_FORMAT but i can's seem to get it to work... > > ideally i'd like to display dates as 2 digit date followed by three > letter month abbreviation and leave the year off completely... > > example: 13 feb Use date() Documentation: http://php.net/date > # 2. i want to hide entries that are newer than the current date AND > hide entries older than 365 days. Limit your SQL to ... where date>now() and dateunix_timestamp() and date<(unix_timestamp()-(365*86400)) ... Documentation: http://mysql.com/date_sub (should redirect to http://www.mysql.com/doc/en/Date_and_time_functions.html) ------- Peter Beckman Internet Guy [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] User Authentication
Try fixing your SQL: $result = ("select user_id, password FROM users WHERE username='$username'... You forgot a comma between user_id and password. On Fri, 27 Feb 2004, Craig Hoffman wrote: >// check if username >$result = ("select user_id password FROM users WHERE > username='$username' AND password=md5('$password')"); ------- Peter Beckman Internet Guy [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] MySQL - separating web and database servers
Change, in the /etc/hosts file, this: localhost 209.10.33.12# new db server Hopefully this will work. Haven't tested, just a suggestion. Probably breaks a few other things, but at least mysql will work. Beckman On Thu, 18 Mar 2004, Operator wrote: > Hi everyone, > > I need to put my database server on the another machine - how can I > configure system(Debian Linux)/php/mysql etc. to make it work without > changing all 'localhost' in a hundreds of customer's scripts? > > The problem is, when localhost is specified as a host the connection is made > using unix socket, not TCP (is it possible to change this?). I tried to > export the socket from database server via NFS, but with no success: > > (...) > munmap(0x2e1f2000, 4096) = 0 > rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 > socket(PF_UNIX, SOCK_STREAM, 0) = 3 > fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) > connect(3, {sin_family=AF_UNIX, path="/var/run/mysqld/mysqld.sock"}, > 110) > = -1 ECONNREFUSED (Connection refused) > shutdown(3, 2 /* send and receive */) = 0 > close(3) = 0 > (...) > > Any ideas? > > Regards > Piotr Babula > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] PDFLib
I LOVE FPDF. I don't know where I found it, but I can insert images, it wraps text -- it's pretty fantastic. Get it. Beckman On Mon, 5 Apr 2004, Nathan Mealey wrote: > Has anyone had any experience extracting text from a fulltext > field/column in a MySQL DB and, using the PDFLib library, converting it > to a PDF on-the-fly? I can create the PDF, but it is taking all of the > text (about 6300 characters) and putting it on just one line - which > goes off of the viewable page (as you can imagine). > > If anyone has any ideas or experience with this, that'd be super. > > -- > Nathan Mealey > Director of Operations > Cycle-Smart, Inc. > P.O. Box 1482 > Northampton, MA > 01061-1482 > [EMAIL PROTECTED] > (413) 587-3133 > (413) 210-7984 Mobile > (512) 681-7043 Fax > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] Oracle Client Libraries for Linux
Folks -- I've been trying to figure out where the Oracle client libraries live, but I'm confused as hell. I've read the PHP-DB archives, and everyone keeps talking about installing the client libraries (libclntsh et al), and how that's all you need for Oracle 9i PHP support. Great -- but which options presented horribly by Oracle do I download? On this page: http://otn.oracle.com/software/products/oracle9i/index.html It lists: Oracle9i Release 2 (9.2.0.4) Oracle9i Database Release 2 Enterprise/Standard Edition for Linux x86-64 New (03-May-04) Oracle9i Database Release 2 Enterprise/Standard Edition for Linux New (26-Mar-04) Oracle9i Release 2 (9.2.0.2) Oracle9i Database Release 2 Enterprise/Standard/Personal/Client Edition for Windows XP 2003/Windows Server 2003 (64-bit) Oracle9i Database Release 2 Enterprise/Standard Edition for HP-UX/IA64 (v9.2.0.2) Oracle9i Database Release 2 Enterprise/Standard Edition for HP Alpha OpenVMS Oracle9i Database Release 2 Enterprise/Standard Edition for Linux/IA64, Release 2 (v9.2.0.2) Oracle9i Release 2 (9.2.0.1) Oracle9i Database Release 2 Enterprise/Standard/Personal/Client Edition for Windows Server 2003 (32-bit) Oracle9i Database Release 2 Enterprise/Standard/Personal Edition for Windows NT/2000/XP Oracle9i Database Release 2 Enterprise/Standard Edition for Sun SPARC Solaris (32-bit) Oracle9i Database Release 2 Enterprise Edition for Sun SPARC Solaris (64-bit) Oracle9i Database Release 2 Enterprise/Standard Edition for HP-UX Oracle9i Database Release 2 Enterprise/Standard Edition for Compaq Tru64 Oracle9i Database Release 2 Enterprise/Standard Edition for AIX Oracle9i Database Release 2 Enterprise/Standard Edition for AIX-Based 5L Systems Oracle9i Database Release 2 Enterprise Edition for Linux/390 Oracle9i Database Release 2 Client for Windows 98/NT/2000/XP Oracle9i Release 2 - Developer's Releases Oracle9i Database Release 2 for IBM Power based Linux New! [01-Dec-03] Oracle9i Developer Release 1 (9.2.0.3.0) for Linux / AMD64 Oracle9i Database Release 2 Enterprise Edition for Apple Mac OS X Version 10.2 Jaguar Oracle9i Release 1 (9.0.1) Oracle9i Release 1 (9.0.1) Enterprise Edition (all platforms) Oracle9i Personal Edition for Microsoft Windows 98 Oracle9i Release 1 - Developer's Releases Oracle9i Enterprise Edition for z/Linux, Release 1 - Developer's Release I'm running Linux RH Enterprise 3 on this server, and the Oracle box is remote. My original assumption is to download the second link, 9iR2 for Linux. However, this is 1.5GB worth of a download for three friggin drivers. What the hell? All of the clients are for Windows, Even the 9.0.1 release is 1.1GB. What do I need to download from Oracle to get the drivers for PHP? Please don't just say "go to otn.oracle.com and download the client" because I've been there and cannot for the life of me find it. I don't have the ability to display X Windows remotely, so whatever solution has got to be command line. I'm at my wits end! I've installed Instant Client, so I have the 10g libraries: /usr/lib/oracle/10.1.0.2/client/lib --> ll total 109664 drwxr-xr-x2 root root 4096 Jun 14 12:36 ./ drwxr-xr-x4 root root 4096 Jun 14 12:36 ../ -rw-r--r--2 root root 1417242 Feb 23 19:32 classes12.jar -rw-r--r--1 root root 1353 Feb 23 19:32 glogin.sql -rwxr-xr-x2 root root 13347415 Feb 23 19:32 libclntsh.so.10.1* -rw-r--r--2 root root 2838283 Feb 23 19:32 libnnz10.so -rw-r--r--2 root root 969980 Feb 23 19:32 libocci.so.10.1 -rwxr-xr-x2 root root 91345295 Feb 23 19:32 libociei.so* -rw-r--r--2 root root96117 Feb 23 19:32 libocijdbc10.so -rw-r--r--1 root root 759920 Feb 23 19:32 libsqlplus.so -rw-r--r--2 root root 1353081 Feb 23 19:32 ojdbc14.jar How do I get connected from a remote PHP+Apache box to Oracle9i on linux? Beckman ------- Peter Beckman Internet Guy [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] Re: $_SERVER['HTTP_REFERRER']
Referer is spelled with one R, not two On Fri, 9 Jul 2004, Torsten Roehr wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > For some reason I cannot get this to work. I'm trying to use the referrer > to > > redirect at the end of a form processing script, but it wont recognize the > > referrer. > > > > I read that it just wont work with some browsers, isps, and/or security > > settings. If this is the case, does anyone know a work around? > > > > Thanks in advance! > > > > Jeff > > Hi Jeff, > > do a print_r($_SERVER) to see which other variables are available. Maybe one > of them will contain what you're looking for. > > Regards, Torsten > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] oracle error ORA-12154
network/log/listener.log > Listening Endpoints Summary... > (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc))) > (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=aleph0))) > > (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zed2.mdah.state.ms.us)(PORT=1521))) > Services Summary... > Service "aleph0" has 1 instance(s). > Instance "aleph0", status UNKNOWN, has 1 handler(s) for this service... > Service "extproc" has 1 instance(s). > Instance "extproc", status UNKNOWN, has 1 handler(s) for this service... > The command completed successfully > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] PHP use in Federal Govt
I wrote an application in PHP that the Department of Housing and Urban Development uses for its Grant programs. PHP + MySQL They love it. On Fri, 16 Jul 2004, Galbreath, Mark A wrote: > Alls, > > My division at State is trying to get PHP 5.0 approved for use by developers > in the Department, and the Powers That Be are requesting evidence that other > Federal agencies/military are using PHP, and the extent of it's use. > > Anybody have a clue about this? I sure would appreciate some help! > > tia, > Mark > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ------- Peter Beckman Internet Guy [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] Function that outputs "at line xxx"
Hey -- I'm writing a database error handler function in PHP, and I want it to tell me at what line in what script the error occurred. Is this possible? I know it happens when PHP hits a warning or a fatal error, but is it possible to do in a live script? Or is there a global variable which keeps track of what line in which scripts each execution is at? 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-DB] mysql_affected_cols() ??? or equivalent?
Is it possible to find out how many columns from a row were updated in a single update SQL command? For example: $x = mysql_query("update users set un={$un},pw={$pw},ln={$ln},fn={$fn} where id={$id}"); And the function (something like mysql_affected_cols()) would return 0 if everything stayed the same (like mysql_affected_rows() does), or if something changed, the number of columns that were changed. So if only the password and first name were changed, mysql_affected_cols() would return 2. >From PHP.net regarding mysql_affected_rows(): When using UPDATE, MySQL will not update columns where the new value is the same as the old value. This creates the possiblity that mysql_affected_rows() may not actually equal the number of rows matched, only the number of rows that were literally affected by the query. Any ideas? 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
Re: [PHP-DB] Function that outputs "at line xxx"
John, that does work! Thanks. The problem is this: Database calls are in db.inc. The script problem occurs in wine.inc. True, the SQL is called and executed from db.inc, so __LINE__ and __FILE__ are correct in a way. But how do I find out where in the execution of my script the other files are in their execution? index.php --> calls function in wine.inc --> calls function in db.inc --> throws SQL error, calls function in wine.inc --> which prints error to user nicely and exits What I want is when db.inc throws the error and passes the error text to the db_error function in wine.inc to look pretty for the user, I want to know where the function db_query was called in wine.inc (one level up, the script which called the function now running). Is this possible? Does it exist? Peter On Wed, 23 Oct 2002, 1LT John W. Holmes wrote: > __LINE__ and __FILE__ should work. > > ---John Holmes... > - Original Message - > From: "Peter Beckman" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, October 23, 2002 3:00 PM > Subject: [PHP-DB] Function that outputs "at line xxx" > > > > Hey -- > > > > I'm writing a database error handler function in PHP, and I want it to > tell > > me at what line in what script the error occurred. Is this possible? I > > know it happens when PHP hits a warning or a fatal error, but is it > > possible to do in a live script? Or is there a global variable which > keeps > > track of what line in which scripts each execution is at? > > > > 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 > --- 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] Credit Card Info & Cryptography
an embedded key, 2. keep that key in a safe place, and 3. > > write another module to decrypt, all it needs is the key. This is > > similar to what was done with DVDs, just don't allow your encryption > > algorithms to be compromised. You can put the source code in the same > > place as your key, you can use a code scrambler when you compile, and > > you should already have your server secure already. Again, my point > > is, this is easy because the same entity that encrypts is doing the > > decrypt. Hope this helps. > > > > <>< Ryan > > > > -Original Message- > > From: Doaldo Navai Junior [mailto:doaldo@;triunfo-bsb.com.br] > > Sent: Wednesday, October 23, 2002 12:53 PM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Subject: [PHP-DB] Credit Card Info & Cryptography > > > > > > Suppose I sell some products online and get user's credit card info > > via SSL connection. Isn't there any method (free, preferably) of > > ASSYMETRIC (Public > > key) cryptography I can use with PHP to store this data in a db?? Or > > is there any other good option instead of this? > > > > TIA, > > Doaldo > > > > > > > > -- > > 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 > --- 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] TOO MANY CONNECTIONS!!
You can also do something like this: if ($db_link = mysql_pconnect($host, $user, $pass)) { if (mysql_select_db($db,$db_link)) { return $db_link; } else die("MySQL Error: Cannot select {$db} database using {$user}@{$host}: ".mysql_error()); } else die("MySQL Error: Cannot connect to {$db}: ".mysql_error()); make $db_link global (if you use this in a function) then you can know that you are connected if your script is still running. If you make two connections, just make db_link something different for the other connection, and do this: $x = mysql_query("Select * from users",$db_link); That will force PHP to use the $db_link specified instead of the "last opened" connection. Peter On Fri, 25 Oct 2002, dr. Agon wrote: > Helo, > > why you don't make some kind of "db_connect.php" which will make "mysql_pconnect()" >and include it in top of your first script? You then will be able use mysql query in >everyone of your page. You can also make $mysql_is_connected=true; there and check >that variable in other scrips if need to be sure that this file was already included. > > -- > Regards, A.K. > > "Georgie Casey" <[EMAIL PROTECTED]> wrote in message >news:20021024201835.36082.qmail@;pb1.pair.com... > > Yeah, sometimes I open and close 2 or 3 permanent connections in one page. I > > knida have to as each page is made up of a few different include files, and > > if I dont do seperate connections, it mightnt work. > > > > I'll recode my site to cache everything except search pages, or can I even > > cache these as well?? > > "Duncan Hill" <[EMAIL PROTECTED]> wrote in message > > news:20021023222841.GD30375@;bajan.cricalix.net... > > > On Wed, Oct 23, 2002 at 10:18:07PM +0100, Georgie Casey wrote: > > > > Im getting a too many connections error in my PHP pages at > > > > http://www.free-ringtones.tv. I presume this is from the MySQL server, > > and I > > > > know I access the database a lot for each page. So whats the solution to > > > > > > MySQL has a default of either 50 or 100 concurrent connections. Exceed it > > > and you'll get that error. That parameter is configurable - if you run > > the > > > MySQL daemon itself. If you use shared hosting, you may not be able to > > > tweak it. > > > > > > Do the pages -need- to be totally dynamic, or can you use the caching > > system > > > you mentioned? If so, then wrap code that stats an HTML page for the > > time, > > > and if it's too old, update it. Be sure to use file locking so you don't > > > clobber yourself. > > > > > > Moreover, do you open one connection and re-use it in a page, or do you do > > > multiple opens and closes? > > > > > > > > -- > > 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] URGET HELP : Logic Help - for first record do_this foreach record after do_that
$x = 1; while($row = mysql_fetch_array($result)) { if ($x) { do_something(); $x = 0; continue; } else { do_something_else(); } } This sets $x = 1 before the loop. The first time it goes through the loop it does something for the first record and sets $x = 0; Every time you loop through after that $x will equal 0 and that do_something_else() condition will be used for every subsequent loop. Peter On Fri, 25 Oct 2002, Aaron Wolski wrote: > > Hey guys, > > Not really off topic as this involves some Db work as I have to query > the DB. > > Got a logic problem that was jumped dumped on me from UPS (dummys!). > > Basically I need to pull some records out of a database and for the > first record do_this logic and for each record after in the array > do_something_else logic. > > How would I approach this? > > something like: > > for ($first_record) { > > do_something; > > } else { > > do_something_else; > > } > > Any clues? > > Thanks! > > Aaron > > -Original Message- > > From: Graeme McLaren [mailto:mickel@;ntlworld.com] > > Sent: Friday, October 25, 2002 2:40 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] Inserting checkbox data > > > > > > Hi all, I'm having a problem inserting a value from a > > checkbox into a MySQL DB. I can print out what the variable > > holds, the problem is it just won't go into the DB. Weird > > thing is when I login to SSH there isn't a NULL value for it > > instead that field is just blank. > > > > Anyone got any ideas what the problem is? > > > > > > The HTML that is used for the checkbox is: > > > > Gift Wrapping: > > > > > > So it should theoretically insert "Y" into the DB > > > > Here is the code that appears to be causing the problem: > > > > $number=count($GiftWrapping); > > for($a=0;$a<=$number;$a++) > > { > > echo $GiftWrapping[$a]; > > $GW = $GiftWrapping[$a]; > > echo $GW; > > } > > > > if ($Submit == "Submit") { > > $sql = "INSERT INTO SiteMember SET > > FirstName = '$FirstName', > > LastName = '$LastName' > > Username = '$Username', > > Password = '$Password', > > GiftWrapping = '$GW'"; > > } > > > > > > Thank you in advance for any help. > > > > Graeme :) > > > > > > Public Sub House() > > > > On Error Resume drink > > > > If Pint.empty = True Then > > Pint.refill > >Else > > Pint.drink > > End if > > > > stomach.add Pint > > > > MsgBox " I've had " & stomach.count & " Pints" > > MsgBox "VERY DRUNK" > > > > End Sub > > > > > > > -- > 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] localhost versus remote
That's some nasty code Two things: 1. What is $ton in your query? 2. Change your mysql_query row to this: $result = mysql_query($query) or die("MySQL Error: ".mysql_error()."SQL: $query"); So when your query dies, you'll know why. Peter On Sun, 27 Oct 2002, Seabird wrote: > sorry for my "furry" message before. > > I search a DB in multiple search fields and my result code looks like this: > > $db=test; > $table=airline_a; > > if (! $link) > die( "couldn't connect"); > mysql_select_db($db) > or die ("won't open test:".mysql_error() ); > > > $db_res=mysql_list_dbs($link); > $num=mysql_num_rows($db_res); > for($x=0; $x<$num; $x++) > > > $db_res=mysql_list_tables("$db",$link); > $num=mysql_num_rows($db_res); > for($x=0; $x<$num; $x++) > > > > $count = mysql_query("SELECT * FROM $table");//selects all rows > $total = mysql_num_rows ($count);//counts the selected rows > > $query = "SELECT * FROM $table WHERE Field1 LIKE '%$icao%' $ton > Field2 LIKE '%$name%' $ton > Field3 LIKE '%$country%' > ORDER BY $sort"; > $result = mysql_query($query) or die("Error in > query");//so this is the error I > get/ > $total = mysql_num_rows ($result);//counts the selected rows > print "your search returned ".$total." matches"; > > print "\n"; > print "IcaoName (Location) class=grey>Country"; > while($row = mysql_fetch_assoc($result)){ > print "\n" > ."" . $row['Field1'] . "\n" >."" . $row['Field2'] . "\n" >."" . $row['Field3'] . " \n" >; > } > > print ""; > ?> > > > The problem I have is that my setup on my localhost and my remote are > identical (I think) and the files are the same. So where does it go wrong. > All I get as error is 'Error in query' which doesn't tell me much. Please > help me... > > Jacco > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "John W. Holmes" <[EMAIL PROTECTED]> wrote in message > news:002801c27dc0$844bfb00$7c02a8c0@;coconut... > > > Hi everyone, > > > I'm using a MySQL DB and a search form. Eveery thing works fine, but > > when > > > I > > > upload, it has a Error in query. I checked all the little details but > > > can't > > > find out why? Any ideas are welcome. > > > > > > Jacco > > > > This one is an easy problem to fix. All you have to do is find the error > > and correct what's causing the problem. > > > > Hope that helps. > > > > ---John Holmes... > > > > PS: If you found my answer worthless, it was about as helpful as your > > question. What error? What versions of PHP and MySQL? What's your > > code??? > > > > > > > > -- > 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] localhost versus remote
It seems to me you have no idea what you are doing. You really need to learn how to troubleshoot your code, as this is a very simple problem to fix. It's not your code. The variables you put in your SQL are empty. Your code: $query = "SELECT * FROM $table WHERE Field1 LIKE '%$icao%' $ton Field2 LIKE '%$name%' $ton Field3 LIKE '%$country%' ORDER BY $sort"; Problem: $ton should equal "AND" or "OR" but it doesn't equal anything. In fact, all of your variables are either empty or not set. You are trying to get: Select * from table where field1 like '%something%' AND field2 like '%something%' AND field3 like '%something%' order by field1 But since $ton is empty you are executing this: select * from airline_a where field1 like '%%' field2 like '%%' field3 like '%%' order by Which is COMPLETELY INVALID. Notice no "AND" statements between fields? I won't publicly flog you, but please don't respond. I believe this list is for help with more advanced issues, not "how to properly write an SQL command and troubleshoot your code for you." Peter On Sun, 27 Oct 2002, Seabird wrote: > My error came out like this: > > MySQL Error: You have an error in your SQL syntax near 'Field2 LIKE '%%' > Field3 LIKE '%%' ORDER BY ' at line 2 > SQL: SELECT * FROM airline_a WHERE Field1 LIKE '%%' Field2 LIKE '%%' Field3 > LIKE '%%' ORDER BY > > Why does it not do this at my localhost?? I have the % around my code so > that it searches correctly right? Or should I clean up my code?? > Jacco > > > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "Peter Beckman" <[EMAIL PROTECTED]> wrote in message > news:20021027151406.T64513-10@;thermonuclear.org... > > That's some nasty code > > > > Two things: > > > > 1. What is $ton in your query? > > > > 2. Change your mysql_query row to this: > > > > $result = mysql_query($query) or die("MySQL Error: > ".mysql_error()."SQL: $query"); > > > >So when your query dies, you'll know why. > > > > Peter > > > > On Sun, 27 Oct 2002, Seabird wrote: > > > > > sorry for my "furry" message before. > > > > > > I search a DB in multiple search fields and my result code looks like > this: > > > > > > > > $db=test; > > > $table=airline_a; > > > > > > if (! $link) > > > die( "couldn't connect"); > > > mysql_select_db($db) > > > or die ("won't open test:".mysql_error() ); > > > > > > > > > $db_res=mysql_list_dbs($link); > > > $num=mysql_num_rows($db_res); > > > for($x=0; $x<$num; $x++) > > > > > > > > > $db_res=mysql_list_tables("$db",$link); > > > $num=mysql_num_rows($db_res); > > > for($x=0; $x<$num; $x++) > > > > > > > > > > > > $count = mysql_query("SELECT * FROM $table");//selects all rows > > > $total = mysql_num_rows ($count);//counts the selected rows > > > > > > $query = "SELECT * FROM $table WHERE Field1 LIKE '%$icao%' $ton > > > Field2 LIKE '%$name%' $ton > > > Field3 LIKE '%$country%' > > > ORDER BY $sort"; > > > $result = mysql_query($query) or die("Error in > > > query");//so this is the error I > > > get/ > > > $total = mysql_num_rows ($result);//counts the selected rows > > > print "your search returned ".$total." matches"; > > > > > > print "\n"; > > > print "IcaoName > (Location) > > class=grey>Country"; > > > while($row = mysql_fetch_assoc($result)){ > > > print "\n" > > > ."" . $row['Field1'] . "\n" > > >."" . $row['Field2'] . "\n" > > >."" . $row['Field3'] . " \n" > > >; > > > } > > > > > > print ""; > > > ?> > > > > > > > > > The problem I have i
Re: [PHP-DB] localhost versus remote
Please stop responding to the list. Your problems are far to simple to bother everyone on the list. I have no idea what you mean when you say "locally" or "remote." Basically your problem is that your script does not see any of the variables. They are empty or not set. They are not getting passed from the form. Who knows. php.ini configured differently locally than remotely. I assume that Server1 is local and server2 is remote. The problem is that server2 probably hasn't got "register_globals" turned on. Do this: Change all your variables that you don't define in your script to this: $GLOBALS[icao] $GLOBALS[name] $GLOBALS[country] $GLOBALS[sort] etc. Also, to see if they even exist, use this: echo ""; print_r($_GET); // or use print_r($_POST) if you are using a POST instead of a GET method for your form echo ""; This prints out all the variables stored. I would also see if the variables are empty (which they are from what you show). Put this line in your script: if (empty($ton)) die("variable ton is empty ($ton). Global: ({$GLOBALS[ton]}) POST ({$_POST[ton]}) GET ({$_GET[ton]})"); If it dies there, it will print out the Global, Post and Get variables of "ton" to see if they exist there. If they do, then you know you have to change the variables in your script to those variables in order to get this to work. Do you know what version of PHP you are using locally and remotely? If remotely is not above 4.0.0, then there is different values for _POST and _GET. Peter On Sun, 27 Oct 2002, Seabird wrote: > Hi Peter I understand your frustration, > > but how come that it works fine on my localhost, prosessing the exact same > code?? I thought it worked because it works fine locally > > What is the differense in my code posted locally and remote? > > Jacco > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "Peter Beckman" <[EMAIL PROTECTED]> wrote in message > news:20021027172628.I64513-10@;thermonuclear.org... > > It seems to me you have no idea what you are doing. You really need to > > learn how to troubleshoot your code, as this is a very simple problem to > > fix. It's not your code. The variables you put in your SQL are empty. > > > > Your code: > > > > $query = "SELECT * FROM $table WHERE Field1 LIKE '%$icao%' $ton > > Field2 LIKE '%$name%' $ton > > Field3 LIKE '%$country%' > > ORDER BY $sort"; > > > > Problem: > > > > $ton should equal "AND" or "OR" but it doesn't equal anything. In fact, > > all of your variables are either empty or not set. > > > > You are trying to get: > > > > Select * from table where field1 like '%something%' AND > > field2 like '%something%' AND > > field3 like '%something%' > > order by field1 > > > > But since $ton is empty you are executing this: > > > > select * from airline_a where field1 like '%%' > >field2 like '%%' > >field3 like '%%' > >order by > > > > Which is COMPLETELY INVALID. Notice no "AND" statements between fields? > > > > I won't publicly flog you, but please don't respond. I believe this list > > is for help with more advanced issues, not "how to properly write an SQL > > command and troubleshoot your code for you." > > > > Peter > > > > On Sun, 27 Oct 2002, Seabird wrote: > > > > > My error came out like this: > > > > > > MySQL Error: You have an error in your SQL syntax near 'Field2 LIKE '%%' > > > Field3 LIKE '%%' ORDER BY ' at line 2 > > > SQL: SELECT * FROM airline_a WHERE Field1 LIKE '%%' Field2 LIKE '%%' > Field3 > > > LIKE '%%' ORDER BY > > > > > > Why does it not do this at my localhost?? I have the % around my code so > > > that it searches correctly right? Or should I clean up my code?? > > > Jacco > > > > > > > > > -- > > > http://seabird.jmtech.ca > > > > > > Attitude is Everything! > > > But Remember, Attitudes are Contagious! > > > Is Yours worth Catching > > > "Peter Beckman" <[EMAIL PROTECTED]> wrote in message > > > news:20021027
Re: [PHP-DB] localhost versus remote
First off, use quotes. If you are going to be a good coder, always use quotes in your HTML and your PHP. In PHP: $table="aviation_a"; // NOT $table=aviation_a; Sure, they both work, but they can cause problems in the future, and it is considered BAD CODING. USE QUOTES. Fix all your input tags with quotes. The problem is that PHP on the remote end probably doesn't have register_globals set. Change your code according the email I just sent. Peter On Sun, 27 Oct 2002, Seabird wrote: > I also provide my searchform here. The problem I have is that everything > works when run on my localhost (which is my testing location before upload. > I have the exact same code local and remote. > > My searchform should pass the code. here it comes: > > > > > > > > > Icao code: > maxlength="3"> > > > > Airline name: > > > > Country: > > $query = "SELECT DISTINCT(Field3) FROM $table ORDER BY Field3"; > $result = mysql_query($query) or die("Error in query"); > > while($row = mysql_fetch_assoc($result)) > { > print "".$row['Field3']."\n"; > } > ?> > > > > Search Criteria: > > AND > OR > > > > Sort by: > > Designator > Name > Country > > > > > > > > class="signature">***no wildcards permitted*** > > > > > > Thanx, and excuse my newbie ignorance, > Jacco > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "John W. Holmes" <[EMAIL PROTECTED]> wrote in message > news:002601c27e08$680a2a50$7c02a8c0@;coconut... > > > MySQL Error: You have an error in your SQL syntax near 'Field2 LIKE > > '%%' > > > Field3 LIKE '%%' ORDER BY ' at line 2 > > > SQL: SELECT * FROM airline_a WHERE Field1 LIKE '%%' Field2 LIKE '%%' > > > Field3 > > > LIKE '%%' ORDER BY > > > > You need some ANDs between each of your field LIKE '%%' clauses. > > > > WHERE field1 LIKE '%%' and field2 LIKE '%%' ... > > > > ---John Holmes... > > > > > > > > -- > 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] PHP/MySQL and passing url params
th="28"> > > > > face="Arial, Helvetica, sans-serif">Address: > > >maxlength="38"> > > > > face="Arial, Helvetica, sans-serif">City: > > >maxlength="23"> > > > > face="Arial, Helvetica, sans-serif">State: > > >maxlength="26"> > > > > face="Arial, Helvetica, sans-serif">Zip: > > >maxlength="10"> > > > > face="Arial, Helvetica, sans-serif">Phone: > > >maxlength="12"> > > > >face="Arial, Helvetica, sans-serif">UserName: >size="27" maxlength="25"> > > > face="Arial, Helvetica, sans-serif">eMail > Address: > >maxlength="38"> > > > > > > > > > > > > > > mysql_free_result($rsID); > ?> > > > > -- > 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] PHP/MySQL and passing url params
Why'd you use it in the first place? Where does $row_rsID['userID'] get set? Why is it in your script if you don't know where it is set and what it is set to? You set it like this: $row_rsID['userID'] = "whatever you want here, probably an int like '0'"; Several ways to define arrays: $array = array(); // set empty array $hash = array("stuff"=>"foo"); // a hash effectively $array = array(); array_push($array, "stuff to push onto the array"); $array[] = "foo"; // same as "array_push" $array[37] = "foo"; // set array index 37 to foo. $array['stuff'] = "foo"; // set "hash" (array using words) stuff to foo $array[0][0][stuff] = "foo"; //multidimensional array. $array[0][1][stuff] = array("stuff"=>"foo"); Peter On Mon, 28 Oct 2002, alex hogan wrote: > How do I set $row_rsID['userID']? > > Do I use (isset($row_rsID['userID']); or something similar? > > Would I define an array, $my_array[]; and then look to populate the > array dynamically? > $my_array[0] = "something"; > $my_array[1] = "something else"; > > I've probably missed something in the docs but I don't seem to find any > hard fast rules on defining arrays or rediminsioning them. > > alex > > > -Original Message- > > From: Peter Beckman [mailto:beckman@;purplecow.com] > > Sent: Sunday, October 27, 2002 9:29 PM > > To: alex hogan > > Cc: [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] PHP/MySQL and passing url params > > > > The first question is is $row_rsID actually an array when you run the > > script? > > > > If it is, is $row_rsID['userID'] set? > > > > If it isn't, is $row_rsID['userid'] set? > > > > If you want to set the variable $row_rsID statically do this: > > > > $row_rsID = array("userID"=>1); > > > > Where does $row_rsID get set? Does it set $row_rsID['userID']? > > > > Peter > > > > On Sun, 27 Oct 2002, alex hogan wrote: > > > > > Sorry..., my bad. Too wrapped up in the problem. > > > > > > > > > > > > Notice: Undefined variable: row_rsID in > > > D:\web\hogana\demo\login\TMPbl2tw4o24u.php on line 48 > > > > > > Warning: Cannot add header information - headers already sent by > (output > > > started at D:\web\hogana\demo\login\TMPbl2tw4o24u.php:48) in > > > D:\web\hogana\demo\login\TMPbl2tw4o24u.php on line 53 > > > > > > > > > > > function GetSQLValueString($theValue, $theType, $theDefinedValue = > "", > > > $theNotDefinedValue = "") > > > { > > > $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : > > > $theValue; > > > > > > switch ($theType) { > > > case "text": > > > $theValue = ($theValue != "") ? "'" . $theValue . "'" : > "NULL"; > > > break; > > > case "long": > > > case "int": > > > $theValue = ($theValue != "") ? intval($theValue) : "NULL"; > > > break; > > > case "double": > > > $theValue = ($theValue != "") ? "'" . doubleval($theValue) . > "'" : > > > "NULL"; > > > break; > > > case "date": > > > $theValue = ($theValue != "") ? "'" . $theValue . "'" : > "NULL"; > > > break; > > > case "defined": > > > $theValue = ($theValue != "") ? $theDefinedValue : > > > $theNotDefinedValue; > > > break; > > > } > > > return $theValue; > > > } > > > > > > $editFormAction = $HTTP_SERVER_VARS['PHP_SELF']; > > > if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { > > > $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING']; > > > } > > > > > > if ((isset($HTTP_POST_VARS["MM_insert"])) && > > > ($HTTP_POST_VARS["MM_insert"] == "frmReg")) { > > > $insertSQL = sprintf("INSERT INTO user (username, fname, lname, > > > address, city, `state`, zip, phone, email) VALUES (%s, %s, %s, %s, > %s, > > > %s, %s, %s, %s)", > > > > GetSQLValueString($H
Re: [PHP-DB] data_seek and fetch_row
One problem: you are using a database wrapper for which you have provided no information. $db->query is a function of a class $db, but we don't know what that function does exactly. Anyway, the $queryid doesn't contain a valid MySQL result resource. So go back a few steps. Is $various_query a valid MySQL result? Print it. Keep adding print statements all over the place until you find out when $various_query is no longer (or if ever) a valid MySQL result resource. My bet is that $db->query isn't returning a valid MySQL result. Do a print after your query on $various_query and see what it shows. It should show: Resource id #2 or something similar when you print it. Peter On Mon, 28 Oct 2002 [EMAIL PROTECTED] wrote: > Hi, > > I got a query and I want to jump through the results.Here's my query: > > $various_query = $db->query( "SELECT > int_param5, > char_param1, > is_admin_pass > FROM various" ); > > And here I seek the data and fetch it into an array with mysql_fetch_row: > > $various = $db->seek( $various_query, 0 ); > > function seek( $result, $row ) > { > > $result = mysql_data_seek( $result, $row ); > return $this->row( $result ); > > } > > function row( $queryid ) > { > $this->record = mysql_fetch_row( $queryid ); > return $this->record; > } > But if I load the page,I get this error: > Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result > resource in > > What is wrong??? > --- 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] Interbase BLOB problem
Your SQL query doesn't need that semicolon at the end of the query -- lose it. I never used ibase, so here's what I found from the PHP Manual page for ibase_query: Using BLOB Insert BLOB: /* create blob */ $blob_id = ibase_blob_create(); /* fill blob */ ibase_blob_add($blob_id, $var_datablob); /* close new blob */ $blob_id_str = ibase_blob_close($blob_id); /* insert into table */ ibase_query("INSERT INTO BLOB_TABLE (ID, BLOB) VALUES (1, ?)",$blob_id_str); Open BLOB: /* query */ $set = ibase_query("SELECT BLOB FROM BLOB_TABLE WHERE ID = 1"); /* fetche a row */ $row = ibase_fetch_object($set); /* open BLOB for read */ $blob_id = ibase_blob_open($row->BLOB); /* get BLOB data */ $stringBLOB = ibase_blob_get($blob_id); /* print BLOB */ echo $stringBLOB; /* close new blob */ ibase_blob_close($blob_id); /* free result */ ibase_free_result($set); Peter On Tue, 29 Oct 2002, David Russell wrote: > Hi all, > > I have a file I need to insert into a blob in a interbase table. Code as > follows: > > $filehandle = fopen($file, "r"); > $blob_id = ibase_blob_import($filehandle); > $qry = "INSERT INTO BPFATTACHMENTS "; > $qry = $qry . "(BPFATTACHMENTNO, BPF, ATTACHMENTTYPE, FILENAME, > FILESIZE, ATTACHMENT)"; > $qry = $qry . "VALUES"; > $qry = $qry . "($bpfAttNo, $BPFNo, $AttachmentType, '$file_name', > $file_size, ?);"; > $res = ibase_query($qry, $blob_id); > > I have a ibase_pconnect prior to this. > > The problem is that is only adds a tiny part of the file (ie 5k of the > 200k file) What should I be looking for? > > Thanks > > David Russell > IT Support Manager > Barloworld Optimus (Pty) Ltd > Tel: +2711 444-7250 > Fax: +2711 444-7256 > e-mail: [EMAIL PROTECTED] > web: www.BarloworldOptimus.com > --- 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] Column Defualts
With MySQL you save a bit by declaring a column not null. If it is null, you are using a bit. For performance on high volume and high transaction servers, declaring your columns not null will help, if only slightly. Peter On Tue, 29 Oct 2002, Ryan Jameson (USA) wrote: > No, I believe all databases have an isnull bit flag to go with any column > stored. So whether you set it or not the bit is being used. > > <>< Ryan > > -Original Message- > From: Gerard Samuel [mailto:gsam@;trini0.org] > Sent: Tuesday, October 29, 2002 9:47 AM > To: php-db > Subject: [PHP-DB] Column Defualts > > > Is defaulting a column to NULL considered as a waste of space?? > I have a table that has 2 columns (so far) that defualt to NULL, and > potentially, > there can be good amount of rows with NULL. Just wondering... > > -- > Gerard Samuel > http://www.trini0.org:81/ > http://dev.trini0.org:81/ > > > > -- > 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 > > --- 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] Column Defualts
This should be useful, mysql-wise: http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimisation.html#Data_size Declare columns to be NOT NULL if possible. It makes everything faster and you save one bit per column. Note that if you really need NULL in your application you should definitely use it. Just avoid having it on all columns by default. Peter On Tue, 29 Oct 2002, Peter Beckman wrote: > With MySQL you save a bit by declaring a column not null. If it is null, > you are using a bit. For performance on high volume and high transaction > servers, declaring your columns not null will help, if only slightly. > > Peter > > On Tue, 29 Oct 2002, Ryan Jameson (USA) wrote: > > > No, I believe all databases have an isnull bit flag to go with any column > > stored. So whether you set it or not the bit is being used. > > > > <>< Ryan > > > > -Original Message- > > From: Gerard Samuel [mailto:gsam@;trini0.org] > > Sent: Tuesday, October 29, 2002 9:47 AM > > To: php-db > > Subject: [PHP-DB] Column Defualts > > > > > > Is defaulting a column to NULL considered as a waste of space?? > > I have a table that has 2 columns (so far) that defualt to NULL, and > > potentially, > > there can be good amount of rows with NULL. Just wondering... > > > > -- > > Gerard Samuel > > http://www.trini0.org:81/ > > http://dev.trini0.org:81/ > > > > > > > > -- > > 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 > > > > > > --- > 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 > --- 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] new to cookies
First off, cookie documentation: http://www.php.net/manual/en/function.setcookie.php Second, since you store your info in the DB, it might be easier and more scalable to use a "$user" object which contains everything about the user: userID, username, email, etc. for quick reference: $user = mysql_fetch_object($result); $user->id is now (ie) 37. $user->username is now Seabird $user->password is now superman Now register the user variable to the session: session_start(); // will start the session unless it is already started somewhere else session_register("user"); // note, no dollar sign! Now if you have register_globals on, $user will be defined globally. If not, $GLOBALS[user]->username or $_SESSION[user]->username will work. Now go add a column to your user table called "login_cookie." Do something funky like $cookie_string = md5($user->username.$user->email.date("r")); $x = mysql_query("update user set login_cookie='{$cookie_string}' where id=$user->id"); Then $encID = rot13(base64_encode($user->id)). $cookie_contents = "$encID|$cookie_string"; setcookie("MYcookie_string", $cookie_contents, 13); // fix that expire date to whatever you want, 3 days, 6 months When the user comes to any page of the site: if (!empty($_COOKIE[MYcookie_string])) { list($encid, $str) = split("|",$_COOKIE[MYcookie_string]); $realid = rot13(base64_decode($encid)); $x = mysql_query("select * from users where login_cookie='{$str}' and id={$realid}"); if (mysql_num_rows($x) == 1) { $user = mysql_fetch_object($x); session_register("user"); } else { // delete the cookie, it's bad setcookie("MYcookie_string",""); } } Now if their cookie string and their user ID matches what you have in the DB, then you log them in via sessions. If not, you do nothing. Peter On Tue, 29 Oct 2002, Seabird wrote: > Hi everyone, > > I created a login on my page that handles with a session. I also would like > to add a cookie so that people don't have to sign in every time they visit > my page, but I have no clue how to create it. Is there anyone out there > willing to help? > > my login script: > > if(isset($_POST['submit'])) { // if form has been submitted > /* check they filled in what they were supposed to and authenticate */ > if(!$_POST['uname'] | !$_POST['passwd']) { > print ' > >maxlength="8"> >name="passwd"> > > > please fill in the required > fields. > > '; > } > // authenticate. > if(!get_magic_quotes_gpc()) { > $_POST['uname'] = addslashes($_POST['uname']); > } > $check = $db_object->query("SELECT username, password FROM users WHERE > username = '".$_POST['uname']."'"); > if(DB::isError($check)) { > print ' > >maxlength="8"> >name="passwd"> > > > username doesn\'t exist. class="header" > href="javascript:loadPage(\'mainlayer\',null,\'login/signup.php\')">sign up > here > > '; > } > $info = $check->fetchRow(); > // check passwords match > $_POST['passwd'] = stripslashes($_POST['passwd']); > $info['password'] = stripslashes($info['password']); > $_POST['passwd'] = md5($_POST['passwd']); > if($_POST['passwd'] != $info['password']) { > print ' > >maxlength="8"> >name="passwd"> > > > wrong password, try again > > '; > } > > // if we get here username and password are correct, register session > variables and set > // last login time. > $date = date('m d, Y'); > $update_login = $db_object->query("UPDATE users SET last_login = '$date' > WHERE username = '".$_POST['uname']."'"); > $_POST['uname'] = stripslashes($_POST['uname']); > $_SESSION['username'] = $_POST['uname']; > $_SESSION['password'] = $_POST['passwd']; > $db_object->disconnect(); > ?> > WelcomeYou are logged in as: > > > } > else { // if form hasn't been submitted > ?> > > >maxlength="8"> >name="passwd&
Re: [PHP-DB] Session variables and arrays
Well, can't say I see the same problem: "bye"); print_r($_SESSION['foo']); echo "\n\n"; print is_array($_SESSION['foo']); Outputs: X-Powered-By: PHP/4.2.2 Content-type: text/html Array ( [hi] => bye ) 1 Which is what I'd expect it to show. Now how did you assign categories? Maybe the var is a scalar and is actually "Array (\n [0] => '1';\n [1] => '12';" and you are confused.o If you are saying: $_SESSION['categories'] = "Array ( [0] = '1'; "; Then it IS a scalar. Try this: print ":::{$_SESSION['categories']}:::"; If you get this: :::Array::: Then I have no clue what the problem is If you don't get that, then we know what your problem is. Peter On Tue, 29 Oct 2002, Ryan Neudorf wrote: > I'm having a problem with session variables and arrays. > I'm building a multi step sign up form and I need to store all the > variable until the final step, when they are inputed to a database. I > thought the best way to do this would be to store the contents for > $HTTP_POST_VARS in session variables. This works fine for everything > except for my array of checkboxes. > > When I do a print_r($_SESSION) it displays the following for the > sessionvariable assigned to the checkboxes: > [categories] => Array ( > [0] => '1'; > [1] => '12'; > ... Etc ... > > But when I run any sort of array function (is_array, foreach) on > $_SESSION['categories'] it appears that it is a scalar, not an array. > > Any ideas? > > - Ryan > > > -- > 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] losing my session variables
Put "session_start()" somewhere in your code. $_SESSION isn't set until you "start" your session. And don't set session variables by $_SESSION[foo] = bar; DO this: $foo = bar; session_register("foo"); Much better. However, if anyone can correct me, go for it. I just believe that setting global variables that the system controls and writes is a bad idea unless you use the functions that you should. Get out of the habit of SETTING variables using $_POST or $_SESSION or $GLOBALS. DO get in the habit of setting globals by just setting your variables correctly in the right scope. Peter On Tue, 29 Oct 2002, Seabird wrote: > Hi everyone, > > I use a login-script, but for some reason I keep losing my $_SESSION > variables. Can Anyone tell me why? > > Here's my login script: > > if(isset($_POST['submit'])) { // if form has been submitted > /* check they filled in what they were supposed to and authenticate */ > if(!$_POST['uname'] | !$_POST['passwd']) { > print ' > >maxlength="8"> >name="passwd"> > > > please fill in the required > fields. > > '; > } > // authenticate. > if(!get_magic_quotes_gpc()) { > $_POST['uname'] = addslashes($_POST['uname']); > } > $check = $db_object->query("SELECT username, password FROM users WHERE > username = '".$_POST['uname']."'"); > if(DB::isError($check)) { > print ' > >maxlength="8"> >name="passwd"> > > > username doesn\'t exist. class="header" > href="javascript:loadPage(\'mainlayer\',null,\'login/signup.php\')">sign up > here > > '; > } > $info = $check->fetchRow(); > // check passwords match > $_POST['passwd'] = stripslashes($_POST['passwd']); > $info['password'] = stripslashes($info['password']); > $_POST['passwd'] = md5($_POST['passwd']); > if($_POST['passwd'] != $info['password']) { > print ' > >maxlength="8"> >name="passwd"> > > > wrong password, try again > > '; > } > > // if we get here username and password are correct, register session > variables and set > // last login time. > $date = date('m d, Y'); > $update_login = $db_object->query("UPDATE users SET last_login = '$date' > WHERE username = '".$_POST['uname']."'"); > $_POST['uname'] = stripslashes($_POST['uname']); > $_SESSION['username'] = $_POST['uname']; > $_SESSION['password'] = $_POST['passwd']; > $db_object->disconnect(); > ?> > Welcome href="javascript:loadPage('mainlayer',null,'users/edit.php?user= ['username']?>')"> color="white"> href="login/logout.php">Logout > > } > else { // if form hasn't been submitted > ?> > > >maxlength="8"> >name="passwd"> > > >href="javascript:loadPage('mainlayer',null,'login/signup.php')">sign up > here > > } > ?> > > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > > > > -- > 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] Re: losing my session variables
prepend.php gets called before running any page on a site. Put the "session_start()" in the prepend.php and you won't have to worry where you put it. Learn more about it on the php web site (don't have the url handy). Peter On Tue, 29 Oct 2002, Seabird wrote: > turns out, I already have a session_start(). I have some seperate files and > use them as includes. The thing is... my login form is located on my > "index.php" and if I do a login, only this file will recognize my session > variables. > > I load pages external into a layer, but none of them get the session > variables. I'll upload some files so you can see. I'll post this. > > Thanx already, > Jacco > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "Baroiller Pierre-Emmanuel" <[EMAIL PROTECTED]> wrote in message > news:20021030002059.9083.qmail@;pb1.pair.com... > > You only need to add session_start() in your script before storing your > data > > into the $_SESSION array. > > Without session_start(), no session is started by php... > > > > Regards, > > P.E. Baroiller > > > > "Seabird" <[EMAIL PROTECTED]> a écrit dans le message de news: > > [EMAIL PROTECTED] > > > Hi everyone, > > > > > > I use a login-script, but for some reason I keep losing my $_SESSION > > > variables. Can Anyone tell me why? > > > > > > Here's my login script: > > > > > > > > if(isset($_POST['submit'])) { // if form has been submitted > > > /* check they filled in what they were supposed to and authenticate */ > > > if(!$_POST['uname'] | !$_POST['passwd']) { > > > print ' > > > > > >> > maxlength="8"> > > >> > name="passwd"> > > > > > > > > > please fill in the required > > > fields. > > > > > > '; > > > } > > > // authenticate. > > > if(!get_magic_quotes_gpc()) { > > > $_POST['uname'] = addslashes($_POST['uname']); > > > } > > > $check = $db_object->query("SELECT username, password FROM users WHERE > > > username = '".$_POST['uname']."'"); > > > if(DB::isError($check)) { > > > print ' > > > > > >> > maxlength="8"> > > >> > name="passwd"> > > > > > > > > > username doesn\'t exist. > > class="header" > > > href="javascript:loadPage(\'mainlayer\',null,\'login/signup.php\')">sign > > up > > > here > > > > > > '; > > > } > > > $info = $check->fetchRow(); > > > // check passwords match > > > $_POST['passwd'] = stripslashes($_POST['passwd']); > > > $info['password'] = stripslashes($info['password']); > > > $_POST['passwd'] = md5($_POST['passwd']); > > > if($_POST['passwd'] != $info['password']) { > > > print ' > > > > > >> > maxlength="8"> > > >> > name="passwd"> > > > > > > > > > wrong password, try again > > > > > > '; > > > } > > > > > > // if we get here username and password are correct, register session > > > variables and set > > > // last login time. > > > $date = date('m d, Y'); > > > $update_login = $db_object->query("UPDATE users SET last_login = > '$date' > > > WHERE username = '".$_POST['uname']."'"); > > > $_POST['uname'] = stripslashes($_POST['uname']); > > > $_SESSION['username'] = $_POST['uname']; > > > $_SESSION['password'] = $_POST['passwd']; > > > $db_object->disconnect(); > > > ?> > > > Welcome > > > > > href="javascript:loadPage('mainlayer',null,'users/edit.php?user= > > ['username']?>')"> > > color="white"> > > href="login/logout.php">Logout > > > > > > > > } > > > else { // if form hasn't been submitted > > > ?> > > > > > > > > >> > maxlength="8"> > > >> > name="passwd"> > > > > > > > > >> > href="javascript:loadPage('mainlayer',null,'login/signup.php')">sign up > > > here > > > > > > > > } > > > ?> > > > > > > -- > > > http://seabird.jmtech.ca > > > > > > Attitude is Everything! > > > But Remember, Attitudes are Contagious! > > > Is Yours worth Catching > > > > > > > > > > > > > > -- > 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] Decimal places.
printf("%d",($eall - $sall) / 1000); On Wed, 30 Oct 2002, Andrew Wilson wrote: > Hay guys, > I have two variables ( integers ) that are being minused one from the other > and i am printing the result to the screen but i am getting unwanted > decimals. > > print ($eall - $sall) / 1000; > > My question is what is the easiest way to strip decimals off the above > result. The only way i know around it is if i piped the above statement into > another varible and set that variable to an integer then printed that. > > I dont really want to do this as i will end up with 50 extra variables. > Thanks in advance for your comments. > > Andrew Wilson > Technical Support > Netway Networks > 8920-8877 > > > > > Netway Networks Pty Ltd > (T) 8920 8877 > (F) 8920 8866 > > > --- 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] Session variables and arrays
On Wed, 30 Oct 2002, Ryan Neudorf wrote: > Ok. The categories are coming from checkboxes, e.g.: > Accountant > > Which then are handled by a $cgi class dealy and handed to the > $_SESSION['categories'] variable before being forwarded to the next > step. I was thinking that the problem might be with the $cgi object, but > when I print_r($_SESSION['categories']) it shows the contents of the > array. > > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got > :::Array::: Try this after that print: print is_array($_SESSION['categories']); You should get a 1 -- if you don't, try this: print gettype($_SESSION['categories']); You should get "array" but if you don't, there is something strange going on! If you get "string" though, do this: print strlen($_SESSION['categories']); If you get "5", then the variable might be a string with the contents being the word "Array". Pretty doubtful, but we're being thorough here. Peter > Hmph > > - Ryan > > > -Original Message- > > From: Peter Beckman [mailto:beckman@;purplecow.com] > > Sent: Tuesday, October 29, 2002 9:59 PM > > To: Ryan Neudorf > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] Session variables and arrays > > > > > > Well, can't say I see the same problem: > > > > > $_SESSION['foo'] = array("hi"=>"bye"); > > > > print_r($_SESSION['foo']); > > echo "\n\n"; > > print is_array($_SESSION['foo']); > > > > Outputs: > > X-Powered-By: PHP/4.2.2 > > Content-type: text/html > > > > Array > > ( > > [hi] => bye > > ) > > 1 > > > > Which is what I'd expect it to show. > > > > Now how did you assign categories? > > > > Maybe the var is a scalar and is actually "Array (\n [0] => > > '1';\n [1] => '12';" and you are confused.o > > > > If you are saying: > > > > $_SESSION['categories'] = "Array ( > > [0] = '1'; > > "; > > > > Then it IS a scalar. Try this: > > > > print ":::{$_SESSION['categories']}:::"; > > > > If you get this: > > > > :::Array::: > > > > Then I have no clue what the problem is > > > > If you don't get that, then we know what your problem is. > > > > Peter > > > > On Tue, 29 Oct 2002, Ryan Neudorf wrote: > > > > > I'm having a problem with session variables and arrays. > > > I'm building a multi step sign up form and I need to store all the > > > variable until the final step, when they are inputed to a > > database. I > > > thought the best way to do this would be to store the contents for > > > $HTTP_POST_VARS in session variables. This works fine for > > everything > > > except for my array of checkboxes. > > > > > > When I do a print_r($_SESSION) it displays the following for the > > > sessionvariable assigned to the checkboxes: [categories] => Array ( > > > [0] => '1'; > > > [1] => '12'; > > > ... Etc ... > > > > > > But when I run any sort of array function (is_array, foreach) on > > > $_SESSION['categories'] it appears that it is a scalar, not > > an array. > > > > > > Any ideas? > > > > > > - Ryan > > > > > > > > > -- > > > 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 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] Session variables and arrays
After a little more research I found out strlen will return 5 for a real array too, so throw that out. However, since gettype prints a string not an array, I just don't know. print_r prints the array, but you can iterate through it. Do you do this before your loop? reset($_SESSION['categories']); print_r($var) will set the pointer to the end of the array, so you have to reset it to the beginning before you iterate through it again. Maybe this is the problem? Peter On Wed, 30 Oct 2002, Ryan Neudorf wrote: > Here are the results: > > is_array(): > gettype():string > strlen():5 > > > -----Original Message- > > From: Peter Beckman [mailto:beckman@;purplecow.com] > > Sent: Wednesday, October 30, 2002 8:57 AM > > To: Ryan Neudorf > > Cc: [EMAIL PROTECTED] > > Subject: RE: [PHP-DB] Session variables and arrays > > > > > > On Wed, 30 Oct 2002, Ryan Neudorf wrote: > > > > > Ok. The categories are coming from checkboxes, e.g.: > > > > />Accountant > > /> > > > > > > Which then are handled by a $cgi class dealy and handed to the > > > $_SESSION['categories'] variable before being forwarded to the next > > > step. I was thinking that the problem might be with the > > $cgi object, > > > but when I print_r($_SESSION['categories']) it shows the > > contents of > > > the array. > > > > > > Anyways, I did the print ":::{$_SESSION['categories']}:::"; and got > > > :::Array::: > > > > Try this after that print: > > > > print is_array($_SESSION['categories']); > > > > You should get a 1 -- if you don't, try this: > > > > print gettype($_SESSION['categories']); > > > > You should get "array" but if you don't, there is something > > strange going on! If you get "string" though, do this: > > > > print strlen($_SESSION['categories']); > > > > If you get "5", then the variable might be a string with the > > contents being the word "Array". Pretty doubtful, but we're > > being thorough here. > > > > Peter > > > > > Hmph > > > > > > - Ryan > > > > > > > -Original Message- > > > > From: Peter Beckman [mailto:beckman@;purplecow.com] > > > > Sent: Tuesday, October 29, 2002 9:59 PM > > > > To: Ryan Neudorf > > > > Cc: [EMAIL PROTECTED] > > > > Subject: Re: [PHP-DB] Session variables and arrays > > > > > > > > > > > > Well, can't say I see the same problem: > > > > > > > > > > > $_SESSION['foo'] = array("hi"=>"bye"); > > > > > > > > print_r($_SESSION['foo']); > > > > echo "\n\n"; > > > > print is_array($_SESSION['foo']); > > > > > > > > Outputs: > > > > X-Powered-By: PHP/4.2.2 > > > > Content-type: text/html > > > > > > > > Array > > > > ( > > > > [hi] => bye > > > > ) > > > > 1 > > > > > > > > Which is what I'd expect it to show. > > > > > > > > Now how did you assign categories? > > > > > > > > Maybe the var is a scalar and is actually "Array (\n [0] > > => '1';\n > > > > [1] => '12';" and you are confused.o > > > > > > > > If you are saying: > > > > > > > > $_SESSION['categories'] = "Array ( > > > > [0] = '1'; > > > > "; > > > > > > > > Then it IS a scalar. Try this: > > > > > > > > print ":::{$_SESSION['categories']}:::"; > > > > > > > > If you get this: > > > > > > > > :::Array::: > > > > > > > > Then I have no clue what the problem is > > > > > > > > If you don't get that, then we know what your problem is. > > > > > > > > Peter > > > > > > > > On Tue, 29 Oct 2002, Ryan Neudorf wrote: > > > > > > > > > I'm having a problem with session variables and arrays. I'm > > > > > building a multi step sign up form and I need to store all the > > > > > variable until the final step, when th
Re: [PHP-DB] SESSIONS
Do this instead: $user = mysql_fetch_object($sql_result); $_SESSION['user'] = $user; Then, you can use stuff like: print "{$_SESSION[user]->name}"; // or if register_globals is on print "$user->name"; // which is nice because you don't have to {} the var or ".$var[name]." Peter On Fri, 1 Nov 2002, wade wrote: > How would one go about registering a session if you were to create > the session based on the users ID and NAME from the database. > > I have the users ID and NAME already being pulled from the database > and being stored in variables named $id and $name. > > I have latest version of PHP so I think I need to use the $_SESSION[] > instead of session_register. > > I am also using the session_encode function to echo out the session that > is currently being stored. What I am trying to store and what I am > actually seeing printed to the page is entirly different. > > if (mysql_num_rows($sql_result) == 1) > { > session_start(); > list($id, $name) = mysql_fetch_row($sql_result); > $SESSION_ID = $id; > $SESSION_NAME = $name; > > session_register("SESSION_ID"); > session_register("SESSION_NAME"); > header("Location:"); > } > else > { > header("Location:"); > exit; > } > > -- > Should you have any questions, comments or concerns, feel free to call > me at 318-338-2033. > > Thank you for your time, > > Wade Kelley, Design Engineer > > Bayou Internet...(888) 30-BAYOU...http://www.bayou.com > Mississippi Internet...(800) MISSISSIPPI...http://www.mississippi.net > Vicksburg Online...(800) MISSISSIPPI...http://www.vicksburg.com > ======== > > > > > -- > 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] killing cookie
try setcookie('user',''); On Fri, 1 Nov 2002, Seabird wrote: > Hi everyone, > > I don't understand why my cookie won't be removed. > > I set my cookie: > > setcookie('user',$_SESSION['username'],time()+36000); > setcookie('pass',$_SESSION['password'],time()+36000); > > I kill my cookie: > > setcookie('user','',time()-60); > setcookie('pass','',time()-60); > > but it doesn't work. why not?? > Jacco > > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > > > > -- > 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] killing cookie
You are doing it wrong then. Are you checking $_SESSION['username'] or $_COOKIE['user'] to determine if the cookie is being deleted? Or looking in your cookies.txt (or similar) file/directory to see if they still exist? What exactly is your PROOF :-) that the cookie is not deleted? Peter On Fri, 1 Nov 2002, Seabird wrote: > Nope, doesn't work. > > In PHP manual the say that the correct way is to set the cookie in a already > expired time. That's why I used time()-60 but it doesn't work... > > Anybody else? > Jacco > -- > http://seabird.jmtech.ca > > Attitude is Everything! > But Remember, Attitudes are Contagious! > Is Yours worth Catching > "Josh Johnson" <[EMAIL PROTECTED]> wrote in message > news:004101c281d3$55b80100$8b00a8c0@;manpa... > > I'm pretty sure you just have to set a cookie to an empty string to > > delete it, i.e., no expiration time > > > > -- Josh > > > > -Original Message- > > From: Seabird [mailto:jacco@;vliegt.nl] > > Sent: Friday, November 01, 2002 7:16 AM > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] killing cookie > > > > Hi everyone, > > > > I don't understand why my cookie won't be removed. > > > > I set my cookie: > > > > setcookie('user',$_SESSION['username'],time()+36000); > > setcookie('pass',$_SESSION['password'],time()+36000); > > > > I kill my cookie: > > > > setcookie('user','',time()-60); > > setcookie('pass','',time()-60); > > > > but it doesn't work. why not?? > > Jacco > > > > -- > > http://seabird.jmtech.ca > > > > Attitude is Everything! > > But Remember, Attitudes are Contagious! > > Is Yours worth Catching > > > > > > > > -- > > 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 > --- 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] LIKE statement
change your query to this: select count(distinct itemid) from business where name like 'word1 word2 word3%' or description like 'word1 word2 word3%'; Peter On 4 Nov 2002, Chris Barnes wrote: > Hi, > I've got a dilly of a problem. I'm probably doing something wrong but I > don't know what. I'm trying to use the LIKE statement in a query where > more than one word is used in with LIKE..e.g. > > select count(distinct itemid) from business where name or description > like 'word1 word2 word3%' > > The problem I'm having is probably obvious to you but I don't know why > this returns no matches but if i specify only 1 word in the LIKE > statement then it returns a match. > > Am i not able to specify more than 1 word with LIKE or am I just doing > it wrong? > > It has been designed to take input from a web form by the variable > $search_string and then the query string is constructed from that e.g. > > $query = "select count(distinct itemid) from business where name or > description like'" . $search_string . "'"; > > > Any help or suggestions greatly appreciated. > --- 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] Generating readio buttons
Gonna need some additional information, such as: 1. The first three rows your query returns 2. The expected output 3. The actual problem and/or error. Peter On Sun, 3 Nov 2002, David Jackson wrote: > Howdy -- > How do I dynamically generate the "value" for radio buttons off the DB > (MySQL) backend? Here's some code that almost works > > TIA, > David > > - Almost works > $header = mysql_query ("SELECT * FROM chart > ORDER BY acct "); > > if ($row = mysql_fetch_array($header)) { > do { > print(""); > print ' value=acct[]">'; > print(""); > print $row["acct"]; > print ""; > print $row["cat"]; > print ""; > print $row["descript"]; > print("\n"); > } while($row = mysql_fetch_array($header)); > > } else {print "Sorry, no records were found!";} > > > ?> > > > -- > 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] Generating readio buttons
Here's your problem: "acct[]" doesn't equal anything. $acct[4] might. So: echo ""; might give you want you want. The name='acct[]' is used for PHP form processing, putting the correct value in the variable. For example, $acct[Yes] might be set if you used this input and it was checked: Peter On Sun, 3 Nov 2002, David Jackson wrote: > Peter Beckman wrote: > > Peter, > Thanks for your prompt reply. > > > Gonna need some additional information, such as: > > > > 1. The first three rows your query returns > > 2. The expected output > > 3. The actual problem and/or error. > > What I'm trying todo is build a radio box form > for the selection of ledger accounts for a account app. > ( http://mustardandrelish.com/ledger) > > Query returns (from HTML table): > > > > > Expected results might be: > > > > > > And then "gl_acct" will be passed to the G/L entry screen > (sticky forms?) > > TIA, > David > > > > > > Peter > > > > On Sun, 3 Nov 2002, David Jackson wrote: > > > > > >>Howdy -- > >>How do I dynamically generate the "value" for radio buttons off the DB > >>(MySQL) backend? Here's some code that almost works > >> > >>TIA, > >>David > >> > >>- Almost works > >> >>$header = mysql_query ("SELECT * FROM chart > >>ORDER BY acct "); > >> > >>if ($row = mysql_fetch_array($header)) { > >> do { > >> print(""); > >>print ' >>value=acct[]">'; > >>print(""); > >>print $row["acct"]; > >> print ""; > >> print $row["cat"]; > >> print ""; > >>print $row["descript"]; > >>print("\n"); > >>} while($row = mysql_fetch_array($header)); > >> > >> } else {print "Sorry, no records were found!";} > >> > >> > >>?> > >> > >> > >>-- > >>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 > --- 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] Locking for data integrity
They will be queued, in my experience. Peter On Mon, 4 Nov 2002, Josh Johnson wrote: > I'm making a query to one table, and inserting it into another table > (INSERT.SELECT syntax). The table that's the source of the copy is > updated constantly, and is has a large amount of data in it. Will > locking the table for write (or read??) access keep insert queries to > the source table from executing at all, or will they be queued, and > executed after the lock is lifted? The MySQL manual wasn't clear on > this. > > I may be misunderstanding the SQL meaning of "locking" something; I want > to keep a table from being updated while I'm getting information from > it, but I still want the inserts to be executed after I'm finished with > the table. I'm running the query in a cron job daily to "compress" the > data in a log table, and keep it from growing out of control, by copying > the totals per user from the live table into a daily table, and then > deleting all of the records in the live table. If the live table is > locked and the inserts made during the lock are queued and executed > after the lock is released, it makes the whole thing a lot easier to > manage. I can empty the live table and be sure that all of the data in > the live table the following day is new data, and not worry about data > loss because of the execution time of the script (which could be as long > as 30 seconds or more, we've gotten over 17,500 unique entries in the > past 24 hours, and the site is growing). > > Thanks for your help. > > -- Josh > > > -- > 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] Re: Generating readio buttons
On Sun, 3 Nov 2002, David Jackson wrote: > OK, this works but there has to be a pretty way? > > David Operation Sticky Bun Operation Sticky Bun '; $header = mysql_query ("SELECT * FROM chart ORDER BY acct"); if (mysql_num_rows($header)>0) { while ($row = mysql_fetch_array($header)) { print "{$row['descript']}"; } } else print "Sorry, no records were found!"; print ''; ?> That looks prettier to me. 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
Re: [PHP-DB] Date and time issues
I assume you are trying to insert into a mysql table column that is a date. insert into table (datecol) values (from_unixtime($new_exp_day)); Example output of from_unixtime: +---+ | from_unixtime(10) | +---+ | 2001-09-08 21:46:40 | +---+ Peter On Mon, 4 Nov 2002, Frederik Feys wrote: > Hi all, > I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick > today's date and add XXX days to it. Its setup to validate membership > period. Now my column is of date type. Aswell, I want to pick current time > and add 1 hour to it. Here aswell, sessions expire after one hour. > Can anybody help me? > Thanks > Fred > My code: > $time = getdate(); > > $yr = $time[year]; > $mn = $time[mon]; > $dy = $time[mday]; > > if (subscr_type==1) { //these users van only work 1 hour > $exp_time=time()+3600; > $new_exp_day = getdate(); > } > else if (subscr_type==3) { //3 months subscription(here time doesn't really > matter) > $offset = 90; > } > else if (subscr_type==12) { //1 year subscriptions > > $offset = 365; > } > > $new_exp_day = strftime("%Y-%m-%d",mktime(0,0,0,$mn,$dy+$offset,$yr)); > > -- > Frederik Feys > > [EMAIL PROTECTED] > > > -- > 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] sort by date
Hey, there are a lot of new people who are starting with PHP. We all are here to help people learn how to use PHP because we are all PHP fans and want the world to use PHP. register_globals is an issue that us more advanced folk know about and deal with on a regular basis. There are lazy people who don't know how to use a manual. However, we've got the ability here to help people who don't know about or how to use the manual. And honestly, some questions are more difficult than the manual provides, especially if you aren't sure where to look. How's this? Anytime someone posts a potential answer, post the manual page for the function, SQL reference or something related. That way it's in the newsgroup and the archives. People DO search the archives, while some people don't. We can't all expect everyone to be as smart and as knowledgable about PHP as some of the people on this list are. So give them a chance and help them learn how to learn instead of getting mad. And if you get mad, maybe this isn't the right place for you to be! I mean that in the nicest sense; the world is filled with idiots, and this list is here to help both idiots and geniuses get through their stumbling blocks by being an intelligent, helpful and friendly community. At least that's what I hope this is. Peter On 6 Nov 2002, Marco Tabini wrote: > Well, excuse me for being a bit cynical, but it's hard to be > philosophical with a deadline hanging over your head. It's true that > most of the questions can be answered by looking at the manual, but you > also have to assume the possibility that the person who's asking them > has a real and immediate need for the answers--at least that's the way I > try to think. > > One thing that would be great, IMHO, would be to start putting together > a little FAQ, like many other mailing lists have, that gets updated and > posted to the list once a month... it could contain answers to the most > frequently asked questions--anybody who's tired of answering that > register_globals has been turned off in recent versions raise your hand! > :-) > > > 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! > > --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- --- Begin Message --- Agreed. we prove day in and out that the answers are only an email away...why would anyone go a different route. manual? whats a manual? There are some brilliant people on this list, but some equally intelligent people wrote some fine documentation. "Ignatius Reilly" To: "Snijders, Mark" <[EMAIL PROTECTED]>, "'Marco Tabini'" , "Terry Romine" <[EMAIL PROTECTED]> [EMAIL PROTECTED]>cc: <[EMAIL PROTECTED]> Subject: Re: [PHP-DB] sort by date 11/06/2002 10:29 AM Good point. "Tell me and I forget, show me and I remember, involve me and I understand" Ignatius - Original Message - From: "Snijders, Mark" <[EMAIL PROTECTED]> To: "'Marco Tabini'" <[EMAIL PROTECTED]>; "Terry Romine" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 4:22 PM Subject: RE: [PHP-DB] sort by date > 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 >
RE: [PHP-DB] sort by date
Besides, if they don't search the archives and newsgroups and Google already, why would we believe they'd read the FAQ? Peter On Wed, 6 Nov 2002, Hutchins, Richard wrote: > Just to weigh in on the tail end here, a FAQ of the top N items would be > nice. But I have to say, I use the archives a lot before I post to the list. > The archives contain the answers to most questions out there. If subscribers > to this list checked the archives to see if their answer is there, then > questions like register_globals might decrease in frequency. > > The other side effect of researching answers for yourself before posting is > that you gain exposure to more of the language faster. How many times do you > read about something that doesn't solve your immediate problem, but puts an > idea into your head as to how you might handle a future situation? I know I > benefit from it. > > Still, nothing better than being able to get help from some of the seasoned > pros on this list right away. > > -- > 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] sort by date
This is how you'd find it in the future. It's fairly simple. http://php.net/ --> Mailing Lists --> Databases and PHP archive link "YES" OR --> Databases and PHP Newsgroup link "Yes" Archives: http://marc.theaimsgroup.com/?l=php-db Newsgroup: news://news.php.net/php.db Peter On Wed, 6 Nov 2002, dwalker wrote: > What archive and how do I access it? ------- 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] Imploding an array?
Well, your code will do this: if delete[7] == 1, you will print_r($order_index[7]) which contains ??? Now from what you say $order_index[7] == "2627"; That's just weird. Whatever it is you are doing is bad. Regardless, you could do this: $foo = preg_split("//",$order_index[7]); Now $foo is an array of [0]=>2, [1]=>6, [2]=>2, [3]=>7; Now you do a while loop: for ($x=0;$x<=count($foo);$x++) { if (is_odd($x)) { $next = 1; } else { $next = 0; } $str .= $foo[$x]; if ($next) $str .= ","; $x++; } Or something like that. is_odd may not be a function, but YOU figure out how to determine if a number is odd. Peter On Wed, 6 Nov 2002, Aaron Wolski wrote: > Ok... > > This is the code I have setup: > > for ($i=0;$i > if ($delete[$i] == 1) { > > print_r($order_index[$i]); > > > $str = implode(",",$order_index[$i]); > echo $str; > > } > > } > > Now..upon the print_r.. The values that ARE there look like 2627 > (which is order_index 26 and 27). > > Basically I am trying to get the 2627 into a string that looks like: > $str = "26,27"; so I can use it in something else. > > *shrugs* > > I think I wma way off base here *eyes blurry* heeh > > Aaron > > > -Original Message- > > From: Rasmus Lerdorf [mailto:rasmus@;php.net] > > Sent: Wednesday, November 06, 2002 2:16 PM > > To: Aaron Wolski > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] Imploding an array? > > > > > > You sure you want [$i] on that? Is it a 2-dimensional array? > > > > On Wed, 6 Nov 2002, Aaron Wolski wrote: > > > > > Hey all, > > > > > > Can't seem to figure out why this won't work: > > > > > > $test = implode(",", $order_index[$i]); > > > > > > When I print_r() the variable I have values so I know that works. > > > > > > Any thoughts on this? > > > > > > Thanks. > > > > > > 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 > --- 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] MySQL password protection?
Create a user "nobody" with no password and give that user select, update, delete and insert capabilities in your DB and can only connect from localhost (or a certain host). This way they have to be on localhost in order to gain access to your tables, and only then be able to do what your nobody user can do. Then you need to make sure nobody can gain access to localhost without express permission (i.e. plug all security holes). Why are you showing people your source-code that has your password in it? Peter On Wed, 6 Nov 2002, William Trappeniers wrote: > Hi all > > I was wondering if it is possible to protect my password to the MySQL-server > from being in a PHP-script. Now I can't do that, so everybody who gets to > see my php-sourcecode also can see my (not protected/not encrypted) > password. > How can I change this? > > Thanks, > > William > > --- > William Trappeniers > mail at: [EMAIL PROTECTED] > > > > -- > 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] MySQL password protection?
And make sure you make sure the webserver will not SERVE that file!!! You see the source, see that you are fopening the file, I'll find it on your system and get it from the web server and I have your password! Make sure the file is NOT in the document root that the web server serves from. You could also just use the file ".htpasswd", usually by default web servers will NOT serve any file named that. However, much safer to put it somewhere that the web server cannot see (but your PHP script can). Also, this is just as insecure as the other way to any person with a login on the box your PHP script is in. Usually the script is owned by nobody:nobody or read-write all, in which case all local users can get your password. The nobody method at least keeps no password. Peter On Wed, 6 Nov 2002, Steve Cayford wrote: > You could put it anywhere. Stick it in a text file somewhere, fopen() > and read the file for the password. Or keep it in a php script outside > of the web root if that's the issue, then just include() it when you > need to. > > Of course any file you put it in will have to be readable by whatever > user the webserver is running as. > > -Steve > > On Wednesday, November 6, 2002, at 04:16 PM, 1LT John W. Holmes wrote: > > >> I was wondering if it is possible to protect my password to the > > MySQL-server > >> from being in a PHP-script. Now I can't do that, so everybody who > >> gets to > >> see my php-sourcecode also can see my (not protected/not encrypted) > >> password. > >> How can I change this? > > > > You can't, unless you want to put it in php.ini or a my.conf file... > > > > ---John Holmes... > > > > > > -- > > 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 > --- 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] Record IDs: Numeric or String??
Always use ints. Also, make sure you actually need an INT before using it: Max Value Unsigned Integer: 4.3 billion or so Unsigned MediumInt: 16.7 million unsigned SmallInt: 65,535 unsigned TinyInt: 255 If you'll only ever have 300,000 rows in a table, use a mediumint. Saves space and sorting time. I use mediumint on almost all tables for primary keys and foreign keys. Peter On Wed, 6 Nov 2002, Monty wrote: > Is it more efficient to store record IDs in a MySQL database as an Integer > or a String? I like string IDs better because you can create meaningful > names, but, not sure if this means the DB has to work harder or not. > > Thanks! > > > -- > 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] Warning - newby question -- $_GET
Make sure DNS is working and mysql.db.*.net.au resolves. Better yet, use the IP address unless absolutely necessary to use the hostname. Peter On Thu, 7 Nov 2002, Gavin Amm wrote: > Hi, > > For some reason the page worked the 1st few times, now I get the error > message (after making no changes to the code from when it worked...): > (line 5 references the "$db = mysql_co..." line of code) > > Warning: Unknown MySQL Server Host 'mysql.db.*.net.au' (2) in > /home/.../public_html/public/index2.php on line 5 > > I've got the following code at the start of my script: > (i've replaced "username" and "**" with the appropriate username & > password...) > > $db = mysql_connect("mysql.db.*.net.au", "username", "**"); > mysql_select_db("kandtsg",$db); > ... > > > cheers, > Gav > > > This e-mail and any attachments are intended solely for the named addressee, > are confidential and may contain legally privileged information. > > The copying or distribution of them or of any information they contain, by > anyone other than the addressee, is prohibited. If you received this e-mail > in error, please notify us immediately by return e-mail or telephone +61 2 > 9413 2944 and destroy the original message. Thank you. > > As Email is subject to viruses we advise that all Emails and any attachments > should be scanned by an up to-date Anti Virus programme automatically by > your system. It is the responsibility of the recipient to ensure that all > Emails and any attachments are cleared of Viruses before opening. KSG can > not accept any responsibility for viruses that maybe contained here in. > Please advise KSG by return Email if you believe any Email sent by our > system may contain a virus. It should be noted that most Anti Virus > programmes can not scan encrypted file attachments (example - documents > saved with a password). Thus extra care should be taken when opening these > files. > > Liability limited by the Accountants Scheme, approved under the Professional > Standards Act 1994 (NSW). > > > > Level 4 > 54 Neridah StreetPO Box 1290 > CHATSWOOD NSW 2067 CHATSWOOD NSW 2057 > > > Ph: +61 2 9413 2944 Fax: +61 2 9413 9901 > > -- > 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] Archiving A Database
ime. > > P.P.S. I did look through the archives before I posted, and didn't find > anything. Please flame in private if I missed something! > > > > -- > 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] FW: php J2EE .NET
Well, I know from experience this: PHP 3 and 4.various, sessions enabled on every page (using DB to store) MySQL 3.23.various Apache 1.2.various 300,000 users in the DB 2600 dynamic pages No images or static multimedia content (on this server) PC, Dual 800Mhz 1GB Ram 4 18GB drives, 7200RPM, raided 0/1 (Mirrored) FreeBSD 4.various ~150 queries per second on mysql 1,233,771 page views in 24 hours, all served without issue. Each page ~100K Averaged 424,192 page views per day. That's just my experience. It was adcritic.com at its peak. Peter On Thu, 7 Nov 2002, Peter Lovatt wrote: > Hi > > There is an article on sitepoint.com about benchmarking J2EE and .NET and > some controversy over the result > http://www.sitepoint.com/newsletters/viewissue.php?fid=3&id=3&issue=52 > > Does anybody have experience of php/MySql in comparison with either of the > above in terms of efficiency or ultimate performance? > > Is anybody interested in putting a php/MySql setup through the same > benchmarks? > > Mostly for fun, but might be useful for the 'but Open Source is not up to > Enterprise Applications' augment. > > Peter > > Mysql query blah.. > --- > Excellence in internet and open source software > --- > Sunmaia > Birmingham > UK > www.sunmaia.net > tel. 0121-242-1473 > International +44-121-242-1473 > --- > > > > > > -- > 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] addition to uploading
Yep. http://www.php.net/manual/en/function.mail.php mail("[EMAIL PROTECTED]","Subject goes Here","Body of message and all that"); Peter On Thu, 7 Nov 2002, Ryan Holowaychuk wrote: > How can I get the php page to email me after it has done and upload > successfully. > > Do I use the mail()?? > > any thoughts > > Thanks > [Ryan Holowaychuk] > > > > -- > 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] [Newbie Q] csv file upload via php to mysql tutorialrequest
1. learn how to do a file upload in PHP: http://www.php.net/manual/en/features.file-upload.php 2. Process the CSV file line by line in a loop. Not posting your CSV file format, I can only guess that it will be in proper form. If so: for loop { $csvline = '"column1","column2","column3"'; $r = mysql_query("insert into table values ($csvline)"); } This assumes the data in your CSV file is the same as your DB structure. If not, do this: $r = mysql_query("insert into table (column1,column2,column3) values ($csvline)"); Peter On Thu, 7 Nov 2002, kristina wrote: > Hello listers > > I am a complete newbie at this and I have searched for > anything that could help me understand this, but I've had > no luck. > > My reason for emailing is this - I want > to know how to > upload a csv file via php to a mysql > database. I have > found a few examples but they are all > much to advanced for > my needs. I just want the bear basics > so I can understand > it. > > I can see that phpMyAdmin does this, > which is great but I > need it for joe public to be able to > use. so I don't > want them using phpMyAdmin. > > Just a few links to some tutorials would > be marvellous. > > ;o) > > -- > tia as always > > bfn > .kristina > > [EMAIL PROTECTED] > kfxdesign.net > > > -- > 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] ROugh idea of speed
I was running a site on a dual 800 CPU, 1GB ram, dual mirrored 18GB drives, doing about 16.8GB per day on average, including PHP/HTML code. The system had several tables (~20), some regularly accessed, some not. The biggest table was a log table of about 2.5+ million rows. Ran reports from it without a problem (as long as I wasn't sorting by date!). Was able to run apache + php + mysql doing 1M page views a day, all generated based on info in the DB. Probably ran at about 150+ queries per second all day long. This was on FreeBSD, not Linux. Hopefully this gives you a bit of an idea. As for 500 million records, if they are all in one table, that's something I've never tried to do before! Peter On Fri, 8 Nov 2002, Steve Vernon wrote: > Hiya, > Just wondering what is the rough idea of speed of a server like this is > holding a database with millions of records. I know its difficult, depends > on the data stored etc. > > Its basically storing an index int and about 5 or so char field (50 > long). In total I want to store 500 million records. Accessed using PHP. > a.. 2x Intel Pentium III 1260 CPU or higher > b.. 1 GB RAM > c.. 60 GB hard drive > d.. 20 GB traffic/month > e.. RedHat LInux 7.2 > Ive read that its better to store the data in different databases on the > same server? > > Can someone please give me a rough idea of the speed and how many > servers needed, my client wants to know how much it will cost to host the > site. > > Anyone have any experience with holding a lot in MySQL? Any idea of > speed would be great. > > Thanks, > > Steve > > > -- > 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] Polls?
Use the dual table questions and answers suggestion before. Then just use a loop: $question = mysql_query("select * from questions where id={$this_question}"); while ($r = mysql_fetch_array($question)) { $answers = mysql_query("select * from answers where qid={$r[id]}"); while ($s = mysql_fetch_array($answers)) { print ""; } } On Fri, 8 Nov 2002, Leif K-Brooks wrote: > I'm working on a polling system, and I'm having a bit of a problem. I'm > not sure how to store the questions. Storing them in a seperate table > would require a query for each poll displayed - not good. I've also > thought of storing them as a serialized array. Any thoughts on this? > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt >to decrypt it will be prosecuted to the full extent of the law. > > > > -- > 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] Polls?
Well, you are gonna have to do two queries if you want a dynamic number of questions in each poll, unless you want to do something limited and have 10 to 20 columns for each poll and leave the questions not questioned null... IE: table poll pollid name descr question1 question2 question3 question4 question...20 Now this assumes that each question has the same set of potential answers, or this doesn't work. The two table polls + questions (or even three tables, polls, questions, answers) wouldn't kill your server: $x = mysql_query("select * from polls"); $y = mysql_query("select * from questions"); $z = mysql_query("select * from answers"); Then just iterate through them all, put them in an array: $polls[$row[id]] = $row_from_db; $questions[$row[id]] = $row_from_db; $answers[$row[id]] = $row_from_db; Then just relate them. while(list($pollid,$row)=each($polls)) { print $row['name']."".$row['descr'].""; reset($questions); while(list($qid,$ques)=each($questions)) { if ($ques[pid] != $pollid) continue; print "Question. ".$ques['question'].""; reset($answers); while(list($aid,$ans)=each($answers)) { if ($ques[pid] != $pollid) continue; print "{$ans['answer']}"; } } } Now you have done everything you need to display all the polls in PHP and not in the DB. I have no clue why you'd want to do it this way, but if your MySQL server is that taxed, then this is how I'd do it -- put the processing on the web server. Peter On Fri, 8 Nov 2002, Leif K-Brooks wrote: > The problem is, I need to make a page that shows all of the polls, and > one query per poll would kill the server. > > Peter Beckman wrote: > > >Use the dual table questions and answers suggestion before. > > > >Then just use a loop: > > > >$question = mysql_query("select * from questions where id={$this_question}"); > >while ($r = mysql_fetch_array($question)) { > > $answers = mysql_query("select * from answers where qid={$r[id]}"); > > while ($s = mysql_fetch_array($answers)) { > > print ""; > > } > >} > > > >On Fri, 8 Nov 2002, Leif K-Brooks wrote: > > > > > > > >>I'm working on a polling system, and I'm having a bit of a problem. I'm > >>not sure how to store the questions. Storing them in a seperate table > >>would require a query for each poll displayed - not good. I've also > >>thought of storing them as a serialized array. Any thoughts on this? > >> > >>-- > >>The above message is encrypted with double rot13 encoding. Any unauthorized >attempt to decrypt it will be prosecuted to the full extent of the law. > >> > >> > >> > >>-- > >>PHP Database Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > >> > > > >--- > >Peter Beckman Systems Engineer, Fairfax Cable Access Corporation > >[EMAIL PROTECTED] http://www.purplecow.com/ > >--- > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt >to decrypt it will be prosecuted to the full extent of the law. > > > --- 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] Email and HTML Parser Library
Hey Folks: I admit, I haven't searched for this anywhere yet, but I thought I'd ask for opinions first. I'm looking to parse an email. Some emails are HTML, some are not. What I want to do with an email is: 1. Split the headers from the body 2. Remove MIME attachments that aren't txt or html from the body 3. Grab all the HREF urls in the body as well as image SRCes (fully qualified, so if there is a "http://www.purplecow.com/hhs/ img http://purplecow.com/gfx/icons/new.gif Are there any good libraries of functions that would aid me in this effort? The idea is to store the headers in the DB, store the body in another table, and store hrefs and image URLs in another table. The URLs will be used to see if there are redirects to somewhere else and make a "parent" association. Any thoughts, pointers, urls or code would be appreciated! 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
Re: [PHP-DB] problem with postgres
Well, I don't know specifics of postgresql, but I'll give it a whirl. http://www.php.net/manual/en/function.pg-last-error.php This function should give you the error about WHY it was unable to connect. If not, check stuff like permissions, making sure pgsql.so (or whatever it is named) is actually compiled in (use phpinfo() to determine, and looks like you already confirmed that), make sure you are connecting to is resolving in DNS if not localhost, and the user can connect to the DB set. $dbconn3 = pg_connect ("host=sheep port=5432 dbname=mary user=lamb password=foo"); Also from the PHP manual site: A lot of the questions that appear here can be answered by looking at the PostgreSQL programming documentation (www.postgresql.org). PHP's PostgreSQL interface appears to be heavily based on the libpq programming interface. If you use PostgreSQL users for authenticating into your pg database rather than using your own authentication, always specify host directive in pg_connect and edit pg_hba.conf to authenticate from this host accordingly. Otherwise, PHP will connect as 'local' using UNIX domain sockets, which is set in pg_hba.conf to 'trust' by default (so you can connect using psql on console without specifying password) and everyone can connect to db _without password_ . Peter On Sun, 10 Nov 2002, Khee Wei wrote: > Hi there, > > I got this fustrating problem with postgresql & php can any one help??? > > my postgresql installation is working fine with my perl application. My php > is working fine... however, my php don't seems to be able to connect to the > postgresql. I always get the unable to connect error... anyone knows what's > wrong??? > > > I'm using postgresql 7.2.2, php 4.2 and redhat 8.0. I've added support for > pgsql and I've confirm that pqsql.so is loaded. > > Pls help > > Regards > > > > -- > 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] Winamp-Like Search
I'm sure that's possible with javascript and frames. There will be a lot of issues though, depending on the size of your MP3 list, with querying even an array or hash on every character a person types. Check out the javascript "onchange='javascriptfunction();'" in the tag. Peter On Sat, 9 Nov 2002, Nikhil Prashar wrote: > Would it be possible to create a Winamp-like search in a web-based form (the > search basically checks your list of music as you type and pulls all the > matches it finds)? > > Say you pull the results of a SQL Query and assign them to a variable. Can > you take user input and compare it to the variable for matches before the > user ever even submits the form? > > Thanks, > Nikhil > > > > -- > 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] Having more than one id in the same field
Add a third table: event table organization table responsibility table id eventID organizationID Now you can have more than one organization responsible for each event, and each organization can have one or more events. Just drop the "organizationID" from the event table, or leave it as the "Primary Organization" and everyone else is a sub organization... though that should probably be kept in the responsibility table, not the event table. Peter On Sun, 10 Nov 2002, Achilles Maroulis wrote: > > Hi. I have a database designing question to ask. > I want to build a table of events. Among the other fields there must be a > field that holds the 'responsible organization' of the event. This > organization of course will be responsible for other events as well so I > have to create another table that holds the organizations (id, name, phones, > director etc) and then just pull the organization id to the events table. > The problem is that it happens too often to have 2 organizations responsible > for the same event so I'll have to add them both to the events table in the > same record. > > How do you advice me to do that? > I thought that I could use a text field to hold the ids and then when > searching the database just change the MySQL command from > "...where events.id='$id'..." (As it would be if only one id was going to be > used) to > "...where '$id' in (events.ids)..." or maybe something using LIKE. > > Do you think it can be done this way? Apart from the responsible > organization I may have other fields in the same table having the same > problem (for example: the event visitors are staying in one hotel and I want > to hold control of the hotels as well. Maybe 2 hotels are used instead of > one). If I solve my problem this way, do you think that it will be too > difficult or 'heavy' to have more than one condition like this in my > queries? > Do you think of any other way? > > Thanx in advance > Achilles > > > -- > 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] retrieving data from mysql table
Notice that you are adding $x in the loop. You are getting a row, printing out index 0 of table_headers, incrementing $x, then moving to the next row. Basically you are fetching row 1 column 1, row 2 column 2, row 3 column 3, etc. instead of fetching all rows. Do this instead: $query = "SELECT * FROM " .$table. "" ; $result = mysql_query ( $query ) or die( mysql_error () ); while ( $row = mysql_fetch_assoc ($result)) { while(list(,$col)=each($row)) { echo "{$col}"; } } This will echo all rows, and for each row will echo all values in order of your table, which is also the order of $table_headers. Peter On Sun, 10 Nov 2002, David Rice wrote: > /* Select all the records from the table */ > $query = "SELECT * FROM " .$table. "" ; > $result = mysql_query ( $query ) or die( mysql_error () ); > $x = 0 ; > while ( $row = mysql_fetch_assoc ($result)) { > ?> > >echo $row[$table_headers[$x]] ; > ?> > >$x++ ; > } > ?> > --- 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] Performance for how many columns to update?
Straight from the MySQL Documentation, which is where you should look first always: http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimisation.html#Update_speed 5.2.10 Speed of UPDATE Queries Update queries are optimised as a SELECT query with the additional overhead of a write. The speed of the write is dependent on the size of the data that is being updated and the number of indexes that are updated. Indexes that are not changed will not be updated. Also, another way to get fast updates is to delay updates and then do many updates in a row later. Doing many updates in a row is much quicker than doing one at a time if you lock the table. Note that, with dynamic record format, updating a record to a longer total length may split the record. So if you do this often, it is very important to OPTIMIZE TABLE sometimes. See section 4.5.1 OPTIMIZE TABLE Syntax. If you aren't doing an update of 50K per row, updating 3 columns instead of 1 will be "much quicker" (quoted from the manual). If you are doing 10,000 updates, read more of the manual on the syntax of UPDATE because you can delay your updates which allows MYSQL to update the table at its leisure which offers better performance. Peter, who reminds you to always read the manual (or less kindly RTFM!). On Sun, 10 Nov 2002, Leif K-Brooks wrote: > I'm wondering how significant the performance differences between: > mysql_query("update table set col1='val1' where whatever='whatever'"); > and > mysql_query("update table set col1='val1',col2='val2',col3='val3'... > where whatever='whatever'"); > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt >to decrypt it will be prosecuted to the full extent of the law. > > > > -- > 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] Performance for how many columns to update?
Update them all. It is easier (and faster) to do that even if none of them has changed than it is to try and figure out which one changed. MySQL doesn't do anything if the row/column hasn't changed, so there is only the overhead of a connection, which is already there since you are doing the fetch/query. Being lazy actually has its benefits in this case. Doing the fetch and then testing if you should update is actually more taxing on the DB (and the server for that matter if we are talking in CPU cycles) than it would be to just do an update on all columns with a where clause on an indexed (or preferably primary keyed) column. Peter On Sun, 10 Nov 2002, Leif K-Brooks wrote: > Yes, I know that one query is more efficient than 3, but I'm trying to > do a mysql_fetch_array that automatically changes the row at the end of > the script if it has changed. I'm trying to decide whether to make it > only update the changed rows or be lazy and make it update them all if > only 1 has changed. > > Peter Beckman wrote: > > >Straight from the MySQL Documentation, which is where you should look first > >always: > > > >>http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Optimisation.html#Update_speed > > > >5.2.10 Speed of UPDATE Queries > > > >Update queries are optimised as a SELECT query with the additional > >overhead of a write. The speed of the write is dependent on the size of > >the data that is being updated and the number of indexes that are > >updated. Indexes that are not changed will not be updated. > > > >Also, another way to get fast updates is to delay updates and then do > >many updates in a row later. Doing many updates in a row is much > >quicker than doing one at a time if you lock the table. > > > >Note that, with dynamic record format, updating a record to a longer > >total length may split the record. So if you do this often, it is very > >important to OPTIMIZE TABLE sometimes. See section 4.5.1 OPTIMIZE TABLE > >Syntax. > > > >If you aren't doing an update of 50K per row, updating 3 columns instead of > >1 will be "much quicker" (quoted from the manual). If you are doing 10,000 > >updates, read more of the manual on the syntax of UPDATE because you can > >delay your updates which allows MYSQL to update the table at its leisure > >which offers better performance. > > > >Peter, who reminds you to always read the manual (or less kindly RTFM!). > > > > > >On Sun, 10 Nov 2002, Leif K-Brooks wrote: > > > > > > > >>I'm wondering how significant the performance differences between: > >>mysql_query("update table set col1='val1' where whatever='whatever'"); > >>and > >>mysql_query("update table set col1='val1',col2='val2',col3='val3'... > >>where whatever='whatever'"); > >> > >>-- > >>The above message is encrypted with double rot13 encoding. Any unauthorized >attempt to decrypt it will be prosecuted to the full extent of the law. > >> > >> > >> > >>-- > >>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/ > >--- > > > > > > > > > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt >to decrypt it will be prosecuted to the full extent of the law. > > > --- 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] Optimizing
On Sun, 10 Nov 2002, Chris Payne wrote: > Hi there everyone, > > How does indexing work, and does it speed up small / average size DB's of > around 20,000 records, with 12 columns per record? (Some columns being > paragraphs of text). YES! 20,000 records is still a lot of records, and indexing on commonly/frequently searched, non-primary-key fields (like email address, last name, or zip code for example) will definitely help speed things up. ALSO, making sure fulltext indexing is on your text fields if you are searching your paragraphs of text will significantly help the queries. When you query your fulltext columns (anything of type TEXT), use this: select match(column1) against ('myquerytext') as blah,column1,column2,column3 from table order by blah desc This will return something like this: 2.393888483| column1 contents | column2 contents | column3 contents 1.938323487| column1 contents | column2 contents | column3 contents if they match 'myquerytext'. Search mysql.com documentation for fulltext indexing. > Also, do you create an index on everything or just 1 item or or or :-) Depends. If you search on a single column almost always, then make an index on that one column. If you do "select * from table where col1='x' and col2='y'" then you'll want to create an index that includes col1 and col2. Again, read the manual on mysql.com on indexing. > I've not looked at indexing but think it's time to start, but in a way even > I can understand so I thought i'd ask you all here :-) Peter "RTFM" --- 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] Are there any Oracle vs Postgresql official benchmarks
EWeek compared MySQL to Oracle 9i and a few others, and they both came out on top. http://www.eweek.com/article2/0,3959,293,00.asp http://www.eweek.com/slideshow/0,3670,p=1&s=1590&a=23120&po=1&i=1,00.asp http://www.eweek.com/slideshow/0,3670,p=1&s=1590&a=23120&po=2&i=1,00.asp On Mon, 11 Nov 2002, Maxim Maletsky wrote: > > I can already say that Oracle is faster. But official benchmark I have > never seen. Have you wondered aboout ACID test results for both? > > > -- > Maxim Maletsky > [EMAIL PROTECTED] > > > > "Manos Papagelis" <[EMAIL PROTECTED]> wrote... : > > > Hello to all, > > > > I have searched enough to find some official benchmarks about oracle and > > postgresql but it seems that don't exist any (mostly because oracle license > > don't permit it). If someone has something in mind it would be very helpful > > to keep me informed. > > I am stressly interested about official performance benchamarks of Oracle > > 9.1 vs Postgresql 7.2.*, however any older benchmark that can give a sense > > is welcomed. > > > > thanx in advance, > > > > - Manos Papagelis > > > > > > > > -- > > 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 > --- 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] php array max value pr. year
First create this array before you do anything: $max = array(10=>1, 20=>1, 40=>1, 60=>1, 320=>1, 780=>1, 890=>1, 920=>1); $year[2002] = $max; $year[2003] = $max; $i = 0; while(list($a,$b)=each($v)) { $year[$y[$i]][$v[$i]] = 0; } reset($year); while(list($a,$b)=each($year)) { while(list($c,$d)=each($b)) { if ($d == 1) $next[$a][$c]=1; } } At this point $next will be a two dimensional array IF all the V's in a year are not used up. If they are, $next[2002] for example will be !isset($next[2002]). To get your $Y and $V: reset($next); while(list($a,$b)=each($next)) { $leftoveryears[] = $a; while(list($c,$d)=each($b)) { $leftovervalues[] = $c; } } Now $leftoveryears is an array of years and $leftovervalues is an array of values. I would highly recommend using a single multi-dimensional array instead of blind indexing for your year to value pairs. IE: $pairs[2002][10] = 1; // (if set) Peter On Mon, 11 Nov 2002, Martin Allan Jensen wrote: > Hi evryonei have a problem that i hope you can help me with. > > Here it goes! > > I have two arrays one called "y" adn one called "v" > Togeather they hold a year(Y) and a value(V) > > The array looks like this: > > v: > 10 > 20 > 40 > 60 > 320 > 780 > 890 > 920 > > y: > 2002 > 2002 > 2002 > 2002 > 2002 > 2003 > 2003 > 2003 > > - > > V represents a climping value > Y represents the year of the value > > > So the values 10, 20, 40, 60, 320 etc. grows until a new year is reachet. And then >it schould start again in the new year. > So MAXIMUM ONE VALUE PER YEAR > > How can i make it return this out of the earlier menchent array : > > (Arrays) > Y: > 2002 > 2003 > > V: > 320 > 920 > > So much thanks peoplei tried now for two days and i just can't come up with >anything... > > P.S. Sorry for my bad english! > > Martin Allan Jensen > > > -- > 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] Are there any Oracle vs Postgresql official benchmarks
So install 4.0.1 and turn on in-memory query results cache! :-) Peter On Mon, 11 Nov 2002, John W. Holmes wrote: > Interesting Quote: > > MySQL's great performance was due mostly to our use of an in-memory > query results cache that is new in MySQL 4.0.1. When we tested without > this cache, MySQL's performance fell by two-thirds. > > ---John Holmes... > > > -----Original Message- > > From: Peter Beckman [mailto:beckman@;purplecow.com] > > Sent: Monday, November 11, 2002 12:29 PM > > To: Maxim Maletsky > > Cc: Manos Papagelis; [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] Are there any Oracle vs Postgresql official > > benchmarks > > > > EWeek compared MySQL to Oracle 9i and a few others, and they both came > out > > on top. > > > > http://www.eweek.com/article2/0,3959,293,00.asp > > > http://www.eweek.com/slideshow/0,3670,p=1&s=1590&a=23120&po=1&i=1,00.asp > > > http://www.eweek.com/slideshow/0,3670,p=1&s=1590&a=23120&po=2&i=1,00.asp > > > > On Mon, 11 Nov 2002, Maxim Maletsky wrote: > > > > > > > > I can already say that Oracle is faster. But official benchmark I > have > > > never seen. Have you wondered aboout ACID test results for both? > > > > > > > > > -- > > > Maxim Maletsky > > > [EMAIL PROTECTED] > > > > > > > > > > > > "Manos Papagelis" <[EMAIL PROTECTED]> wrote... : > > > > > > > Hello to all, > > > > > > > > I have searched enough to find some official benchmarks about > oracle > > and > > > > postgresql but it seems that don't exist any (mostly because > oracle > > license > > > > don't permit it). If someone has something in mind it would be > very > > helpful > > > > to keep me informed. > > > > I am stressly interested about official performance benchamarks of > > Oracle > > > > 9.1 vs Postgresql 7.2.*, however any older benchmark that can give > a > > sense > > > > is welcomed. > > > > > > > > thanx in advance, > > > > > > > > - Manos Papagelis > > > > > > > > > > > > > > > > -- > > > > 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 > > > > > > > > > -- > > - > > 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 > --- 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] payperiods
$nextpayperiod = mktime(0,0,0,$month,$day+14,$year); $humanreadabledate = date("r",$nextpayperiod); where $month is numeric month, $day is the last payperiod day (1-31), and $year is the year of the payperiod. $nextpayperiod will equal the unix timestamp of 14 days from the last payperiod. Peter On 12 Nov 2002, Darren Bentley wrote: > Hello, > > I have build a php calendar and want to implement 2 week payperiods so > staff can enter their hours worked. Then I can summarize work done per > pay period. > > Any idea what the easiest way to do this is? I could hard code a > starting date into a database, then go up 2 weeks at a time from there. > Is there a better way? > > Thanks, > > -- > Darren Bentley / Systems Administrator > Borealis Internet / 1-800-667-0307 > Prince George, BC, Canada > http://www.pgweb.com > > > -- > 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] payperiods
Put the dates for employees into one table. In another, put the payperiods. You could populate the payperiods table for the next 90 years if you wanted if it is always on a 2 week schedule. To look at past payperiods: select start, end from payperiods where start = '$querydate'; Or just date, but you'll have to decide if the date in the payperiod table will be the start of the payperiod or end of the payperiod. IE: select date as start,date_add(date,interval 14 day) as end from payperiods where start = '$querydate'; Then get the employees who put in time between those days, assuming $pp contains the row found: select * from timesheets where date>={$pp[start]} and date<{$pp[end]}; Then you'd have all of the hours employees put in. Then just sort by employee name (add a group by) and/or sum their hours, etc. Pretty easy. Peter On 12 Nov 2002, Darren Bentley wrote: > Our payperiods will always be 2 week increments. > > So if I specify a starting day in the database I need to have that > starting day always updated to the current starting day. (when we switch > to the new payperiod), so as Jerrad mentioned I could use a cron job. > > But how would I be able to look at past payperiods? Lets say I want to > view a payperiod from September, then this method won't work. > > I'm trying to automate this so employees don't have to specify dates. > They just click the date on the calendar and enter their hours worked > per task. > > Then the accountants can go to a "summaries" page where they can click > on the staff member and view any current and past pay periods. > > This sounded easy when I first started :) > > Thanks again for the help! > > -- > Darren Bentley / Systems Administrator > Borealis Internet / 1-800-667-0307 > Prince George, BC, Canada > http://www.pgweb.com > > > -- > 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] OT... distribution under the GPL
SourceForge.net and freshmeat.net both offer Free hosting of Open-source, GPL software. SF.net also offers CVS services for keeping revisions centralized. Both offer the ability to host tarballs of your collections, scripts and other useful stuff. I know on SF.net you can create one project "Cortes-Scripts" and create multiple projects under that, allowing you to keep 30 different scripts as released projects. Peter On Tue, 12 Nov 2002, Michael Cortes wrote: > This is probably off topic..I hope someone can help. > > How do I go about distributing a php program (collection, scripts, whatever) under >the GPL? > > Thank you for any help you may give in pointing me in the right direction. > > > M.Cortes > Fort LeBoeuf School District > > ------- 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
Re: [PHP-DB] Variable from PHP to HTML...
If the last reply didn't help you, try this: Another way to write, if you aren't worried about Peter On Tue, 12 Nov 2002, NIPP, SCOTT V (SBCSI) wrote: > I am attempting to create a form of system names that is populated > from a database query. The database query is working fine, and the form > > > >$sys = $system['Name']; > if ($cnt == 1) { > $cnt = 2; > echo ""; ?> > > ------- 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] can i create an Access table or mdb with PHP?
On Tue, 12 Nov 2002, John A DAVIS wrote: > Want to give the user the ability to download a dynamic Access.mdb file > that has a table and linked report formatted for Avery 5160 labels. Know > how to create all this stuff in VBA code, but not using PHP. It is better to give too much information than not enough. You are trying to generate a dynamic Access.mdb file on the fly, using PHP? Or you are trying to deliver this already existing file that changes sometimes with PHP? Or you are trying to do something else? If the first option, where is your data coming from? If the second, why are you trying to use PHP instead of just linking to the Access.mdb file via the web server? 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
Re: [PHP-DB] Multiple Inserts with mySQL
Try this: $stack is an array of hashes: $stack[0] = array(0=>tablename, 1=>insertid()); For each insert you do, push an anonymous array on $stack which includes the tablename and insertid of the insert. Then as you continue your inserts, if any of them fail, call a function which takes that array $stack, and iterate through it, deleting the rows you just inserted. (see mysql_insert_id() function to get the insert ID) If none of them do fail, then you are in the clear. Either unset $stack or ignore it. Peter On Wed, 13 Nov 2002, Anthony wrote: > I have to drop a lot of data into mySQL from PHP. It will go into quite > a few different tables. How can I maintain integrity of the entire > insert? I need to do about a dozen inserts on four tables and I need to > insure that all the inserts are successful or that none of them get > done. I'm sort of new at this, so please help me out. Thanks. > > - Anthony > > > -- > 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] Arrays again again
The problem there is that you've got $a[$year] getting set a bunch of times. That is busted code. $a[$year] will only contain the LAST value. Replace that line with this one. $a[] = array(year=>$year, value=>$value); OR $a[$i] = array(year=>$year, value=>$value); Now $a[0][year] = 2002 Now $a[0][value] = 320 And on and on. Peter On 13 Nov 2002, Marco Tabini wrote: > Perhaps I don't understand what it is you're looking for, but... > > $a = array(); > for ($i = 0; $i < $maxvalue; $i++) > { > $a[$year] = $value; > } > > but this is almost too simple, which probably just means I didn't quite > understand your question. > > > Marco > -- > > php|architect - The magazine for PHP Professionals > The monthly worldwide magazine dedicated to PHP programmers > > Come visit us at http://www.phparch.com! > > On Wed, 2002-11-13 at 19:28, Martin Allan Jensen wrote: > > Sorry fellers > > > > Allready figured it outsorrynow i see that the question was foolish > > > > Anyway now i need help with something else... > > > > I now have some values: > > 320 - 250 - 290 - 100 > > And years that fits to them: > > 2002 - 2003 - 2004 - 2005 > > > > How can i put these dynamic values in a array. be carefull cause i need the >array to be filled active in a loop, so i CAN only define ONE year, and ONE value in >each LOOP! > > > > THANKS!!! > > > > > > -- > > 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 > --- 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] Shopping Cart Sessions - Think this is a simple prolem- hopefully
1. Are you 100% sure register_globals is turned on? 2. You session_register your variable before you change it. Replace $ShoppingCart with $_SESSION[ShoppingCart] every time you use it. This way you are modifying the session variable actually in the session, not just the one time. session_register() copies the named variable into the session space, but adding or removing items from that variable does NOT change it in the session if you use _register. If you modify $_SESSION[shoppingcart] every time, then you are actually reading/writing to the real session variable and don't have to worry about it. Peter On Thu, 14 Nov 2002, Boa Constructor wrote: > Evening all, I'm pretty stumped with this basic shopping cart I'm trying > to integrate into my site, if u wanna see what I'm on about visit > http://www.hostmaster-x.co.uk/Products.php. On my products script I've > got the following: > [...] > Of course I need a link so that I can buy a product, so I've got the following in a >loop: > echo "Buy"; > > The link works fine for each product, the problem is that the ID of the > product doesn't seem to be stored in the session and I get a whole pile > of mysql errors which don't appear in the same page when products are > displayed. The errors highlight the following code: > > while($ProductDetails = mysql_fetch_array($Q)) > { > $ProductID = $ProductDetails["ID"]; > $ProductName = $ProductDetails["ProductName"]; > $SellingPrice = $ProductDetails["SellingPrice"]; > $ProductPicture = $ProductDetails["PictureOfProduct"]; > $AmountInStock = $ProductDetails["AmountInStock"]; > $Description = $ProductDetails["ProductDescription"]; > $PictureOfProduct = $ProductDetails["PictureOfProduct"]; > } > if(mysql_num_rows($Q) > 0) > > Anyone got any ideas? I'm a bit lost as to why this doesn't work. > > G :) --- 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] Move PDFs
http://www.php.net/manual/en/function.rename.php You are just moving files on a file system from one place to another right? rename("/old/path/to/file/filename.pdf","/new/path/newfilename.pdf") or die("can't move file"); Can't remember what variable/function holds the last error for rename, otherwise I'd put it there. Peter On Thu, 14 Nov 2002, Natividad Castro wrote: > Hi to all, > I have an Access DB with a table call newchecklist. On this table I have a > field call PDF where I have many PDFs. > What I'm trying to do is to move all these PDFs into different folders. > For example, if I have a folder name VA, so my query will be: > > SELECT STATE FROM newcheklist WHERE STATE='VA'; > > Once I get these records, I would like to move these PDFs to the VA folder. > > Is there a way to do this? > > Any idea or reference how can I start this, is greatly appreciate. > > Thanks in advance > Nato > > > > -- > 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] serious help with linking data together...
Right, ok, I understand your code. What's wrong? On Thu, 14 Nov 2002, Aaron Wolski wrote: > I am creating a Search Engine Tracking Report that lists keywords and > the Search Engines used on that keyword along with the count total for > that search Engine - example: > > > Keyword Search Engine Count > Web hosting Yahoo 27 > Google 20 > MSN 12 > Web DesignOverture30 > MSN 17 > So on and so forth. > Seems simple right? But no not for me! > > $keyQuery = db_query("SELECT keyword, COUNT(keyword) as kTotal >FROM SiteTrackingTable WHERE $query GROUP BY keyword"); > while ($keyResult = db_fetch($keyQuery)) { > if (strlen($keyResult[keyword]) > 2) { > $refQuery = db_query("SELECT *, COUNT(referer) > as refTotal FROM SiteTrackingTable WHERE keyword=".$keyResult[keyword]." > GROUP BY referer ORDER BY refTotal DESC"); > $nrows = db_numrows($refQuery); > ?> > > > > > > > > >while ($refResult = db_fetch($refQuery)) { > ?> > > > > > } ?> > > > > } > } > ?> --- 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] phpmysqladmin
phpMyAdmin search for it on sourceforge.net On Fri, 15 Nov 2002, Matt Giddings wrote: > Anybody have the url for phpmysqladmin? I believe phpmysqladmin is a > web interface for mysql. I'm sure someone will correct me if I'm wrong. > : ) > > Thanks, > Matt > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.399 / Virus Database: 226 - Release Date: 10/9/2002 > > > > -- > 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] Email Encryption?
Why not encrypt the password in the DB? If they lose their password, it cannot be sent to them. They chose it, so it doesn't need to be sent to them in their email. If they lose it, it is changed, and they have to change it again. That way, only if they are stupid do they have an extra step. The passwords in the DB are encrypted, so only if someone gets a hold of the DB can the passwords be cracked by brute force. md5 would work fine for this. It is the same security that FreeBSD uses in their password file. Peter On Fri, 15 Nov 2002, Aaron Wolski wrote: > 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:jayv@;nortelnetworks.com] > 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:aaronjw@;martekbiz.com] > 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:aaronjw@;martekbiz.com] > Sent: November 15, 2002 11:36 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] Email Encryption? > > > 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 > --- 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] Email Encryption?
At the time of the account setup, you'll have the unencrypted and encrypted password. Send the email before it gets encrypted. Still, this is a little silly, since the email is unencrypted. I guess you could base64 encode the email, but that'd take an extra step. Oooh, what about this? Send an email that takes you to an https: page that only can be viewed by entering a valid code sent in another email? This https page, given the right code, will give you your username and password? The two separate emails provides a bit of obscurity, and the password is always encrypted. On the server side, if these accounts would only be accessed from certain IP blocks, you can block other requests. Peter On Fri, 15 Nov 2002, Aaron Wolski wrote: > My client is the one doing the setup of accounts. > > How would the account holder know of his password before it got > encrypted? > > Hense the email. > > Aaron > > -Original Message- > From: Peter Beckman [mailto:beckman@;purplecow.com] > Sent: November 15, 2002 12:35 PM > To: Aaron Wolski > Cc: 'Jason Vincent'; [EMAIL PROTECTED] > Subject: RE: [PHP-DB] Email Encryption? > > Why not encrypt the password in the DB? If they lose their password, it > cannot be sent to them. They chose it, so it doesn't need to be sent to > them in their email. If they lose it, it is changed, and they have to > change it again. That way, only if they are stupid do they have an > extra > step. > > The passwords in the DB are encrypted, so only if someone gets a hold of > the DB can the passwords be cracked by brute force. > > md5 would work fine for this. It is the same security that FreeBSD uses > in > their password file. > > Peter > > On Fri, 15 Nov 2002, Aaron Wolski wrote: > > > 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:jayv@;nortelnetworks.com] > > 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:aaronjw@;martekbiz.com] > > 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:aaronjw@;martekbiz.com] > > Sent: November 15, 2002 11:36 AM > > To: [EMAIL PROTECTED] > > Subject: [PHP-DB] Email Encryption? > > > > > > 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 > > > > -------- > --- > 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 > --- 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] Query Executes in MySQL Command Line, Not From PHP.
Can you post the "explain levelone" here? One thought is that 1contentID is a char or varchar instead of an int. Then again, if it were, that exact code shouldn't have worked. Are you sure you are doing the query using $sql_element_low and not something else? You may be echoing it but are you actually using the query to execute, or did you copy the mysql_query() command from another line and forget to change the var? Also, I hate ". and .", makes for messy life. Try this: $sql_element_low = "UPDATE {$table} set medialow=NULL WHERE {$_POST['tbl']}contentID={$_POST['id']}"; Also, does medialow have a unique index on it? This could cause it to fail. Or is medialow defined as NOT NULL? Peter On Fri, 15 Nov 2002, Hutchins, Richard wrote: > I'm having problems with a query. The query as it reads in my code is: > > $sql_element_low = "UPDATE $table SET medialow=NULL WHERE > ".$_POST["tbl"]."contentID=".$_POST["id"].""; > > All of the varibles get passed as expected. I know this because if I echo > the SQL out to the page, I get: > > UPDATE levelone SET medialow=NULL WHERE 1contentID=1 > > When I type the echoed SQL directly into the MySQL command line, the query > executed just fine. However, when I try to let the code execute the query, > nothing happens. No, mysql_error(), nothing. > > All of the surrounding code is found below. $sql_media fires just fine and > deletes what it is supposed to. However, when the $sql_element_low query > gets called, it'll echo out just fine, but won't execute. > > if(isset($_POST["delete"]["medialow"])){ > $sql_media = "DELETE FROM media WHERE > mediaID=".$_POST["mediaID"][0].""; > //echo $sql_media.""; > > mysql_query($sql_media) or die(mysql_error()); > > $table = tableNumToName($_POST["tbl"]); > > $sql_element_low = "UPDATE $table SET medialow=NULL WHERE > ".$_POST["tbl"]."contentID=".$_POST["id"].""; > echo $sql_element_low.""; > > mysql_query($sql_element_low) or die(mysql_error()); > } > > Any ideas? > > Thanks, > Rich > > -- > 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] database update question
you could do substring update table_name set col_name=concat(substring_index(col_name,".pdf",1),".zip") where col_name like "%.pdf" What does this do? From the man page: SUBSTRING_INDEX(str,delim,count) Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned: mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2); -> 'www.mysql' mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2); -> 'mysql.com' This function is multi-byte safe. What does it do here? mysql> select concat(substring_index("filename.pdf",".pdf",1),".zip"); +-+ | concat(substring_index("filename.pdf",".pdf",1),".zip") | +-+ | filename.zip| +-+ The ONLY problem you will have with this is if the filename is something like this: filename.pdffile.pdf This code will rename it filename.zip, not filename.pdffile.zip as expected. Peter On Fri, 15 Nov 2002, Brad Bonkoski wrote: > If you wish to update all of them, then just eliminate the id condition. > > [EMAIL PROTECTED] wrote: > > > I have a database with several hundred entries of file names that end with > > .pdf. I have converted > > all those docs to .zip, now I need to change all the entries in the > > database to .zip. I tried to use > > update table_name set col_name='%.zip' where col_name like '%.pdf' && id > > = '11' > > but of course that changed the file name for id 11 to %.zip. Is there a way > > to change all the > > entries from .pdf to .zip without writing an update statement for each > > individual row? > > > > -- > > Chip Wiegand > > Computer Services > > Simrad, Inc > > www.simradusa.com > > [EMAIL PROTECTED] > > > > "There is no reason anyone would want a computer in their home." > > --Ken Olson, president, chairman and founder of Digital Equipment > > Corporation, 1977 > > (They why do I have 8? Somebody help me!) > > > > -- > > 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 > --- 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] Passing by reference
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
Re: [PHP-DB] Need Help
A few suggestions. $show["Time"] doesn't exist; replace the 5 lines after your "while" with this: $sms_time=$show["sms_time"]; $smsc=$show["smsc"]; $org_sms=$show["org_sms"]; $dest_sms=$show["dest_sms"]; $msg_content=$show["msg_content"]; Also, so save you some formatting headaches, change your $s_sms to this: $s_sms="SELECT from_unixtime(unix_timestamp(sms_time)) as sms_time,smsc,org_sms,dest_sms,msg_content FROM dlr WHERE smsc=('Receive SMS')"; This will format your sms_time from the DB as year-month-day hour:minute:second select from_unixtime(unix_timestamp(now())); +--+ | from_unixtime(unix_timestamp(now())) | +--+ | 2002-11-17 00:11:57 | +--+ Peter On Sun, 17 Nov 2002, Afif wrote: > Dear All, > I would like to represent data from table dlr, but I could have > nothing with this script > > $s_sms="SELECT sms_time,smsc,org_sms,dest_sms,msg_content FROM dlr WHERE >smsc=('Receive SMS')"; > $result = mysql_query($s_sms); > if (!$result) error_message(sql_error()); > > //Header of Table > > echo ""; > echo "Hasil"; > echo ""; > echo ""; > echo ""; > echo "Time"; > echo "Action"; > echo "From"; > echo "Destination"; > echo "Message"; > echo ""; > > //detail of row > >while ($show = mysql_fetch_array($result)) { > $sms_time=$show["Time"]; > $smsc=$show["Action"]; > $org_sms=$show["From"]; > $dest_sms=$show["Destination"]; > $msg_content=$show["Message"]; > > Make Best Result of timestamp; > $sms_time = substr($show["Time"],0,4).'-'. > substr($show["Time"],4,2).'-'. > substr($show["Time"],6,2).'-'. > substr($show["Time"],8,2).':'. > substr($show["Time"],10,2).':'. > substr($show["Time"],12,2); > > echo ""; > echo "$sms_time "; > echo "$smsc "; > echo "$org_sms "; > echo "$dest_sms "; > echo "$msg_content "; > echo ""; >} > echo ""; > echo ""; > echo ""; > > DO I miss some thing with above script ?? > pls help me > 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 > --- 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] Inserting things into the DB
Having a little trouble doing some inserts into a db. The problem is escaping the right characters. Data integrity is important. Right now, I have taken an email and split it into $body and $header (containing the respective parts of the email) using my own parsing loop. Fairly simple, it doesn't really need to be posted. Before running dcc on it (see http://www.rhyolite.com/anti-spam/dcc/ if you want to know more), I escape the quotes: $all2 = preg_replace("/\"/","\\\"",$header."\n".$body); $cmd = 'echo "'.$all2.'" | dccproc -C'; $output = `$cmd`; That works great. Does what I want it to do, at least I think it does. The larger problem comes later -- the insert: $body = preg_replace("/\/","",$body); $body = preg_replace("/\"/","\\\"",$body); $x = db_query("insert into body (submitter,md5,fuz1,fuz2,body) values (1,'{$dcc['Body']['md5']}','{$dcc['Fuz1']['md5']}','{$dcc['Fuz2']['md5']}',\"{$body}\")"); Now this works great for a good amount of emails. I was just escaping the double quotes, but then I found a case where an email had in the actual email a backslash before the quote, so I added the first regex as well. But then I start running into problems: Syntax error: EOF in backquote substitution or Warning: No ending delimiter '/' found in /home/beckman/public_html/work/spamtracker/stlib.inc on line 45 line 45: $body = preg_replace("/\/","",$body); I truly suck at regexs, and for the life of me I haven't been able to teach them to myself. If anyone can't point me in the right direction, I think this is easily solved with a better regex than what I have. Why not just use addslashes()? addslashes will escape the single quote, and it will persist through the insert, which cannot happen (need to be able to prove the md5 hashes generated by DCC is accurate, and adding slashes in the wrong place will screw that up). What's the answer? addslashes then remove the single-quoted-slashes? Thanks for the help. 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
Re: [PHP-DB] Automatic Refresh Page
It is done in HTML usually: http://www.htmlhelp.com/";> In php. NOTE: This will only work if there is nothing else on the page. If you want to print something then push them after 10 seconds, use the meta refresh above. http://www.htmlhelp.com";); Peter On Sun, 17 Nov 2002, Afif wrote: > Dear All, > > I have a question, > how to make refresh page in certain time in php? so if my table > have new data, in the page will automatic refresh in the certain time. > does any one have sample script? would you pls share with me? > 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 > ------- 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] Sorting in numerical order, and then randomly
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] php sessions using mysql (or any db)
gt; > > > > 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 > --- 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] 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) > > > > > > >// 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 th
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! > > > $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
Re: [PHP-DB] Sessions Vs DB Access
Don't forget that you can use the DB to store PHP Sessions as well, which is faster than storing the sessions in /tmp on the file system. If you have well written SQL, you can have 5-30 queries per page, most of which should return the data in under 1/100 of a second. I was running a site doing 150 queries per second, serving 1M page views a day. That's about 13M DB queries per day at a rate of about 11-12 page views per second. All on a dual 800mhz and 1gb of memory on FreeBSD, Apache, PHP and MySQL. It can be done! Peter On Sun, 24 Nov 2002, Dave Smith wrote: > Chris, > > I'm assuming you're running this thing on *nix. > > Session variables are stored on the file system. PHP writes them out to > /tmp, where it subsequently reads them upon request. The question is: > How good at caching is your DB? If it can cache common select queries, > then you are probably better using the DB (since file system caching is > usually not that great). If your DB is busy with other things while the > file system is relatively idle, maybe it'd be better to store them in > sessions. > > The only real way to know is to benchmark both methods. You could come > up with some real quick code that implements both methods. Then, run > ApacheBench (ab) or JMeter to test the performance. Be sure that you run > the benchmark utility in such a way to use the session vars (ie, > simulate a user login). During the tests, watch things like load average > (top) and I/O activity (iostat). > > Let us know which method works best for you. Scalability issues are so cool. > > --Dave > > Chris Payne wrote: > > Hi there everyone, > > > > I have a system I am programming, and each page needs to get various config > > elements from a DB, of course this means lots of DB access for each page. > > What I was wondering is, after the user has logged in successfully it > > currently stores their email, name, address and a few other bits of data in > > a session, would it also be a good idea to store other information in a > > session at the very start when they login to ease DB access? Are there > > problems with having lots of data in a session? Well when I say lots of > > data, I mean things like font size, color, table images, background colors, > > some normal text etc nothing like an essay or anything, just about > > 30-50 different variables. > > > > Just want to make sure it won't slow my system down by doing this, or would > > it speed it up because of less DB access? > > > > Thanks for your help > > > > Regards > > > > Chris > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] PHP4, Apache 1.3.x, and mod ssl install document?
Actually, it's easier: cd /usr/ports/www/apache13-modssl make install cd /usr/ports/www/mod_php4 make install apachectl start (or restart) Peter On Wed, 27 Nov 2002, RClark wrote: > Hello all, > > I have a FreeBSD server which has been updated to 4.7 STABLE. I have updated > my ports collection and installed mysql server. Does anyone have an updated > doc on how to install apache with PHP4 and modssl support either from ports > collection or from source. I would greatly appreciate it. > > Thanks > Ron > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ----------- Peter Beckman Internet Guy [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] imap_search problems
I'm writing a command line script to go through a mailbox on the file system. PHP the binary is compiled with imap, I've confirmed by using imap_headers to get the array of the 10,051 messages and printed the array out. Here's my code: #!/usr/local/bin/php -q Here's what I get when searching for a variety of different possibilities (no results being returned in $matches): Finding 'ALL fat' (Executing imap_search(Resource id #1,'ALL fat')) Finding 'ALL "fat"' (Executing imap_search(Resource id #1,'ALL "fat"')) Finding 'BODY "fat"' (Executing imap_search(Resource id #1,'BODY "fat"')) Then I put SE_UID as the last option in imap_search: Finding 'BODY "fat"' (Executing imap_search(Resource id #1,'BODY "fat"',SE_UID)) Finding 'TO "[EMAIL PROTECTED]"' (Executing imap_search(Resource id #1,'TO "[EMAIL PROTECTED]"',SE_UID)) I get nothing in $matches ever. What is going on? Am I doing it wrong? I've read the documentation and the contributed notes and copied and pasted replacing the search strings and continue to fail. Argh. I know the word "fat" is in the body of more than 50 messages, as well as in the headers, as there are 10,051 pieces of spam I'm trying to parse. Peter --- Peter Beckman Internet Guy [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] imap_search problems
Don't you hate it when, right after you post to the list, you figure out your problem? :-) I removed the quotes around $id after using: $err = imap_errors(); print_r($err); to determine what the problem was. Anyway, Happy Thanksgiving all, happy troubleshooting and never forget to use the debugging tools the nice people at PHP gave you for Christmas. Beckman On Wed, 27 Nov 2002, Peter Beckman wrote: > I'm writing a command line script to go through a mailbox on the file > system. PHP the binary is compiled with imap, I've confirmed by using > imap_headers to get the array of the 10,051 messages and printed the array > out. > > Here's my code: > > #!/usr/local/bin/php -q > > $id = $_SERVER["argv"][1]; > > ini_set("max_execution_time","9000"); > > list($usec, $sec) = explode(" ",microtime()); > $start = ((float)$usec + (float)$sec); > > $mbox = imap_open("/home/beckman/public_html/spamtracker/a-copy-of-spam", "", >"") or die("can't open"); > > print "Finding '$id' (Executing imap_search($mbox,'$id'))\n"; > $matches = imap_search($mbox, '$id'); > print_r($matches); > > #while(list($key,$val)=each($matches)) { > # echo "$key: $val\n"; > #} > > imap_close($mbox); > ?> > > Here's what I get when searching for a variety of different possibilities (no >results being returned in $matches): > > Finding 'ALL fat' (Executing imap_search(Resource id #1,'ALL fat')) > Finding 'ALL "fat"' (Executing imap_search(Resource id #1,'ALL "fat"')) > Finding 'BODY "fat"' (Executing imap_search(Resource id #1,'BODY "fat"')) > > Then I put SE_UID as the last option in imap_search: > Finding 'BODY "fat"' (Executing imap_search(Resource id #1,'BODY "fat"',SE_UID)) > Finding 'TO "[EMAIL PROTECTED]"' (Executing imap_search(Resource id #1,'TO >"[EMAIL PROTECTED]"',SE_UID)) > > I get nothing in $matches ever. What is going on? Am I doing it wrong? > I've read the documentation and the contributed notes and copied and pasted > replacing the search strings and continue to fail. Argh. > > I know the word "fat" is in the body of more than 50 messages, as well as > in the headers, as there are 10,051 pieces of spam I'm trying to parse. > > Peter > --- > Peter Beckman Internet Guy > [EMAIL PROTECTED] http://www.purplecow.com/ > --- > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [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] Fulltext matching
Is there any way in PHP and MySQL to find out the most used words in a full text index? Is there access to the index? In the index I want to show the words that occur the most in descending order limit 50. In addition, is there any way to search for, without boolean (using 3.23.??), words in a row? I've tried searching for "print pal" (which I know exists) but only get print and pal returned as two separate words, and since pal is 3 letters or less, it isn't indexed. This doesn't work: select id, match(body) against ('"print pal"') from body where match(body) against ('"print pal"'); Peter ----------- Peter Beckman Internet Guy [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] Processing HTML forms
I have a form handler that I use that I wrote. It works great, but I have a problem. I want it to save all the values from the forms when used with PHP. For example, I have a text box that is named "data[phone][1][number]" and I want the form to be automatically filled in for me. It works for the first [] (ie data[stuff] gets filled in properly in my code). Here's the code: function displayText($name, $default = '', $size = HTML_FORM_TEXT_SIZE, $maxlength = '') { if (preg_match("/^(.*)\[+(.*)\]+$/",$name,$x)) $setvalue = $GLOBALS[$x[1]][$x[2]]; else $setvalue = $GLOBALS[$name]; $default = stripslashes((empty($setvalue))?$default:$setvalue); if (!$maxlength) { print ""; } How would I write this to support multiple brackets? Basically it is the preg_match line that does the "magic." Peter ----------- Peter Beckman Internet Guy [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] anchors
Try auction.php?clientid=1#map On Wed, 4 Dec 2002, Edward Peloke wrote: > Ok, I know this isn't really a db specific question so forgive me. In my > php/mysql page, I have a button that loops back to the same page only when > it opens the page again, I want it to go to a certain spot on the page with > certain parameters. > > For Example > > auction.php#map takes me to the map section of the page but if I loop to > that section with parameters > auction.php#map?clientid=1 nothing happens. How do I distinguish between > the end of the anchor and the start of the parameters? > > Thanks, > Eddie > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > ----------- Peter Beckman Internet Guy [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] Index on email or ID?
Something I used was this: id | username | password | cookie_string $foo = the id was rot13'ed then base64-encoded $str = the cookie_string was an md5 hash generated at the time of registration then a cookie was set: setcookie("cookie_string",$foo."|".$str); When the user returns, we checked for the cookie, and if it existed, split on the "|", de-"crypted" (haha) the ID, looked up the cookie_string in the DB and saw if it matched. If it did, it was pretty unlikely that it was "hacked" so we logged them in. Peter On Wed, 4 Dec 2002, Jim wrote: > > Always, always, always use a value that has no other significance other > > than being a unique ID. Email addresses change and so do passwords, so > > those are poor choices for linking data. They are fine and good choices > > for login, but that's about the only thing they should be used for. > > I understand what your saying, but if I just use the ID, then it makes it > extremely easy to login as another user, simply change the ID in your > cookie. Atleast if I have email/password aswell it takes someone with access > to the network and a sniffer to get the values. > > If a user changes his email and/or password, then the cookie gets updated, > simple. I can't see that its that much of an issue. If we were talking about > a credit card number or something else critical then I'd agree. > > Jim. > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php