Re: [PHP-DB] session_registered variable problem
On Monday 28 January 2002 18:42, Jason Wong wrote: $page behaves just fine : page: 2 - yup, it's incrementing, all right... nr_pages: 230 Whack! Doesn't work any more... It's starting to drive me mad. Me too. Post the full code so we can all revel in this madness! All rightey. Here it goes in it's (almost) full glory! // The nav-function that's responsible for updateing the query if($nav) { if($go==next) { if($page $nr_pages $page = 0) { $page++; $milla= (($page) * 20).,;// replace with echo millä: . $milla; // echo out debug info $mita = (($page-1) * 20).,; // replace what echo mitä: .$mita; // echo out more debug info $query=ereg_replace($mita,$milla,$query); } } if($go==prev) { if($page=1 $page = $nr_pages) { $page--; $milla = (($page) * 20).,; echo millä: . $milla; $mita = (($page+1) * 20).,; echo mitä: . $mita; $query=ereg_replace($mita,$milla,$query); } } echo query from nav(): .$query; $result=mysql_query($query,$database) or die(BEATCH,WHINE AND MOAN!); // hehe. just a debug output. print_taulukko(); } function print_taulukko() { ? FORM ACTION=page.php METHOD=POST ? //debug echo query: . $query; echo BRBR; echo page: . $page; echo BR; echo nr_pages: .$nr_pages; //endof debug while($row=mysql_fetch_row($result)) { [snip away stuff that doesn't really matter] } ? TR TD COLSPAN=5 WIDTH=50% ALIGN=CENTERINPUT ?php if($page == 0) {echo DISABLED;} ? TYPE=button VALUE=Edellinen sivu onclick=parent.location='page.php?nav=truego=prev';/TD TD COLSPAN=4 WIDTH=50% ALIGN=CENTERINPUT ?php if($page = ($nr_pages-1)) { echo DISABLED; }? TYPE=button VALUE=Seuraava sivu onclick=parent.location='page.php?nav=truego=next';/TD /TR ? } And that's basically it. There's a function responsible for reading user input and constructing the sql-query, and it places the sql in $query, stuffs it down MySQL and throws it over to print_taulukko(), and it seems to be working right, since the first result always is the correct one. It also session_registers $query. (yes, I use session_register(query), not session_register($query).) I checked the sess_whatever file step by step when testing again just to see exactly what is put in it, but it seems to be a well-behaved little textfile. Make any sense out of the code? Cheers mate, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Date operations.
Wow Garry, I know that I like to kick-start my brain by getting 'into' a list problem/challenge in the (London) mornings, but today I'm completely beaten. Thanks for the broad explanation, which is probably quite meaningful, but I'm not into breeding (could that statement be misunderstood?) and so don't understand the terminology, but let's soldier on... Can I request some db-speak please? You already have a tbl (or more). So let's start by asking for the table definitions Do you already have some SQL as a 'first attempt'? Could you also post that, together with a note about its short-comings/what needs to be added? That would also assist (my, feeble) comprehension. Usually in this sort of problem, the trick is to work out how to order/group the data, and then bearing in mind the various table-relationships, organise the join(s) and apply the requisite statistical functions. (that's the fun part) (if you haven't got anything started yet) Along with the definitions, how about starting a SELECT by listing the data you want to see, filling in the FROM clause, and then skipping to the WHERE clause and putting in the last or last-two criteria, eg the year/date-range to be used in the analysis - well do what you can/makes sense to you, so far. That might be enough to 'inspire' a solution - or start us on the way... Please advise, =dn Hi All, I have a problem working out a suitable algorithm either in PHP or MySQL. Basically I have a DB that keeps track of breeding records. Each record has a paired data, and a split-up date. I need to generate some statistics to work out average numbers of pairs per month, averaged on a daily basis, for a given start and stop date, typically a year or year-to-date. All the algorithms I can think of are messy, where I have to loop through all the breeding records for every day of the year, and count how many pairs are breeding by seeing if the date is between the start and stop dates, and then average that on a monthly basis. I can't see that scaling very well, as there might be several hundred breeding records for a given year, multiplied by 365 days. Has anyone any hints/pointers for an efficient way to do this? Regards, Garry. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] RE: ensuring unique field value in MySQL using PHP
Janet, MySQL (and indeed all multi-user databases) has a feature called Locking. What this means is that whilst many users/clients may access a database, apparently simultaneously, when one (or more) is updating the data in some way, everyone else is kept locked-out for the duration. Hopefully the period of time required is so short that other users don't particularly notice. For example, let's say we have a joint bank account. The bank db will maintain a balance figure (say 100). If I'm at one branch of the bank and ask for the balance, it will be given. If at the exact same moment in time, you are at another branch, the SAME number will also be given to you. Now let's get complicated. Having worked out that there is some money, let's say I raid the piggy-bank and ask for 75. The bank computer will say 100 less 75 leaves a balance of 25 and the teller will give me my loot. However if again, at exactly the same point in time) you try to withdraw (a more modest, caring and sharing) 50. If your teller's computer reported a balance of 100, and you got the 50, and the balance was updated to 50, what would happen? I don't know about you, but I don't often get the better of banks... Strangely enough, in database theory this is called the banker's problem. So, when two tellers ask to update an account balance, only one will be given the 'lock' - the other will be momentarily 'locked out'. MySQL is responsible for this timing/choice. (it's one of the management parts of DBMS) The other user/computer is locked out, and in certain situations can figure that out. So what happens next is that your teller does not subtract 50 from 100, but subtracts 50 from the remaining balance, eg UPDATE...SET balance = balance - 50 WHERE a/c nr=... (not SET balance = 100 - 50 ) at which point in time you get embarrassed by the teller, and I get into REALLY hot water! I have really quick reactions: at the first sign of trouble I run away! So yes it is possible that two of your clients will press 'submit' at the same moment in time, but when the processing scripts hit the database, the RDBMS will using a 'lock' to prioritise (even inventing a priority if necessary) one over the other without any intervention from you. You have nothing to worry about (until you let me operate your bank account). Incidentally the 'level' at which a lock is applied varies from DBMS to DBMS. MySQL 'only' has table-level locking. This means no one else can use a table whilst one user is updating. Depending upon transaction rates/response time requirements, the mix of transactions in the system, and the size of the table(s); this might be a problem (eg for our mythical bank). Other DBMS' allow locking right down to the row level. However locking takes time, and so imposes a speed penalty. MySQL is built for speed, doesn't pay a high 'penalty', and in this way gets away with higher level/more widely imposed locking. There is no one 'correct' answer to this conundrum despite the widespread criticism/fear (or even FUD) - everybody's mileage may vary! Does that help to clear things up? =dn - Original Message - From: Adam Royle [EMAIL PROTECTED] To: Janet Valade [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: 29 January 2002 03:49 Subject: [PHP-DB] RE: ensuring unique field value in MySQL using PHP Checking a small database for username/password combination would happen so quick, it would be nearly impossible for two usernames to be entered in. Your script should work properly, but to make sure no duplicates are entered, you can change the column definition using the ALTER columnName command to make sure there are no duplicates. Look in the mySQL documentation (www.mysql.com) to find the correct command. Adam -Original Message- From: Janet Valade [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 1:24 PM To: [EMAIL PROTECTED] Subject: ensuring unique field value in MySQL using PHP I have a form in which users create their own login name. The code for storing the login name they created does something like the following: $userlogin is the name the user typed in the form $sql = select loginname from login where loginname='$userlogin'; $result=mysql_query($sql); $num=mysql_num_rows($result); if ($num 0) { echo Sorry, that login name is already taken, Try another; shows form again; } else insert new record into database; echo okay, your new account is added; I am wondering if it is possible that two people could hit the submit button at the exact same time with the same login name so that the same login name could get entered twice? Seems unlikely that this would happen by accident, but is this something a hacker could do on purpose? Thanks, Janet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL
[PHP-DB] php db2
hi, I have a RedHat distribution installed with mysql. Now I would like also to connect to my AS400 with database DB2, via ODBC unificated functions... but these functions are not defined, probably because the PHP installed was not compiled for DB2 support. Does anyone know how to recompile PHP for DB2 (ODBC unificated), and if is the only step necessary to make the scripts able to connect to DB2? Thank, Fabio -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Session across Multiple Hosts
Dear all, I was wondering, can session variables be transfered across multiple hosts, i.e. if I send a request from http://host1/page1.phtml, to http://host2/page1.phtml where I started the session by SessionRegister() or some other way and I gave the variable VAR1 some value, then I went back with header(Location: http://host1/page2.phtml;), does the VAR1 still hold the value? if not, please advice with the way I can do this (transfere database results from one host to another without remote access). Best Regards Hayan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] session_registered variable problem
On Monday 28 January 2002 18:42, Jason Wong wrote: $page behaves just fine : [snip] page: 2 - yup, it's incrementing, all right... nr_pages: 230 Whack! Doesn't work any more... It's starting to drive me mad. Me too. Post the full code so we can all revel in this madness! Well, problem solved, sort of. It suddenly started working. Wicked. Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] session_registered variable problem
On Tuesday 29 January 2002 21:15, Markus Lervik wrote: On Monday 28 January 2002 18:42, Jason Wong wrote: $page behaves just fine : [snip] page: 2 - yup, it's incrementing, all right... nr_pages: 230 Whack! Doesn't work any more... It's starting to drive me mad. Me too. Post the full code so we can all revel in this madness! Well, problem solved, sort of. It suddenly started working. Our collective karma did the trick then? Wicked. Hehe -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* The heart is wiser than the intellect. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Date operations.
The traditional Data Warehouse way to solve this is to have a second table of dates. The table might look like: DateTable --- dayID int, myDate datetime And you add all the particular columns that you might ever want to search on, like: month int, year int, dayOfYear, int quarter int And then your table(s) only include the dayID (the integer - perhaps the date too but it's not necessary, all your searching and grouping is done by the ID). PHP offers several data functions which may or may not meet your needs but the important thing to remember is that next year the dayID must not go back to 1 - rather tomorrow will always be dayID++. So if your table looked like: Dog - name varchar(20), mom varchar(20), dad varchar(20), birthDayID int, sex char You could do a query like: Select mom, count(*) from Dog where birthDayID in (select dayID from DateTable where year = 2000) Group by mom Which would show you all the mothers who had given birth in 2000 and the number of children for each. Now notice how easy it is to change the where year = 2000 to where quarter = 2 and year = 2001 and so on... I need to generate some statistics to work out average numbers of pairs per month, averaged on a daily basis, for a given start and stop date, typically a year or year-to-date. Select month, count(*) from Dog, DateTable where birthDayID = myDate and myDate = 1/1/2000 /*start date */ and myDate 6/1/2000 /* end date */ Group by month -- this is the total per month for the first 5 months of 2000, you can figure the average from here. Change the month to quarter, dayOfYear or year or even myDate for daily totals and you're off. This set up works best where the number of records per day is high - you only need one int field in your data table (sometimes called 'fact table') and you can be as anal as you like with your DateTable - even go back and add more attributes later without messing with your fact table. The advantage is you do the work on the DateTable and then it's a simple join to your fact table. Good Luck, Frank [EMAIL PROTECTED] On 1/29/02 9:21 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: From: Garry Optland [EMAIL PROTECTED] Date: Tue, 29 Jan 2002 19:10:25 +1100 (EST) To: [EMAIL PROTECTED] Subject: Date operations. Hi All, I have a problem working out a suitable algorithm either in PHP or MySQL. Basically I have a DB that keeps track of breeding records. Each record has a paired data, and a split-up date. I need to generate some statistics to work out average numbers of pairs per month, averaged on a daily basis, for a given start and stop date, typically a year or year-to-date. All the algorithms I can think of are messy, where I have to loop through all the breeding records for every day of the year, and count how many pairs are breeding by seeing if the date is between the start and stop dates, and then average that on a monthly basis. I can't see that scaling very well, as there might be several hundred breeding records for a given year, multiplied by 365 days. Has anyone any hints/pointers for an efficient way to do this? Regards, Garry. -- Frank Flynn Poet, Artist Mystic -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] session vars between two host servers
Problem: hosts http://www.; and https://secure.; of the same domain need to work with the same browser session_id. This is a login/authenticate/redirect scenario. In this case the session data store is a common MySQL database, so the issues of /tmp sharing, NFS, etc. are set aside. My platform is Apache 1.3.22 and RH Linux 7.1. What PHP v4.1.x method of exchanging the session_id and session_name is most secure, most effective, and generally makes good soup? I've had some success with initial tests in appending '?PHPSESSID=29AE490...' to the URL and link hrefs, but that really seems ugly and unnecessary. hopefully there's a better way!? This question seems to get asked a lot in the archives but there doesn't seem to be a guideline resolution. PLEASE and THANK YOU! RF. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] arrays and email
I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: Session across Multiple Hosts
Hi Hayan Thechnically yes - for instance you could send it as a form hidden input. But I wonder whether there is sense in it. regards Ivo Hayan Al Mamoun [EMAIL PROTECTED] wrote in message 000401c1a8a9$838d4ee0$5e00a8c0@cybernation">news:000401c1a8a9$838d4ee0$5e00a8c0@cybernation... Dear all, I was wondering, can session variables be transfered across multiple hosts, i.e. if I send a request from http://host1/page1.phtml, to http://host2/page1.phtml where I started the session by SessionRegister() or some other way and I gave the variable VAR1 some value, then I went back with header(Location: http://host1/page2.phtml;), does the VAR1 still hold the value? if not, please advice with the way I can do this (transfere database results from one host to another without remote access). Best Regards Hayan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] arrays and email
Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] arrays and email
The other thing you could do is populate a string of emails and add the BCC header to your mail() function. This way everyone's email will not be seen by all other recipients. Check out the docs at www.php.net for this one a better way to build the string would probably be: while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email_list .= $row[12]; } Then just pass $email_list in the BCC - be careful as some ISP's do not allow mass mailings to be sent in BCC. [i.e. mine is limited to 99 emails and then it gets spam blocked so i must send through the mailing list feature] olinux --- Gurhan Ozen [EMAIL PROTECTED] wrote: Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Re: Session across Multiple Hosts
i did something like that once. I passed the session variables using an encrypted query string ( could be using a hidden input, anyway i think it is a good idea to encrypt the value). I didnt like it because of the unnecesary use of a second server, but i'm sure sometimes you just have to go that way hope this helps you, andrés Ivo Stoykov [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Hayan Thechnically yes - for instance you could send it as a form hidden input. But I wonder whether there is sense in it. regards Ivo Hayan Al Mamoun [EMAIL PROTECTED] wrote in message 000401c1a8a9$838d4ee0$5e00a8c0@cybernation">news:000401c1a8a9$838d4ee0$5e00a8c0@cybernation... Dear all, I was wondering, can session variables be transfered across multiple hosts, i.e. if I send a request from http://host1/page1.phtml, to http://host2/page1.phtml where I started the session by SessionRegister() or some other way and I gave the variable VAR1 some value, then I went back with header(Location: http://host1/page2.phtml;), does the VAR1 still hold the value? if not, please advice with the way I can do this (transfere database results from one host to another without remote access). Best Regards Hayan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Do persistent dba_popen connections work ?
I'm trying to use Berkeley DB db2 files with PHP persistent connection dba_popen. When I try persistent connections with dba_open then sometimes I don't get reads working I never get insert/replace working. Without persistent connections reading writing work fine. Has anyone else gotten persistent dba_popen connections working ? - Sam. - Do You Yahoo!? Yahoo! Auctions Great stuff seeking new owners! Bid now!
Re: [PHP-DB] Date operations.
On Wed, 30 Jan 2002, DL Neil wrote: Can I request some db-speak please? You already have a tbl (or more). So let's start by asking for the table definitions The table definition is as follows: CREATE TABLE breeding ( rec SMALLINT(4) UNSIGNED AUTO_INCREMENT, sire SMALLINT(4) UNSIGNED, dam SMALLINT(4) UNSIGNED, paired DATE, split DATE, num_offspring TINYINT(1) ZEROFILL, PRIMARY KEY (rec) ); Do you already have some SQL as a 'first attempt'? Could you also post that, together with a note about its short-comings/what needs to be added? That would also assist (my, feeble) comprehension. First, we define if a pair was breeding for a given date by seeing if that date lies between the paired date and the split date. In mysql: SELECT FROM breeding WHERE TO_DAYS(paired) = TO_DAYS('$given_date') AND TO_DAYS('$given_date') = TO_DAYS(split); Where it gets messy is this has to be put into a loop, between the given start and end dates (year and month only). For each day in the loop, I have to do a query and count the number returned to php. Then average that figure for the month. Normally start and end dates would be input via a form. I was wondering if anyone had done that sort of thing, or whether there was a more efficient way of doing it than stepping through the database one day at a time. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] multiple pages for large result sets
Hello, I have this query: if ($cat){ $result = mysql_query(SELECT * FROM table WHERE $cat=1,$db); if ($myrow = mysql_fetch_array($result)); { do { I use a link on the menu to call this query(a href=browse.php?cat=food) This returns a large result set that I would like to span accross multiple pages. I've gotten this off this list and used it with success on other pages: if ( ! ISSET($loc) ) { $loc=0; $next=1; } elseif( $next == 1 ) {$loc +=50;} else ($loc -= 50;} If ($loc 0 ) {$loc = 0;} with links like this(A href=\browse.php?loc=$locnext=0\Previous/A; A href=\browse.php?loc=$locnext=1\Next/A;) How could I combine these operations? Thanks in advance for the help, Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Date operations.
Garry, Could you please explain (define) in one sentence(paragraph) what end result you want. It might be possible to handle it in one SQL statement. Miles Thompson At 09:54 AM 1/30/2002 +1100, Garry Optland wrote: On Wed, 30 Jan 2002, DL Neil wrote: Can I request some db-speak please? You already have a tbl (or more). So let's start by asking for the table definitions The table definition is as follows: CREATE TABLE breeding ( rec SMALLINT(4) UNSIGNED AUTO_INCREMENT, sire SMALLINT(4) UNSIGNED, dam SMALLINT(4) UNSIGNED, paired DATE, split DATE, num_offspring TINYINT(1) ZEROFILL, PRIMARY KEY (rec) ); Do you already have some SQL as a 'first attempt'? Could you also post that, together with a note about its short-comings/what needs to be added? That would also assist (my, feeble) comprehension. First, we define if a pair was breeding for a given date by seeing if that date lies between the paired date and the split date. In mysql: SELECT FROM breeding WHERE TO_DAYS(paired) = TO_DAYS('$given_date') AND TO_DAYS('$given_date') = TO_DAYS(split); Where it gets messy is this has to be put into a loop, between the given start and end dates (year and month only). For each day in the loop, I have to do a query and count the number returned to php. Then average that figure for the month. Normally start and end dates would be input via a form. I was wondering if anyone had done that sort of thing, or whether there was a more efficient way of doing it than stepping through the database one day at a time. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Date operations.
On Thu, 31 Jan 2002, DL Neil wrote: Garry, I regret to say that I can't see an immediate answer. CREATE TABLE breeding ( rec SMALLINT(4) UNSIGNED AUTO_INCREMENT, sire SMALLINT(4) UNSIGNED, dam SMALLINT(4) UNSIGNED, paired DATE, split DATE, num_offspring TINYINT(1) ZEROFILL, PRIMARY KEY (rec) ); First, we define if a pair was breeding for a given date by seeing if that date lies between the paired date and the split date. In mysql: SELECT FROM breeding WHERE TO_DAYS(paired) = TO_DAYS('$given_date') AND TO_DAYS('$given_date') = TO_DAYS(split); There is no need to use TO_DAYS() because paired and split are both dates so you can operate on them directly. I recommend that you take a look at the manual's section on Time and Date Functions. You are right. I works without the TO_DAYS(). But I did get them from the manual :-) Where it gets messy is this has to be put into a loop, between the given start and end dates (year and month only). For each day in the loop, I have to do a query and count the number returned to php. Then average that figure for the month. So if I understand correctly, you are thinking in terms of a 'result table' which would (ideally) have the days 1-28/29/30/31 in the left-hand column, and the number of pairs who were put together on that day (paired = day/date = split). Then at the bottom you want to sum the right-hand column and divide it by the number of days in the month to give some sort of average mating possibilities per day. Does that sound right? Basically for statistical reasons I need average pairs per month, just a single number. But the months/years to be queried on would be input via a form. I was thinking of generating the data on-the-fly, but as you suggest above and from something Frank Flynn suggested, I would be better off having a separate table with monthly results. They could all be pre-calculated except the current month. Normally start and end dates would be input via a form. I don't understand, at first you talked of $given_date and now we have two dates! Are you inputting a month - asking for the average for January for example. Or are you putting in two dates representing a period of arbitrary length and asking for an average of that, eg 42 days? Please clarify. Input is two dates, granularity one month. For example start Jan 2000, finish Dec 2001. Then for each month in that period, I want the avarage for each month. For example: 2000 January 56.2 2000 February 34.4 2001 December 48.6 There will be a whole lot of other statistics as well, such as number of eggs laid, number hatched, number of surviving chicks etc. But I can calculate _them_ quite easily. If I have followed your explanation, and repeated your logic, then we would indeed need to step through the days. However this is not the 'relational way' - there may be another way to achieve the 'numbers'. Do you actually want/use the daily figures or is it only the bottom/end-of-month average that is important? End of month averages only. Trouble is it's after midnight here. Apologies. Please would you respond to the questions above, and if no one else steps in meantime, I'll endeavor to return with a more lucid analysis in the morning... Sorry to keep you awake :-) Thanks for your help, Regards, Garry. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] same connection to access two different database?
Hi everyone: is it possible to use one connect to access two database in postgreq, because i would like to use subquery to do same search. on the fly in postgreq must faster a lot than evaluate in php code... A, B belong to different database... sql : select * from A in ( select * B) Vincent Ma -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] odbc_columns()
Hi. Have a question: I've tried using the odbc_columns() function to get a list of columns in an access database connected via an ODBC System DSN.. However, I haven't had much luck in trying to use it. The manual page doesn't really cover much about it, and I noticed a few comments posted there (on www.php.net) mentioning that it was a pretty badly documented function. In any case, there were notes on how to use it with MS SQL 7, but none on just plain access databases. All I want to get is a list of field names in a table. What would the proper syntax be to do that? Any help would be appreciated. Thanks, Scotty -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] multiple pages for large result sets
On Wednesday 30 January 2002 09:48, [EMAIL PROTECTED] wrote: Hello, I have this query: if ($cat){ $result = mysql_query(SELECT * FROM table WHERE $cat=1,$db); if ($myrow = mysql_fetch_array($result)); { do { I use a link on the menu to call this query(a href=browse.php?cat=food) This returns a large result set that I would like to span accross multiple pages. I've gotten this off this list and used it with success on other pages: if ( ! ISSET($loc) ) { $loc=0; $next=1; } elseif( $next == 1 ) {$loc +=50;} else ($loc -= 50;} If ($loc 0 ) {$loc = 0;} with links like this(A href=\browse.php?loc=$locnext=0\Previous/A; A href=\browse.php?loc=$locnext=1\Next/A;) How could I combine these operations? Have you tried: a href=browse.php?loc=$locnext=1cat=foodNext/a -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* A kiss is a course of procedure, cunningly devised, for the mutual stoppage of speech at a moment when words are superfluous. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] how to reverse a hudge multidimensional array?
Well i hope someone will be able to give me a solution... Here s my problem: I'm working with a hudge mysql table (about 15 columns and 100 rows...) in fact i ve got to count the number of couples `ncompte`/`naffaire` in the table and finaly calculate the number of couples that appear once, twice here is the query i do: $result = mysql_query(SELECT count(*) FROM datas GROUP BY `ncompte`, `naffaire`); its result like something like this: count(*) naffaire ncompte 4 affaire1 compte1 4 affaire2 compte2 1 affaire3 compte3 2 affaire4 compte4 1 affaire5 compte5 (plus many more) my final result should be: $result[1] :2 $result[2] :1 $result[4] :2 I manage to do this quite easily but i use a while instruction... while($row = mysql_fetch_array($result)) { array_push($suite, $row[count(*)]); } As my table is very long the while takes a lot of time to complete... So my question is : Is there a solution to return my array as follow : 1 2 3 1 4 7 4 5 6 ===2 5 8 ??? 7 8 9 3 6 9 It would allow me to not have to use this long long while So if someone could telle me how to modify my query or what instructions to use to do that... thx Etienne -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] drop down list
I have two fields artist_id, artist. How do I put the contents of artist into a dropdown list. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] RE: drop down list
Something I have created for a project recently (note that I use my own db wrapper functions - just substitute the dbconn(), dbquery(), dbnumrows() and dbresult() for your database functions - e.g. mysql_connect() for mysql, ms_sql_connect() - look them up in the PHP manual however as I am not sure that those are completely right). This code works quite well but the current value will be repeated (it will be selected but it can also be found in the drop down -- fixes anyone?) and I have tested it quite throughly (although I can't swear its bug proof as this has only got to alpha stage in my current project). If you want further explanation of the code / an example then let me know and I will dig something out for you. $id = the field name that the id value resides in the table $name = the name field in the table, $table is the name of the SQL table $current is optional (hence is set by default to NULL) and htmlelname refers to the HTML class name that the dropdown will be given. ?php // create a drop down HTML form element from the fields and table specified function dropdownfromdb($id, $name, $table, $current = NULL, $htmlelname = select) { $sqlquery= SELECT $id, $name FROM $table; $db = dbconn(); $res = dbquery($sqlquery, $db); $j = dbnumrows($res); if($j 0) { print select name=\$htmlelname\\n; for ($i = 0; $i $j; $i++) { $val = dbresult($res, $i, 0); print option ; if ($current == $val) print selected ; print value =\$val\\n; print dbresult($res, $i, 1)./option\n; } print /select\n; } else print ERROR dropdownfromdb function failed; } ? Hope that helps, sorry if this email is a bit scrappy, very tired! Ollie P.S. Does anyone know of a better way than DIE() (or my above error message) to capture errors - eg Java / C++'s exceptions? I couldn't find any mention of exceptions in the PHP manual. -Original Message- From: B.J.Rumsey [mailto:[EMAIL PROTECTED]] Sent: 30 January 2002 06:30 To: php-db Subject: drop down list I have two fields artist_id, artist. How do I put the contents of artist into a dropdown list. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] arrays and email
It would appear that I should check if anyone else has answered a question first! And get some more sleep! Sorry! Ollie -Original Message- From: olinux [mailto:[EMAIL PROTECTED]] Sent: 29 January 2002 20:05 To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] arrays and email The other thing you could do is populate a string of emails and add the BCC header to your mail() function. This way everyone's email will not be seen by all other recipients. Check out the docs at www.php.net for this one a better way to build the string would probably be: while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email_list .= $row[12]; } Then just pass $email_list in the BCC - be careful as some ISP's do not allow mass mailings to be sent in BCC. [i.e. mine is limited to 99 emails and then it gets spam blocked so i must send through the mailing list feature] olinux --- Gurhan Ozen [EMAIL PROTECTED] wrote: Hi kevin, Seems like in your while loop, you are not populating your list array correctly with all the emails you have. Try to have a count value and populate the array list accordingly such as: $count = 0; while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[$count] = $email; $count = $count + 1; } Hope this helps. Gurhan -Original Message- From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 2:14 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] arrays and email I'm working on an application that will allow someone to view all attendees for a specific webinar that my company is hosting. I want to allow the user to send one group email to all participants scheduled for that particular webinar. After I connect to my database my code looks like this: ? $sql = select * from webusers where webdate=\$webdate\; $result = mysql_query($sql) or die(couldn't generate a list of the users); while ($row = mysql_fetch_row($result)) { $real_name = $row[1]; $email = $row[12]; $list[] = $email; } echo form method=\post\ action=\doemailattendees.php\\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0 class=\orange4\\n; echo tr\n; echo td valign=\top\pbTo:/b/p/td\n; echo td valign=\top\p\n; foreach ($list as $value) { print $value, ; $to = $value; } echo /p/td\n; echo /tr\n; echo /table\n; echo table width=\100%\ border=0 cellspacing=0 cellpadding=0\n; echo tr\n; echo td valign=\top\pbSubject:/b/p/td\n; echo td valign=\top\pinput type=\text\ name=\subject\/p/td\n; echo /tr\n; echo tr\n; echo td valign=\top\pbMessage:/b/p/td\n; echo td valign=\top\textarea name=\message\/textarea/td\n; echo /tr\n; echo tr\n; echo td colspan=2 valign=\top\input type=\submit\ value=\submit\/td\n; echo /tr\n; echo /table\n; echo /form\n; ? The $to, $subject, $message variables then get sent to a page that actually mails the message. The problem I'm having is that it's only being sent to the last person in the array. I understand why this is happening but don't know enough about arrays to find a solution. As my code shows I ambitiously tried setting $to to the entire array but that doesn't work. If anyone would be kind enough to help me out I'd greatly appreciate it. Thank you. Kevin www.worktiviti.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]