RE: [PHP] daily availability chart array
Thank you for the response. I am not quite sure how that works, can you please give an example? Thanks. Jason -Original Message- From: Marek Kilimajer [mailto:[EMAIL PROTECTED] Sent: May 27, 2003 8:13 AM To: Jason Dulberg Cc: [EMAIL PROTECTED] Subject: Re: [PHP] daily availability chart array Use weekdays' numbers instead of the short format, then you need only 2 nested loops Jason Dulberg wrote: I need to create a daily availability chart and currently am using multidimensional arrays to assign which day/timeslot is chosen. My problem is that in doing so, I have to create 7 foreach statements to go through each of the days to pick out the timeslot values. ie. avail[mon][1] (morning) avail[tues][2] (afternoon) avail[wed][4] (evening) avail[thurs][8] (night) etc. (the above data is taken from a user input form, user can choose 1 or all timeslots) I need to loop through these values for bitwise calculation and comparison to a mysql db field. The user can have multiple choices in the same day so the obtained bit values would have to be added accordingly. Is there any way to get around using 7 loops to create the bit value? Any suggestions are greatly appreciated! Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array insert help
I need to create a form where work/home address details need to be entered. I'd like to have these listed as 2 entries in the mysql db so I'm assuming I need to create an array and loop through the array to do the insert. So I have an address[1] and address[2] for example for a total of 12 address fields in each set. (6 each) My problem is that I'm not sure how to set up the array for the fields and how to take the input fields and insert them. Do I need a multidimensional array for this? ie. input type=text name=address[address][] input type=text name=address[city][] How would I decode that to create an insert statement?? Any suggestions are greatly appreciated! Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] array insert help
Thanks for your help... I tried the code as you suggested however when I attempted to echo the variables for testing but nothing showed. for($i = 0; $i = 1; ++$i) { echo paddress.$_POST['address']['address'][$i]; echo brcity.$_POST['address']['city'][$i]; } The form fields are as you suggested as well. Thanks again! Jason -Original Message- From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED] Sent: March 22, 2003 4:05 PM To: Jason Dulberg Cc: [EMAIL PROTECTED] Subject: Re: [PHP] array insert help At 20:59 22.03.2003, Jason Dulberg said: [snip] My problem is that I'm not sure how to set up the array for the fields and how to take the input fields and insert them. Do I need a multidimensional array for this? ie. input type=text name=address[address][] input type=text name=address[city][] How would I decode that to create an insert statement?? [snip] I believe your example would work. However since you have a definite number of adresses you could add the index directly, as here: bHome Address:/bbr / input type=text name=address[address][0] input type=text name=address[city][0] bWork Address:/bbr / input type=text name=address[address][1] input type=text name=address[city][1] When the form is received you will have an array for adress that looks like this: $_REQUEST['address'] = array( 'address' = array(0 = 'home address', 1 = 'work address'), 'city' = array(0 = 'home city', 1 = 'work city')); To insert the home address you'd create an SQL statement like this: for($i = 0; $i = $number_of_addresses; ++$i) { $sql = insert into address(adress, city) values ( . {$_REQUEST['address']['address'][$i]}, . {$_REQUEST['address']['city'][$i]}); // more code } Hope this helps, -- O Ernest E. Vogelsinger (\)ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update query based on array
Thanks Mike, that fixed the problem that I had! Jason -Original Message- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]] Sent: December 10, 2002 6:21 AM To: 'Jason Dulberg' Cc: [EMAIL PROTECTED] Subject: RE: [PHP] update query based on array -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: 09 December 2002 23:52 So you mean do something like: input type=text name=category[15] value=Prep School input type=text name=rank[15] value=30 size=4 input type=checkbox name=rankid[15] value=166 Doesn't that create 2 additional arrays though? Yes -- but how else are you going to get multiple values for each name from your form to your PHP script? Without the array subscripts on both category and rank, you will only ever get one category and one rank passed to your script. Using the above, just do: foreach ($_POST['rankid'] as $row, $rankid): // in here, $rankid is the value of the current rankid[] // $_POST['category'][$row] is associated category[] value // $_POST['rank'][$row] is associated rank[] value endforeach; Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] update query based on array
I am displaying a list of data (from an sql query) and some of the fields in that list are editable through a form. If the user chooses to edit one or more of the rows of data, they must click on a checkbox to add that row to an update array. The problem is that when I read that array to pass to an UPDATE sql statement, it only passes the last entry of the array. Here's an example of the data being passed: 13 - 4 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=4 14 - 169 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=169 15 - 166 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=166 The above is created based on the following html code: //the last row input type=text name=category value=Prep School input type=text name=rank value=30 size=4 input type=checkbox name=rankid[15] value=166 So as you can see, its only reading the last row and assigning its values to the data above as well. Here's what I'm using for the sql query: while(list($key,$val)=each($rankid)) { $upd=mysql_query(UPDATE ranking SET category='$category', rank='$rank' WHERE pid=$val); } If anyone has any suggestions for fixing this problem, please let me know :) THanks __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] update query based on array
So you mean do something like: input type=text name=category[15] value=Prep School input type=text name=rank[15] value=30 size=4 input type=checkbox name=rankid[15] value=166 Doesn't that create 2 additional arrays though? Basically my form is just row after row of the html code above... each row has a different ID of course. The update query should only update fields with checked checkboxes. Thanks for your input! Jason -Original Message- From: Jimmy Brake [mailto:[EMAIL PROTECTED]] Sent: December 9, 2002 6:29 PM To: Jason Dulberg Cc: [EMAIL PROTECTED] Subject: Re: [PHP] update query based on array not real sure of the setup of the form but if you have mutiple groups of items to be updated then you should make the rank an array -- rank[pid#] you should make all the items -- that are related part of the same group -- by using [] On Mon, 2002-12-09 at 15:06, Jason Dulberg wrote: I am displaying a list of data (from an sql query) and some of the fields in that list are editable through a form. If the user chooses to edit one or more of the rows of data, they must click on a checkbox to add that row to an update array. The problem is that when I read that array to pass to an UPDATE sql statement, it only passes the last entry of the array. Here's an example of the data being passed: 13 - 4 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=4 14 - 169 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=169 15 - 166 - UPDATE ranking SET category='Prep School', rank='30' WHERE pid=166 The above is created based on the following html code: //the last row input type=text name=category value=Prep School input type=text name=rank value=30 size=4 input type=checkbox name=rankid[15] value=166 So as you can see, its only reading the last row and assigning its values to the data above as well. Here's what I'm using for the sql query: while(list($key,$val)=each($rankid)) { $upd=mysql_query(UPDATE ranking SET category='$category', rank='$rank' WHERE pid=$val); } If anyone has any suggestions for fixing this problem, please let me know :) THanks __ Jason Dulberg Extreme MTB http://extreme.nas.net -- Jimmy Brake [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 1 session, 2 subdomains
I am working on a sports website that will have a subdomain for each major sport. There is a login panel on the main domain that routes users to the appropriate subdomain depending on the sport that they are in. Everything seems to be ok with cookies (cookiedomain=.domain.tld) but I can't get it to work with sessions -- even if I pass the session id in the URL. In the login script, I define the session then route to the appropriate subdomain. This where the problem lies - after redirection, the session is lost. It appears that the session is defined for the domain name that the user signs in on - if I allow users to login on their given sport subdomain, the session works ok, but this doesn't work the way I'd like. Any ideas on what I'm doing wrong? (I can post my login/session code if need be) Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 1 session, 2 subdomains
The subdomain's are all on the same server and all have their docroot set to the same directory. I'm mainly using subdomains as a way to keep the site organized and to have different graphics based on their sport location. So if I pass to the next subdomain, do I just use session_start() if the person is logged in with sessions?? Thanks for your help! Jason I'm guessing that your redirection to the appropriate subdomain actually refers to a different instance of the webserver potentially on a different machine? If so, then that's why the session is lost. Sessions are maintained on a per server basis (am I correct here?) Even so, you can redirect to a specific page in the appropriate sport tld and reconstruct/restart the session (I guess to that point you should only have a memberid after the authentication). cheers, thalis On Mon, 3 Jun 2002, Jason Dulberg wrote: I am working on a sports website that will have a subdomain for each major sport. There is a login panel on the main domain that routes users to the appropriate subdomain depending on the sport that they are in. Everything seems to be ok with cookies (cookiedomain=.domain.tld) but I can't get it to work with sessions -- even if I pass the session id in the URL. In the login script, I define the session then route to the appropriate subdomain. This where the problem lies - after redirection, the session is lost. It appears that the session is defined for the domain name that the user signs in on - if I allow users to login on their given sport subdomain, the session works ok, but this doesn't work the way I'd like. Any ideas on what I'm doing wrong? (I can post my login/session code if need be) Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 1 session, 2 subdomains
I am currently storing the session hash/login info (userid, session hash, host, etc.) in the db and send it to the next domain in the redireted URL. How would the handler work if no session info isn't being passed to the subdomain? Thanks! Jason From: Cal Evans [mailto:[EMAIL PROTECTED]] Store your session information in a database. Assign it an ID and send that ID to the cookie or the URL in the new domain. Then you can write a session handler that retrieves the session info form the database. =C= * * Cal Evans * Journeyman Programmer * Techno-Mage * http://www.calevans.com * -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 2:13 PM To: [EMAIL PROTECTED] Subject: [PHP] 1 session, 2 subdomains I am working on a sports website that will have a subdomain for each major sport. There is a login panel on the main domain that routes users to the appropriate subdomain depending on the sport that they are in. Everything seems to be ok with cookies (cookiedomain=.domain.tld) but I can't get it to work with sessions -- even if I pass the session id in the URL. In the login script, I define the session then route to the appropriate subdomain. This where the problem lies - after redirection, the session is lost. It appears that the session is defined for the domain name that the user signs in on - if I allow users to login on their given sport subdomain, the session works ok, but this doesn't work the way I'd like. Any ideas on what I'm doing wrong? (I can post my login/session code if need be) Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] 1 session, 2 subdomains
There should be session info to pass though, its just not getting through to the subdomain from the main one. The login script (on the main domain) for sessions looks like this: session_register(type,user,pass,userid,user_is_logged_in,sessid) ; then it redirects to the subdomain based on $type $redirecturl=$config[listings_dir].$config[client_dir].$type./index.php?s= .$sessid; If I don't redirect outside of the main domain, it works fine, it just breaks once it hits the new one. How would I find info about creating a session handler for this application? Jason Actually, if you are doing this then just re-login the person once they get to the new domain. Then you have the login and the session. PHP has the capability to allow you to replace the session handler. If you have to have them login in one domain and then use the info in another, building your own session handler is one way to do it. But if you have no session info to pass, why is it a problem? =C= * * Cal Evans * Journeyman Programmer * Techno-Mage * http://www.calevans.com * -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 3:08 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP] 1 session, 2 subdomains I am currently storing the session hash/login info (userid, session hash, host, etc.) in the db and send it to the next domain in the redireted URL. How would the handler work if no session info isn't being passed to the subdomain? Thanks! Jason From: Cal Evans [mailto:[EMAIL PROTECTED]] Store your session information in a database. Assign it an ID and send that ID to the cookie or the URL in the new domain. Then you can write a session handler that retrieves the session info form the database. =C= * * Cal Evans * Journeyman Programmer * Techno-Mage * http://www.calevans.com * -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, June 03, 2002 2:13 PM To: [EMAIL PROTECTED] Subject: [PHP] 1 session, 2 subdomains I am working on a sports website that will have a subdomain for each major sport. There is a login panel on the main domain that routes users to the appropriate subdomain depending on the sport that they are in. Everything seems to be ok with cookies (cookiedomain=.domain.tld) but I can't get it to work with sessions -- even if I pass the session id in the URL. In the login script, I define the session then route to the appropriate subdomain. This where the problem lies - after redirection, the session is lost. It appears that the session is defined for the domain name that the user signs in on - if I allow users to login on their given sport subdomain, the session works ok, but this doesn't work the way I'd like. Any ideas on what I'm doing wrong? (I can post my login/session code if need be) Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] save html created by loop in variable
I have a WHILE loop that I am interested in storing the html that is generated based on its results to a variable. This variable would then be echoed later on. Basically the html that is generated from the while loop is a bunch of table cell definitions and some data from the database - this data is manipulated with some IF statements in the loop. So I'd want to store something like this: while ($row=mysql_fetch_array($result)) { ? tr if ($variable==1) { //store on td?=$variable;?/td //store off } if ($variable==2) { //store on td?=$variable;?/td //store off and so on. } /tr ?php } I tried to use something like $store.=td$variable/td; for each time something needs to be displayed but it didn't display anything. Any ideas how I could create such a thing? thanks in advance! :) __ Jason Dulberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] save html created by loop in variable
Thanks for your reply... I just tried it with ob_start(); and I think I'm almost on the right track. Just one small issue. Since the records are in a while loop, the results are printed line by line as expected. However, I need to print something obtained from the sql query just once then the rest to loop. //a.agentname displays only once and h.title/h.address will be in a list SELECT h.title, h.address, a.agentname FROM homes h, agents a WHERE h.owner=a.id AND a.id=$aid Basically what I'm after is displaying something like: Agent: Fred nice house, 123 street ugly house, 643 road Thanks again for your help on this. Jason -Original Message- From: Miguel Cruz [mailto:[EMAIL PROTECTED]] Sent: April 17, 2002 8:28 PM To: Jason Dulberg Cc: [EMAIL PROTECTED] Subject: Re: [PHP] save html created by loop in variable On Wed, 17 Apr 2002, Jason Dulberg wrote: I have a WHILE loop that I am interested in storing the html that is generated based on its results to a variable. This variable would then be echoed later on. Check in the manual under Output Buffering. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get data from query before while loop
I have a mysql query that I need to echo a variable from once before I go into the while loop which would list the entire contents of the array. The field shown once will not be displayed in the while looped contents. So theoretically, something like this: $result = mysql_query(SELECT h.title, a.agentname, a.agenturl, IF(h.status='Sold',1,0) AS is_sold FROM homes h, agents a WHERE h.owner=a.id AND a.id=$aid ORDER BY is_sold ASC); if ($is_sold==1) { echo $agentname. .$agenturl; } while ($row=mysql_fetch_array($result)) { extract($row); echo $title.br; } Currently, I have everything in the while loop which prints things out more than what I'd like. Is there a way that I can get around this problem? Any suggestions are greatly appreciated thanks. :) __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Okay... I messed around with things a bit and moved the php stuff to the top as you suggested. I have part of the validation working however if more than 1 error exists, it still only prints the 1st one. Below are 2 example places where there would be an error... if I leave them both blank, they should both give an error message. $error=array(); if (strlen($username) 3) { $error['username']=Username must be more than 3 characters; } elseif (strlen($password) 3) { $error['password']=Password must be more than 3 characters; } input type=text name=username value=?=$username;? ? if ($error['username']) echo br.$error['username'];? input type=text name=password value=?=$password;? ? if ($error['password']) echo br.$error['password'];? Am I assigning errors to the array incorrectly? Thanks for your help :) Jason -Original Message- From: Jason G. [mailto:[EMAIL PROTECTED]] Sent: February 18, 2002 9:19 AM To: Matt; [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Why do not you all just put all your PHP logic, db access, etc at the TOP of the script. Once you have your results and variables created, then start into html. This method produces MUCH cleaner scripts, and there is a very minimal amount of PHP interspersed within the HTML. Also, you have time to bail out, or redirect, etc... ? Connect to DB Are we to process the form? Yes: Validate fields Generate Error Messages break; No Error Messages? Update the DB Header(Location: bla.php?NEWID=$NEWID); exit; ? html Firstname: ? if(error) echo(error message); ?br input type=text name=txtFIRSTNAME value=?= htmlspecialchars($txtFIRSTNAME); ?br br Lastname: ? if(error) echo(error message); ?br input type=text name=txtLASTNAME value=?= htmlspecialchars($txtLASTNAME); ?br br /html At 08:35 AM 2/18/2002 -0500, Matt wrote: I think that mixing of html and php is too complex and leads to hard to maintain scripts. I find it extremely difficult to understand a scripts logic when it's spread out over hundreds of lines of php/html. I use EasyTemplates that came in Web Applications Development with PHP 4.0 by Tobias Ratschiller and Till Gerkin. It looks like the source is copyrighted and you have to buy the book to get it. But it says it's based on FastTemplates. The book itself is at http://www.amazon.com/exec/obidos/ASIN/0735709971/ You can see a sample of the method here http://marc.theaimsgroup.com/?l=php-generalm=101371611609042w=2 Notice that the form action handler is the same as the original form. This is a simple example, but it does remember user input as you want. I wrote a couple of helper functions that accept db names to build select boxes and radio buttons. They return strings of the html with the selected value, and I just put them in a template container reserved for them (the {TEMPLATE_ITEM} in the sample). For tables with unknown number of rows, I have one template of the main page, one for the table container, and one for each row itself. I loop on the row, using the row template and concatenate all of the rows of html into a string. I take that string and stick it into the table template, and finally stick the table into the page template. Very smooth, easy to read, and no trouble with headers() since all output is done on the last statement. You have complete control over the script until then, and can bail out to another page, or decide to use other templates and output something else. As for errors, I build an array of the messages such as: if (!empty($thatsThere)) { $errors[] = Don't put $thatsThere in there; } if (empty($userName)) { $errors[] = Username must be supplied; } Then you can tell if all is okay, with if (is_array($errors)). If it is an array, then something is wrong, so I append the array contests into html like this: foreach($errors as $value) { $errorMsgs = $value . br\n; } and then put $errorMsgs into the page template container you've reserved for it. - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: [EMAIL PROTECTED] I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some
[PHP] form submission error trapping
I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] form submission error trapping
RE: [PHP] form submission error trappingThanks for the code Is there a way to keep track of what fields had the errors as its possible for people to have like 5 errors? Thanks again. Jason -Original Message- From: Martin Towell [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:41 PM To: '[EMAIL PROTECTED]'; Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping something like: ? // filename: here.html if ($submit) { $error = false; if (trim($email) == ) { $error = true; } // process more... if (!$error) { // do stuff here, maybe a header(location:); exit; } } ? html form action=here.html method=post input type=text name=email value=?= $email; ? input type=submit name=submit value=Go For It!!! /form /html not tested but should work - just expand on it Martin -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Monday, February 18, 2002 10:22 AM To: Steven Walker Cc: [EMAIL PROTECTED] Subject: RE: [PHP] form submission error trapping Ya, it would be cool if you could how do you submit the form to itself? Right now, I have something like if (!$submit) { display form } else { process if (trim($email)==) { echo error, hit back button to fix; } } Thanks Jason -Original Message- From: Steven Walker [mailto:[EMAIL PROTECTED]] Sent: February 17, 2002 6:18 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] form submission error trapping Jason, I just finished one of my form pages, and I'm really happy with how it turned out. I created one php page that both displays the form and validates the input. When the user hits the submit button, it submits the data to itself. If anything is missing from the page, the form is reshown with missing fields highlighted and the other fields filled in. If on the other hand the info passes the validation test, the information is shown to screen a new button (hidden form) allows the user to continue. If you want, I can send you a link to my test site so you can check it out. Steven J. Walker Walker Effects www.walkereffects.com [EMAIL PROTECTED] On Sunday, February 17, 2002, at 02:22 PM, Jason Dulberg wrote: I am working on some error trapping for several forms on my site. After visiting a bunch of websites, I've noticed 2 common methods of displaying error messages. 1. display an error box on a new page and force the user to hit the back button 2. display the form again with appropriate error text and pre-filled fields. I have part of the error on the new page working but I'm running into the infamous no contents in the form after going back. There are some useability issues with forcing the user to hit the back button -- some just don't want to bother. Is there a way to display the form w/original contents and error messages 'without' having to code the entire form twice? I have about 5 forms with 50 fields or so each. What would be the best way to go about redrawing the form with the errors shown beside each field? Any suggestions are greatly appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IF in mysql query results problem
I am working on a program that allows users to bookmark a particular item that they view. The bookmarks are stored in the database. I would like to use an IF statement in the mysql query so when the user logs in and views the items, the option to bookmark the record has been removed if they have already bookmarked it. Here's an example query: SELECT p.id AS player_id, p.name, p.hs, c.id AS coach_id, co.cid AS college, IF(co.pid=31,1,0) AS is_bookmarked FROM player p, coach c, co_bookmarks co WHERE p.id=31 AND p.hs=c.id AND co.cid=2 When I use the above query in a search, it comes up with 3 results, 1 of which is correct. If I GROUP BY p.id, there is only 1 result but its incorrect. The search should only come up with 1 correct result in this case. +---+-++--+-+---+ | player_id | name | hs | coach_id | college | is_bookmarked | +---+-++--+-+---+ | 31 | Paul Mantle | 24 | 24 | 2 | 0 | | 31 | Paul Mantle | 24 | 24 | 2 | 1 | | 31 | Paul Mantle | 24 | 24 | 2 | 0 | +---+-++--+-+---+ +---+-++--+-+---+ | player_id | name | hs | coach_id | college | is_bookmarked | +---+-++--+-+---+ | 31 | Paul Mantle | 24 | 24 | 2 | 0 | +---+-++--+-+---+ The row with is_bookmarked = 1 is the only correct one. I am assuming that for some reason, its displaying 3 results because there are 3 id's associated with cid=2. But if I group them by the id, it takes the wrong row: If anyone has any suggestions as to what I'm doing wrong, please let me know as I'm tapped out on ideas. Thanks a TON!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] IF in mysql query results problem
Thanks for your reply... I thought about making that join however in this case, the coach data is only needed for the player info. Jason. -Original Message- From: Mehmet Kamil ERISEN [mailto:[EMAIL PROTECTED]] Sent: January 7, 2002 1:41 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] IF in mysql query results problem Hi Jason, I am not too familiar with IF statements in SQL, but one thing may be the reason you see the incorrect results: You have three tables, player, coach and co_bookmarks, but you only join player and coach. Shouldn't you join coach with co_bookmarks. I hope this helps. erisen SELECT p.id AS player_id, p.name, p.hs, c.id AS coach_id, co.cid AS college, IF(co.pid=31,1,0) AS is_bookmarked FROM player p, coach c, co_bookmarks co WHERE p.id=31 AND p.hs=c.id AND co.cid=2 Jason Dulberg [EMAIL PROTECTED] wrote: I am working on a program that allows users to bookmark a particular item that they view. The bookmarks are stored in the database. I would like to use an IF statement in the mysql query so when the user logs in and views the items, the option to bookmark the record has been removed if they have already bookmarked it. Here's an example query: SELECT p.id AS player_id, p.name, p.hs, c.id AS coach_id, co.cid AS college, IF(co.pid=31,1,0) AS is_bookmarked FROM player p, coach c, co_bookmarks co WHERE p.id=31 AND p.hs=c.id AND co.cid=2 When I use the above query in a search, it comes up with 3 results, 1 of which is correct. If I GROUP BY p.id, there is only 1 result but its incorrect. The search should only come up with 1 correct result in this case. +---+-++--+-+---+ | player_id | name | hs | coach_id | college | is_bookmarked | +---+-++--+-+---+ | 31 | Paul Mantle | 24 | 24 | 2 | 0 | | 31 | Paul Mantle | 24 | 24 | 2 | 1 | | 31 | Paul Mantle | 24 | 24 | 2 | 0 | +---+-++--+-+---+ +---+-++--+-+---+ | player_id | name | hs | coach_id | college | is_bookmarked | +---+-++--+-+---+ | 31 | Paul Mantle | 24 | 24 | 2 | 0 | +---+-++--+-+---+ The row with is_bookmarked = 1 is the only correct one. I am assuming that for some reason, its displaying 3 results because there are 3 id's associated with cid=2. But if I group them by the id, it takes the wrong row: If anyone has any suggestions as to what I'm doing wrong, please let me know as I'm tapped out on ideas. Thanks a TON!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] Mehmet Erisen http://www.erisen.com -- Do You Yahoo!? Send FREE video emails in Yahoo! Mail.
RE: [PHP] php in css not working with IF's
Should I stick with if (($site_style!=10) ($site_style!=9) ($site_style!=8)) or if($site_style != ('10' or '9' or '8')) So here's what I've gathered from the various messages and my current methods: - index.php selects $site_style from the db - header.php is included by index.php (header.php has the css src for styles.php in it) - styles.php has the IF's - I need to put link rel=stylesheet src=styles.php?site_style=xxBROWSER_PLATFORM=xyz to pass the variables from the script to the css file (if possible, I need to get around this as headers are being included with the css src already in them) - do not need to use require() in styles.php Thanks to everyone for all the suggestions!! :) Jason -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: October 4, 2001 2:09 AM To: Maxim Maletsky (PHPBeginner.com) Cc: 'Jason Dulberg'; [EMAIL PROTECTED] Subject: RE: [PHP] php in css not working with IF's Ok. Wll show you with an example: if (($site_style!==10) ($site_style!==9) ($site_style!==8)) { } elseif ($site_style==10) { } Should simply be if($site_style != ('10' or '9' or '8')) {} Stop confusing the lad. That obviously won't work. -Rasmus -- PHP General 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] php in css not working with IF's
$site_style ranges from 1 - 11 $site_style 1 - 7,11 use the same css style. $site_style 8,9 use the same css $site_stylye 10 uses different css from them all. Thanks for your time. Jason -Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: October 4, 2001 2:48 AM To: Jason Dulberg; Rasmus Lerdorf Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] php in css not working with IF's On Thu, 4 Oct 2001 16:04, Jason Dulberg wrote: Should I stick with if (($site_style!=10) ($site_style!=9) ($site_style!=8)) or if($site_style != ('10' or '9' or '8')) As has been pointed out, that latter won't work. What is the range of possible values for $site_style? If it is 10 or less, then you could simply rephrase the test to if($site_style 8) or alternatively, if the range is 0 to more than 10 if( $site_style 8 || $site_style 10 ) -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Ici nous voyons le tour Eiffel! Tom parried. -- PHP General 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] php in css not working with IF's
I just want to thank everyone who helped me get the css stuff to work. All of the IF statements are now working properly --- I've certainly learned a lot from all the messages. thanks again... Maxim Maletsky Rasmus Lerdorf and all others who responded to my message! __ Jason Dulberg Extreme MTB http://extreme.nas.net I have a common css file that is being used across several virtual hosts. Basically, what I am trying to do is use the same css file even though several text colors/sizes need to be changed depending on what site/platform its being used on. -- PHP General 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] php in css not working with IF's
I have a common css file that is being used across several virtual hosts. Basically, what I am trying to do is use the same css file even though several text colors/sizes need to be changed depending on what site/platform its being used on. I have my sql query (retrieves $site_style) in the file that includes the css file and a bunch of IF statements inside the css file itself. The only problem is that the css is not being generated properly. For some reason, the IF statements are not being processed correctly/at all. I can echo the variables through the index.php and the variables are set to global. Its just that styles.php seems to almost bypass the IF and use the 1st set of variables even though it shouldn't be. Here's an example from the css (styles.php) - there are about 5 IF statements in there but here's the basic idea of them all: ?php //index.php creates platform and site style require(index.php); if (($BROWSER_PLATFORM == Win) (($site_style!==10) || ($site_style!==9))) { $pc8=8; $pc9=9; $pc10=10; $pc12=12; $pc13=13; $pc14=14; $text=#ff; $heading=#2E4471; } ? .standard { font-family:verdana, arial; font-size: ?=$pc10;?pt; color:?=$text;?; } The call from site style 10 link rel=stylesheet href=/styles.php If I go to a $site_style 10, it still uses the variables defined within the example IF statement even though it clearly shouldn't. If I type in the URL to styles.php from a $site_style 10, it shows the wrong tags. Is it a problem with my IF statements or is something else going over my head? Thanks again for any help - I've been trying to figure this out for days to no avail... __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] php in css not working with IF's
Thank you for your response. I changed my the code to the method that you suggested. Unfortunately, it still doesn't use the IF's properly. For instance, if I open a $site_style 10, the IF statement for that is the following: elseif (($BROWSER_PLATFORM == Win) ($site_style==10)) { $pc8=8; $pc9=9; $pc10=10; $pc12=12; $pc13=13; $pc14=14; $text=#D1BAC6; $link=#F8CC92; $heading=#B38B9F; } It still reads the first IF statement as I have in the original message shown below. Thanks again. Jason. if (($BROWSER_PLATFORM == Win) (($site_style!==10) || Any other problems aside, this is not how you do 'Not Equal'. $site_style!=10 is correct syntax. ($site_style!==9))) { $pc8=8; $pc9=9; $pc10=10; $pc12=12; $pc13=13; $pc14=14; $text=#ff; $heading=#2E4471; } ? -- PHP General 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] php in css not working with IF's
Theoretically, either/or I'm assuming. If A isn't 10 or A isn't 9... So I'm assumuming that my IF's are way off base? This is definitely something that'll be helpful for my other work as well. Thanks __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Sent: October 4, 2001 12:41 AM To: Jason Dulberg Cc: [EMAIL PROTECTED] Subject: Re: [PHP] php in css not working with IF's if (($BROWSER_PLATFORM == Win) (($site_style!==10) || ($site_style!==9))) { Common logic mistake. if ( A != 10 or A != 9 ) Which value of A would make that logic false? -Rasmus -- PHP General 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] php in css not working with IF's
Thanks for sticking with me here and for your examples!! So basically, I need to use AND instead of OR. if (($site_style!==10) ($site_style!==9) ($site_style!==8)) { } elseif ($site_style==10) { } hrm... it didn't work. Sorry for being such a dope about this :( Jason Ok, you are clearly not following along here... ;) You have (let $site_style = A for brevity): if( A!=10 OR A!=9 OR A!=8 ) When A=10 this becomes: if( 10!=10 OR 10!=9 OR 10!=8 ) falsetrue true if( false OR true OR true ) is the same as if (true) Seriously, try drawing the Venn diagram for your expression. Or try substituting common english. if Jason is not 21 or Jason is not 20 or Jason is no 19 let him into the cool club. Say Jason is 21, is he allowed in? Sure he is, because one of the conditions for getting into the cool club is that Jason is not 20. It doesn't matter that one of the other conditions says to not let Jason in. If the people writing the rules wanted to force all the conditions to apply they would have written: if Jason is not 21 AND Jason is not 20 AND Jason is not 19, let him into the cool club. -Rasmus -- PHP General 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] mysql query for current id-1
This is kindof a weird question so bear with me as I try to explain. I have a session table that gets updated when a user logs in/out. If they don't logout, some info is left unchanged. I have a cron script that takes care of the stray sessions so that's all good. In the sessions table, there's a field self_logout which is Y when they logout properly and N if the cron script removes their session. What I'd like to do is when the user logs in next time, a search will be made to look at that users last login session info. If they didn't log out properly, a notice will appear. So theoretically, I need to search for something like: users current id -1 or their last time of visit. Here is the sql query that I have so far. But I think that I need to remove the self_logout='N' because that doesn't show the actual last result; rather it shows the last result where they didn't properly logout. $sql=select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE (self_logout='N') AND (userid='$current_user') ORDER BY id DESC LIMIT 1,1; Here is my trimmed down table structure: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in timestamp(14), time_out varchar(50) DEFAULT '-' NOT NULL, self_logout char(1) DEFAULT 'N' NOT NULL, KEY id (id) ); Did that make any sense? To sum it all up, I just want to remind people to click logout if they forgot the last time. Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] mysql query for current id-1
Thank you for your lightning fast response!! I tried your query but it appears to be coming up with the current id rather than the users last login. __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Maxim Maletsky (PHPBeginner.com) [mailto:[EMAIL PROTECTED]] Sent: October 2, 2001 12:14 AM To: 'Jason Dulberg'; [EMAIL PROTECTED] Subject: RE: [PHP] mysql query for current id-1 What about this: $sql=select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE userid='$current_user' ORDER BY id DESC LIMIT 1; I think this should work for your case. Maxim Maletsky www.PHPBeginner.com -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: martedì 2 ottobre 2001 6.04 To: [EMAIL PROTECTED] Subject: [PHP] mysql query for current id-1 This is kindof a weird question so bear with me as I try to explain. I have a session table that gets updated when a user logs in/out. If they don't logout, some info is left unchanged. I have a cron script that takes care of the stray sessions so that's all good. In the sessions table, there's a field self_logout which is Y when they logout properly and N if the cron script removes their session. What I'd like to do is when the user logs in next time, a search will be made to look at that users last login session info. If they didn't log out properly, a notice will appear. So theoretically, I need to search for something like: users current id -1 or their last time of visit. Here is the sql query that I have so far. But I think that I need to remove the self_logout='N' because that doesn't show the actual last result; rather it shows the last result where they didn't properly logout. $sql=select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE (self_logout='N') AND (userid='$current_user') ORDER BY id DESC LIMIT 1,1; Here is my trimmed down table structure: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in timestamp(14), time_out varchar(50) DEFAULT '-' NOT NULL, self_logout char(1) DEFAULT 'N' NOT NULL, KEY id (id) ); Did that make any sense? To sum it all up, I just want to remind people to click logout if they forgot the last time. Thanks for any suggestions!! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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 General 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] mysql query for current id-1
Awesome... Works perfectly!! Thanks for your help! __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Maxim Maletsky (PHPBeginner.com) [mailto:[EMAIL PROTECTED]] Sent: October 2, 2001 1:03 AM To: 'Jason Dulberg'; [EMAIL PROTECTED] Subject: RE: [PHP] mysql query for current id-1 ... DESC LIMIT 1,1 As you wrote yourself. Sorry, haven't taken in consideration ;-) Maxim Maletsky www.PHPBeginner.com -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: martedì 2 ottobre 2001 6.59 To: Maxim Maletsky (PHPBeginner.com); [EMAIL PROTECTED] Subject: RE: [PHP] mysql query for current id-1 Thank you for your lightning fast response!! I tried your query but it appears to be coming up with the current id rather than the users last login. __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Maxim Maletsky (PHPBeginner.com) [mailto:[EMAIL PROTECTED]] Sent: October 2, 2001 12:14 AM To: 'Jason Dulberg'; [EMAIL PROTECTED] Subject: RE: [PHP] mysql query for current id-1 What about this: $sql=select id,agent,host, DATE_FORMAT(time_in, '%M %d, %Y, %l:%i') AS unixdate from logged_in WHERE userid='$current_user' ORDER BY id DESC LIMIT 1; I think this should work for your case. Maxim Maletsky www.PHPBeginner.com -- PHP General 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] select based on time/date
You were right! I changed it to a timestamp (14) and the selection is working great now. Only problem is that when I logout which UPDATE's the table to clear the $session field, the $time_in timestamp gets updated because of the NOW() function. I need that date to stay the same when someone logs out. current logout.php: $out = UPDATE logged_in SET session='' WHERE (logged_in.userid='$aid') AND (logged_in.session='$sessid'); Is there a way to only allow the NOW() to work when a row is added to the table? Or perhaps another way Thank you again for your time. I've learned alot from this. __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Sheridan Saint-Michel [mailto:[EMAIL PROTECTED]] Sent: September 26, 2001 9:38 AM To: Jason Dulberg; [EMAIL PROTECTED] Subject: Re: [PHP] select based on time/date The reason my query didn't work is you have time_in as a varchar. Change it to a datetime field or timestamp field and it should work. I would suggest making it a timestamp field. That way whenever you update the row (probably update the session field with a new session) MySQL will automatically set time_in to Now(). This will avoid a lot of headache for you =) Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: Sheridan Saint-Michel [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, September 25, 2001 5:08 PM Subject: RE: [PHP] select based on time/date I tried basically what you have but I got an error: $sql=select * from logged_in where time_in + interval 1 hour = now(); $result = mysql_query($sql); If it will help, here's the table structure -- looks like my structure is bit different from what I orignally posted: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in varchar(50) NOT NULL, KEY id (id) ); Thanks again. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] select based on time/date
Awesome... Its all working perfectly now! Makes perfect sense why the update is like that. thanks again! __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Sheridan Saint-Michel [mailto:[EMAIL PROTECTED]] Sent: September 26, 2001 1:59 PM To: Jason Dulberg; [EMAIL PROTECTED] Subject: Re: [PHP] select based on time/date Timestamp only sets itself to Now() if it isn't explicitly set (or set to NULL). So try this: $out = UPDATE logged_in SET session='',time_in=time_in WHERE (logged_in.userid='$aid') AND (logged_in.session='$sessid'); Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: Sheridan Saint-Michel [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 12:44 PM Subject: RE: [PHP] select based on time/date You were right! I changed it to a timestamp (14) and the selection is working great now. Only problem is that when I logout which UPDATE's the table to clear the $session field, the $time_in timestamp gets updated because of the NOW() function. I need that date to stay the same when someone logs out. current logout.php: $out = UPDATE logged_in SET session='' WHERE (logged_in.userid='$aid') AND (logged_in.session='$sessid'); Is there a way to only allow the NOW() to work when a row is added to the table? Or perhaps another way Thank you again for your time. I've learned alot from this. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] select based on time/date
I had a look at the DATE_FORMAT info on the mysql doc page and its a bit easier to understand than the CONCATS. Would I want to use the CURTIME() function since I would want to select sessions based on the hour? How would I go about combining CURTIME with the rest of my query? Theoretically, here is what I understand, please let me know whether or not I am correct: select * from sessions where (CURTIME() - EXTRACT(MINUTE FROM $timein) = 60); //where 60 is the lifespan of the session Thanks for your suggestions and time! __ Jason Dulberg Extreme MTB http://extreme.nas.net And, as someone recently pointed out in response to a similar suggestion I made, there is a mysql DATE_FORMAT function that will do the same thing without the CONCATS. -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: martedì 25 settembre 2001 5.47 To: [EMAIL PROTECTED] Subject: [PHP] select based on time/date I am using sessions on my site and have noticed that people often don't click the logout button -- something which I need them to do in order to clear their session from the db and update some site stats. In the sessions table, I have a field $timein (in format F j, Y, g:i a) that gets added when the user logs in and a $timeout field that gets added when they hit logout. Basically, what I've been thinking of doing is using cron to run a php script every hour or so that will search the table for sessions with no $timeout field and $timein is more than X number of minutes old. My problem is that since I'm using the F j, Y, g:i a date/time format, how would I make the mysql select? Do I have to explode the $timein field? Any suggestions are appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] select based on time/date
I tried basically what you have but I got an error: $sql=select * from logged_in where time_in + interval 1 hour = now(); $result = mysql_query($sql); If it will help, here's the table structure -- looks like my structure is bit different from what I orignally posted: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in varchar(50) NOT NULL, KEY id (id) ); Thanks again. __ Jason Dulberg Extreme MTB http://extreme.nas.net The problem with this is curtime returns a number in HHMMSS format and your extract returns MM so you get HHMMSS - MM which is always going to be greater than 60 unless you are running your script in the first minute of the day (ie 37 - 49). Try this instead: select * from sessions where $timein + interval 1 hour = now(); - Original Message - From: Jason Dulberg [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, September 25, 2001 2:35 PM Subject: RE: [PHP] select based on time/date I had a look at the DATE_FORMAT info on the mysql doc page and its a bit easier to understand than the CONCATS. Would I want to use the CURTIME() function since I would want to select sessions based on the hour? How would I go about combining CURTIME with the rest of my query? Theoretically, here is what I understand, please let me know whether or not I am correct: select * from sessions where (CURTIME() - EXTRACT(MINUTE FROM $timein) = 60); //where 60 is the lifespan of the session -- PHP General 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] select based on time/date
I plugged your query in and it didn't result in an error - however, it came up with no results even though there should be. This one should have come up but didn't: INSERT INTO logged_in VALUES ( '5', 'b406e68a7cde49534a14f5fd8848006e', 'September 24, 2001, 3:27 pm', ''); -- the fields correspond to the table structure quoted below Thanks again! __ Jason Dulberg Extreme MTB http://extreme.nas.net -Original Message- From: Jack Dempsey [mailto:[EMAIL PROTECTED]] Sent: September 25, 2001 7:07 PM To: 'Jason Dulberg'; 'Sheridan Saint-Michel'; [EMAIL PROTECTED] Subject: RE: [PHP] select based on time/date select * from logged_in where date_add(time_in,interval 1 hour) = now() -jack -Original Message- From: Jason Dulberg [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 25, 2001 6:08 PM To: Sheridan Saint-Michel; [EMAIL PROTECTED] Subject: RE: [PHP] select based on time/date I tried basically what you have but I got an error: $sql=select * from logged_in where time_in + interval 1 hour = now(); $result = mysql_query($sql); If it will help, here's the table structure -- looks like my structure is bit different from what I orignally posted: CREATE TABLE logged_in ( id tinyint(4) DEFAULT '0' NOT NULL auto_increment, session varchar(100) DEFAULT '0' NOT NULL, time_in varchar(50) NOT NULL, KEY id (id) ); -- PHP General 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] select based on time/date
I am using sessions on my site and have noticed that people often don't click the logout button -- something which I need them to do in order to clear their session from the db and update some site stats. In the sessions table, I have a field $timein (in format F j, Y, g:i a) that gets added when the user logs in and a $timeout field that gets added when they hit logout. Basically, what I've been thinking of doing is using cron to run a php script every hour or so that will search the table for sessions with no $timeout field and $timein is more than X number of minutes old. My problem is that since I'm using the F j, Y, g:i a date/time format, how would I make the mysql select? Do I have to explode the $timein field? Any suggestions are appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] dumping a session
If an admin deletes a user's session while they are online, is it possible to show that user a message saying that their session has been revoked? I can seem to think of a way to determine if the user logged out or if the agent kicked them out. Thanks in advance and please excuse my newbieness. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] RE: problem with $HTTP_POST_FILES
Now I just feel like an idiot... that was the answer! I had all the other globals registered but that one. Thanks for your time! Jason. If they're empty but phpinfo displays them you're probably inside a function and haven't declared HTTP_POST_FILES as global. Jason Dulberg wrote: I am working on an image upload script and I've tried to use the variables from $HTTP_POST_FILES however it seems that no matter how I try to get the variables, they are always empty -- even though they are populated when checking phpinfo(); HTTP_POST_FILES[binFile] Array ( [name] = arrow-block.gif [type] = image/gif [tmp_name] = /var/tmp/phph60272 [size] = 857 ) I got some info on it from php.net and attempt to echo as they have on their site however it displays nothing. echo $HTTP_POST_FILES['binFile']['name'].br; I am attempting to get size/extension of the file to determine if its a valid extension and within the valid filesize range. Is this a server issue or just my php newbie-ness? If anyone has any ideas on how I can get this working, please let me know. Thanks. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] problem with $HTTP_POST_FILES
I am working on an image upload script and I've tried to use the variables from $HTTP_POST_FILES however it seems that no matter how I try to get the variables, they are always empty -- even though they are populated when checking phpinfo(); HTTP_POST_FILES[binFile] Array ( [name] = arrow-block.gif [type] = image/gif [tmp_name] = /var/tmp/phph60272 [size] = 857 ) I got some info on it from php.net and attempt to echo as they have on their site however it displays nothing. echo $HTTP_POST_FILES['binFile']['name'].br; I am attempting to get size/extension of the file to determine if its a valid extension and within the valid filesize range. Is this a server issue or just my php newbie-ness? If anyone has any ideas on how I can get this working, please let me know. Thanks. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] bold current menu item
The menu that's taken from the database is basically a list of links like this $s=select * FROM molds m, prodlookup p WHERE p.cid=$cid and p.pid=m.id ORDER BY p.pid; $menu=mysql_query($s); while ($stuff = mysql_fetch_array($menu)) { extract($stuff); echo a href=\?cid=$cidid=$idpage=1\.$title./abr; } So basically there could be an unlimited # of links depending on how many products there are. I'm guessing that before I echo the link, I need to evaluate whether $id is in the current URL. How would I go about doing that? Thanks for your time. __ Jason Dulberg Extreme MTB http://extreme.nas.net On Thu, 16 Aug 2001 03:50, Jason Dulberg wrote: I am dynamically creating a menu based on a title field from a database. ie item1 item2 etc. Is it possible that when I'm on the item1 page to bold the title in the menu? Any suggestions are appreciated. Presumably there is a corresponding filed for filename, or URL, or somesusch? If so, just check whether the current script name matches, and if so add the STRONG tags where needed. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA If at first you don't succeed, work for Microsoft. -- PHP General 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] bold current menu item
I am dynamically creating a menu based on a title field from a database. ie item1 item2 etc. Is it possible that when I'm on the item1 page to bold the title in the menu? Any suggestions are appreciated. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] .inc location security
I have about 20 virtual hosts on my server and all of them have shtml and some php files that look to a directory /includes/ which is aliased (in the srm.conf file) over to a main includes directory under the root dir. Alias /includes/ /usr/local/etc/httpd/htdocs/includes/ If I change this alias to a directory above the root dir, I can still view all of my .inc files in a browser even if I rename them to .inc.php These .inc files are just plain text that get included into all .shtml files on the virtual hosts. I tried to do the deny *.inc but doing so just made it so the browser can't even include them. So that won't do the trick. Is there any way that I can make these .inc files not readable by viewing them directly in the browser and still be able to include them into documents? Same goes for the php config stuff. If I put a config.php script above the root, how can I get the php script to read it -- is it the same 'ol /usr/etc/httpd/ sort of thing like cgi? My main concern is to get this stuff more secure while still allowing all of the virtual hosts to use the files. The contents of the files isn't exactly top secret, its just a matter of a piece of mind. Any ideas to sort this out are greatly appreciated! Thanks. __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] populating dropdown list problems
I would like to populate a dropdown list from a particular field of a bunch of records. Here's what I have so far on the modify page but it doesn't list stuff from the database, all it prints is the number 1 which isn't in any of the records. One version of this will be on an add page and another will be on a modify page which has the current field selected. For the add script, I'd just lose all the selected stuff that's on there now. print "select name=\"owner\""; $result = mysql_query("SELECT owner,agent FROM homes;"); while($a_row = mysql_fetch_array($result)) { printf('option name="owner" value="'.$a_row[owner].'"'.$a_row[owner].'/option', $a_row[owner], ($owner == $a_row[owner]) ? "selected" : "", $a_row[owner]); } print "/select"; What am I doing wrong in this code? Even when I take out the selected stuff, I still get a value of 1 in the list instead of the actual contents of the field. Any help is greatly appreciated! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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] framing search results
I'd like to create a script that will frame search results made by various databases. I will be hardcoding these links into an HTML page. Since there will be alot of these links and I will be using the script across several virtual hosts, I can't have the links built by a db as they link to offsite stuff. My problem so far is that if I try to link to a search result (which is obviously built by a database), I get a bunch of errors because the , =, ? etc. fields are dropped. So basically, I need to escape the ?,'s etc. in the url. I can do this in perl (cgi::escape) but I'm not quite sure how to do it in php. Couldn't get it to work properly in perl so I'm crossing over to PHP to see if its doable. Here's what I got from a code example from zend.com. Basically, I just need to add the %3A etc onto $url. ? switch($x){ case "frame": ? frameset framespacing="0" border="0" frameborder="NO" rows="135,*" frame name="top" src="header.shtml" marginwidth="0" marginheight="0" scrolling="NO" noresize frame name="textarea" src="? echo $url; ?" ? break; } ? Now one thing that I noticed is that often when the url is encoded and I try the link, I get a 404 error. What am I doing wrong? So the links that I hardcode into the html is something like xyz.com/frame.php?page=searchresults.php or something like that. I'm really new to php so sorry if this is kinda vague. If there's a better way of doing what I'm trying to above, please let me know! Thanks in advance for your help! __ Jason Dulberg Extreme MTB http://extreme.nas.net -- PHP General 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]