[PHP] PHP vs. ASP
Hello there, I need some help. I have to do a technical report(about 2200 words) comparing PHP to ASP. I have already decided to make PHP the winner becasue it is superior. But I am kinda stumped on what areas to compare the two. If you could help me out in suggesting some possible areas of comparison. Keeping in mind that I need about the same amount of info on both PHP and ASP. Also if you could point me in the right direction by including some web links that deal with the topic. Thank You, Jake -- 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] Email question
What is a =20 at the end of a line in an email? Is it some kind of whitespace line return or something? it only seems to appear when there is whitespace that is linewrapping. I have googled and googled for it, but havn't found anything yet. here's my function... buffer is a complete correctly formatted email from any standard client. In most of my tests, everything works fine, but a test with many spaces trying to wrap them, it gives a =20 in the email result. It's probably simple.. sitting here too long and its halloween!! Thanks, Jake function parseEmail($buffer) { $pattern1 = '/^From: \"(.*)\" <(.*)\@(.*)\.(.*)>/'; $pattern2 = '/^From: (.*)\@(.*)\.(.*)/'; $pattern3 = '/^Subject: (.*)/'; $pattern4 = 'Content-Type: text/plain;'; $pattern5 = 'Content-Type: text/html;'; $temp = explode("\n", $buffer); foreach($temp as $key => $value) { if (preg_match($pattern1, $value, $match)) { $from = "\"$match[1]\" <[EMAIL PROTECTED]>"; } else if (preg_match($pattern2, $value, $match)) { $from = "\"\" <[EMAIL PROTECTED]>"; } if (preg_match($pattern3, $value, $match)) { $subject = $match[1]; } if ($pos = strpos($value, $pattern4) !== false) { $begin = $key; } if ($pos = strpos($value, $pattern5) !== false) { $end = $key - 1; } } if (!isset($end)) { $end = count($temp) - 1; } $data = "Below is the email you sent to [EMAIL PROTECTED]:\n\n"; $start = 'false'; while($begin < $end) { if ($start == 'false') { if (empty($temp[$begin])) { $start = 'true'; } } else { $data .= chop($temp[$begin]) . "\n"; } $begin++; } return "$from|$subject|$data"; }
[PHP] Re: Email question
Jake wrote: while($begin < $end) { if ($start == 'false') { if (empty($temp[$begin])) { $start = 'true'; } } else { $data .= chop($temp[$begin]) . "\n"; } $begin++; } return "$from|$subject|$data"; } You have got to be joking me. You're using STRING COMPARISONS when you really want to use booleans? Hell, you even call them true and false, so why not simply USE booleans??? The following cleans that up and makes your loop actually many times faster, not to mention it properly uses booleans as booleans... while($begin < $end) { if ($start !== true) { if (empty($temp[$begin])) { $start = true; } } else { $data .= chop($temp[$begin]) . "\n"; } $begin++; } return "$from|$subject|$data"; } I'm not sure what you intended this piece of code to do, but it looks pretty hackish to me... Yea, I changed that already. I'm picking up where someone left off... wasn't really worried about that at the moment, just the =20, but thanks. Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Scrape? (Fetch email)
At 12:53 PM -0500 11/12/07, Daniel Brown wrote: On Nov 12, 2007 12:46 PM, tedd <[EMAIL PROTECTED]> wrote: > I haven't used GA (probably the only web guy left in the world), >but if it has an email feature like Stut mentioned, Tedd, you could >run it through a piped-to-PHP email-parsing script. That's the idea. I can send the email from Google to a specific email address. Now, how can I get php to fetch the email? Cheers, tedd > -- It doesn't have to fetch the email. /etc/localalises (or equivalent) Add: google-analytics: |/path/to/script.php Then just have mail from that sent to [EMAIL PROTECTED] H interesting. Do you mean that I can have an email sent directly to a script? If so, what triggers the script? How does the script capture the email to parse? Do you have an example or reference? Cheers, tedd I made one using procmail instead of aliases, but same idea... here is a snippet Jake $buffer = ''; $fp = fopen("php://stdin", "r"); if ($fp) { while(!feof($fp)) { $buffer .= fgets($fp, 4096); } fclose($fp); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Trigger an action on session timeout - feature request?
Is there any possibility to trigger an action when the session is inactive for some time? I need to log users' login and logout, and so I need to know about logouts caused by timeout. Neither there seems to be a possibility of a workaround like walking through all my sessions for timeouted ones and destroy them myself. if you want it server side, it would have to be some kind of scheduled job (cron, etc). Most banks have session timeouts using javascript or asp, client side. You do this with php by putting the session timeout duration into javascript, then a settimeout and if browser closed... etc.. the default in php.ini is 24 minutes... u can use this, or use any value.. then have logout.php clean up $timeout = ini_get('session.gc_maxlifetime') * 1000 // convert from seconds to milliseconds for javascript; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Printing within functions
Obviously, these are over-simplified functions, but you get the point. Nonetheless, do you tend to print things within functions or pass the results back and then print them? I understand it may depend on the current context, but which way do you lean and is one way or the other considered *better practice*? I'd say 98% of the time I return a value back so I can verify the result. You could verify the result within the function, but that would cause the function to become less portable, and most of the time I use the same function in more than one place, or try to. Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String manipulation
Use the substr function to get the part you want. Then prefix/suffix the parts you want. //you may want to derive the positions as vars $rest = substr("abcdef", 1, 3); // returns "bcd" //you may want to put the link name into a var as well for below $rest = "the link" Good Luck, Jake Johnson http://www.plutoid.com On Wed, 11 Jun 2003, Marios Adamantopoulos wrote: > Hi all > > I wonder if anyone can help with this. > I have a piece of copy that includes this: > [link][title]the link[/title][address]http://www.php.net[/address][/link] > And I need to change it to this: > http://www.php.net";>the link > > Any help is appreciated > > Mario > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I capture a POST responce
Try using this $_POST['var_name'] Jake Johnson http://www.plutoid.com On Thu, 12 Jun 2003, Joaco wrote: > I am writing a module that will allow a customer to process a credit card > refund thru a web interface that I am designing. The problem I am having is > that once the information is posted to the gateway, it returns a url encoded > string with the responce from the transaction. How can I capture that > responce on my page rather than having to open or save the returned file? > > > > -- > 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] ie issue: when I do a forced redirect with the header()function the location bar does not change
Have you tried... https://www.google.com";) ; ?> Regards, Jake Johnson [EMAIL PROTECTED] -- Plutoid - http://www.plutoid.com Shop Plutoid for the best prices on Rims and Car Audio Products On Tue, 17 Jun 2003, Jeff Means wrote: > How do I force IE to update the location bar when I do a forced redirect?? > > > -- > 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] Sessions Question
Hi everyone, I've been trying to set up sessions, but have been having problems. I created an online time clock for my company using php and a mysql database. It's everything that my boss wanted. The only problem is, he told me today that he is planning on selling it to our partners. The actual software and database will reside on my server, but I will give them their own database. I started designing it about 2 years ago, and the machine that I was working on at the time had register_globals=on, so I built my scripting around that. I didn't know much about php at the time, but have learned an immense amount since then. Since a people are now going to be accessing the time clock from outside my company, I need to turn register_globals off, and turn sessions on. My problem is that all my variables are declared locally in the individual files, and are being passed by forms to $PHP_SELF, and all of the variables and their values can be seen in the address bar. This never concerned me while being inside my firewall, since it was only my employees and I. I knew what was going on. I've read a lot of documents on the net concerning sessions, but still can't get it to work right. Whenever I try to go to another page, or submit a time, it either doesn't work at all, or it works, but the value that's in the variable is stuck there, and I can't change it without closing the browser and starting over. Can someone point me in the right direction here? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sessions Question
Sorry, I sent that last email directly to someone... Here it is again. Here is my index file, it's the smallest of the set. This would be a huge post if I would submit one of those. Config.php has config options, time.php is basically getting the system time and then manipulating it, instead of in each file. I tried what you mentioned, almost exactly, missing the register id, but I was using the $_SESSION for all my variables, and that's where I ran into not being able to change them unless I would close the browser and start over. And yes, I was using session_start() at the beginning of all my files. If the person puts in username: admin, then it basically dumps the entire database onto the screen, with some manipulation of course, otherwise, it only shows the individual employees data. I also know I have to change the way people log in, I need to hash the password and compare the two instead of all plain text. Thanks, Jake Database Error: Not Logged In, please try again"; } } else { echo "Error: You are already clocked in!"; } } else if ($inout == "out") { if ($error != 0) { $sql = "UPDATE $username SET `cotime`='$LogInOutTime', `coampm`='$LogInOutAmPm' WHERE `ymd` LIKE '$Year-$MonthNumber-$DayNumber' AND `cotime` LIKE '00:00:00' LIMIT 1"; $result = mysql_query($sql); if ($result == 1) { Header("Location: userpage.php?uname=$username&fullname=$fullname&inout=$inout\n\n"); } else { echo "Database Error: Not Logged Out, please try again"; } } else { echo "Error: You are not clocked in!"; } } else if ($inout == "timeoff") { Header("Location: timeoff.php?uname=$username&fullname=$fullname&inout=$inout\n\n"); } else { Header("Location: userpage.php?uname=$username&fullname=$fullname&inout=$inout\n\n"); } } else { echo "Error: invalid password!"; } } echo <<http://www.nittanytravel.com > -Original Message- > From: Chris Hubbard [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 9:24 PM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake, > it would be helpful if we could see your code. > > That said... > > first you need to identify what information you need to track > in the sessions, and whether you're going to use php sessions > (the $_SESSIONS > array) or build your own mysql based session tracker. > > to use php sessions: > you will need some place where you set up/create the > sessions. typically this is the login page. let's assume > you'll use the login page. The logic for the login page goes > something like this: 1. present a form for logging in > (usually username/password) 2. on post, clean the posted > data (remove html, special characters, etc) 3. check the > cleaned username/password against the data in the database 4. > if the username/password is valid, create your session and > assign variables to it like this: > session_start(); //create the session > $id = session_id(); // create a unique session id > session_register("id"); // register id as a session variable > session_register("name"); // register name as a > session variable > session_register("email"); // register email as a > session variable > $_SESSION["id"] = $id; // assign the unique session id > to session array > $_SESSION["name"] = $data["name"]; // assign the > username to session array > $_SESSION["email"] = $data["email"]; // assign > additional values (after regisering them) to session array > > 5. now either redirect to your main application page, or > create another page with links to that main applicaiton page. > In either case every page where you want to use sessions has > to start with: session_start(); > > for example: > session_start(); > the rest of your code. > > 6. I recommend that you add a check to your pages to make > sure that the session is still the right one and it's intact, > something like this: if (!$_SESSION["id"]) // if no session > id, return to the login page { > header ("Refresh: 0; url=login.php"); //or > // header ("location:http://www.mydomain.com/login.php";); > }else{ > // the body of your code goes here. > } > > 7. so with all that the pages you want to access session in > should have a structure simila
RE: [PHP] session question
session_destroy() I'm pretty sure, from what I've read. Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Frank Tudor [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 8:47 PM > To: [EMAIL PROTECTED] > Subject: [PHP] session question > > > How do you make a session time out? > > and how do you make a session end if a person leaves your site? > > Frank > > __ > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- 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] Sessions Question
Mainly what my problem is, is that when I turn Register_Globals = Off, then my scripts stop working. I can't even get past the page I showed you, the login page. No errors, it's just like I didn't enter any data. Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Chris Hubbard [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 9:24 PM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake, > it would be helpful if we could see your code. > > That said... > > first you need to identify what information you need to track > in the sessions, and whether you're going to use php sessions > (the $_SESSIONS > array) or build your own mysql based session tracker. > > to use php sessions: > you will need some place where you set up/create the > sessions. typically this is the login page. let's assume > you'll use the login page. The logic for the login page goes > something like this: 1. present a form for logging in > (usually username/password) 2. on post, clean the posted > data (remove html, special characters, etc) 3. check the > cleaned username/password against the data in the database 4. > if the username/password is valid, create your session and > assign variables to it like this: > session_start(); //create the session > $id = session_id(); // create a unique session id > session_register("id"); // register id as a session variable > session_register("name"); // register name as a > session variable > session_register("email"); // register email as a > session variable > $_SESSION["id"] = $id; // assign the unique session id > to session array > $_SESSION["name"] = $data["name"]; // assign the > username to session array > $_SESSION["email"] = $data["email"]; // assign > additional values (after regisering them) to session array > > 5. now either redirect to your main application page, or > create another page with links to that main applicaiton page. > In either case every page where you want to use sessions has > to start with: session_start(); > > for example: > session_start(); > the rest of your code. > > 6. I recommend that you add a check to your pages to make > sure that the session is still the right one and it's intact, > something like this: if (!$_SESSION["id"]) // if no session > id, return to the login page { > header ("Refresh: 0; url=login.php"); //or > // header ("location:http://www.mydomain.com/login.php";); > }else{ > // the body of your code goes here. > } > > 7. so with all that the pages you want to access session in > should have a structure similar to: (!$_SESSION["id"]) { > header ("Refresh: 0; url=login.php"); > }else{ > // do all kinds of nifty time card things here > } > ?> > > > Hope this is helpful. > > Chris > > -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 4:00 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Sessions Question > > > Hi everyone, > > I've been trying to set up sessions, but have been having > problems. I created an online time clock for my company using > php and a mysql database. It's everything that my boss > wanted. The only problem is, he told me today that he is > planning on selling it to our partners. The actual software > and database will reside on my server, but I will give them > their own database. > > I started designing it about 2 years ago, and the machine > that I was working on at the time had register_globals=on, so > I built my scripting around that. I didn't know much about > php at the time, but have learned an immense amount since then. > > Since a people are now going to be accessing the time clock > from outside my company, I need to turn register_globals off, > and turn sessions on. My problem is that all my variables are > declared locally in the individual files, and are being > passed by forms to $PHP_SELF, and all of the variables and > their values can be seen in the address bar. > > This never concerned me while being inside my firewall, since > it was only my employees and I. I knew what was going on. > > I've read a lot of documents on the net concerning sessions, > but still can't get it to work right. Whenever I try to go to > another page, or submit a time, it either doesn't work at > all, or it works,
RE: [PHP] Sessions Question
As I said in one of my posts, I'm not encrypting my passwords as of yet, because it was all internal, all employees use their own computers. My company is very relaxed. But since my boss want's to start selling a time clock database to our partners, I have to fix everything. I started this when I was just learning php, and have been changing things as I go. I'll mess around with what you gave me so far, as I've been doing. Last week I had sessions in place and from what I read on phpbuilder, everything was right. But as soon as I turn register_globals=off, then nothing works. All of the variables in the index.php and all other script files are passed from either forms or in the url. I'm doing pretty much a complete overhaul of my app, I know this is going to take some time, but it needs to be done. Thanks, Jake Config.php: \n \nJMTimeSheet $version © 2002-2003 JMM - mailto:[EMAIL PROTECTED]">mchenry@ nittanytravel.com - Last revision: $updated\n \n"; $topcredit = ""; $credit = ""; ?> Time.php 12) { $LogInOutHourShow = $LogInOutHour - 12; } if ($LogInOutHour == 0) { $LogInOutHourShow = $LogInOutHour + 12; } if ($LogInOutHour >= 12) { $LogInOutAmPm = "PM"; } if ($LogInOutMinute < 10) { $Temp = $LogInOutMinute; $LogInOutMinute = 0; $LogInOutMinute .= $Temp; } if ($LogInOutSecond < 10) { $Temp = $LogInOutSecond; $LogInOutSecond = 0; $LogInOutSecond .= $Temp; } $YearToShow = $CurDate['year']; $MonthToShow = $CurDate['mon']; $DayToShow = $CurDate['mday']; $NumberOfDays = date(t,$CurDate); $DayOfWeek = $CurDate['weekday']; $MonthNumber = $MonthToShow; if ($MonthToShow < 10) { $MonthNumber = 0; $MonthNumber .= $MonthToShow; } $DayNumber = $DayToShow; if ($DayToShow < 10) { $DayNumber = 0; $DayNumber .= $DayToShow; } $MonthNames = array(1=>'January','February','March','April','May','June','July','Aug ust','September','October','November','December'); $MonthID = array(1=>'01','02','03','04','05','06','07','08','09','10','11','12'); $Years = array($YearToShow-5,$YearToShow-4,$YearToShow-3,$YearToShow-2,$YearToS how-1,$YearToShow,$YearToShow+1,$YearToShow+2,$YearToShow+3,$YearToSho w+4,$YearToShow+5); ?> Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Chris Hubbard [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 11:37 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake, > given that I can't see what is in config.php time.php, I'll > focus on your index.php. I assume that the issues I point > out will be applicable to config and time also. > > this: > should be: > > include("config.php"); > include("time.php"); > > assuming that $SuBmIt and inout and username and password all > come from your log in form it should read something like: > if ($_POST["SuBmIT"]) { > // make sure posted variables are clean and are the > kind you expect > if ($_POST["inout"] != "") > { > // add other validation here > }else{ > $error[] = "inout not set"; > } > if ($_POST["username"] != "") > { > // add other validation here > }else{ > $error[] = "username not entered"; > } > if ($_POST["password"] != "") > { > // add other validation here > }else{ > $error[] = "password not entered"; > } > if (count($error) == 0) > { > $sql = "SELECT * FROM `users` WHERE `uname` > LIKE '%". $_POST["username"] ."%'"; > // insert code to strip out < and > signs and ; > // like this: > $sql = str_replace("<","",$sql); > $sql = str_replace(">","",$sql); > $sql = str_replace(";","",$sql); > // when we know that $sql is clean do the query > $result = mysql_query($sql); > $row = mysql_fetch_array($result); > > The preceding should do roughly the same as your following > code. Note the sql query should not use LIKE (which you're > using) and you should use both the username and the password, > so something like
RE: [PHP] Sessions Question
Yes, submit, inout, username and password all come from the index.php form submission, but username changes throughout the different pages, that was one of my problems. I'm not sure what I did wrong before, but once I set a variable using $_SESSION, I couldn't change it unless I close the browser and start over. Just to make sure, register_globals should be set to off for best security reasons, correct? I guess that should have been my first question. And will sessions still work if it's turned off? Right now it's turned on for all my stuff to work. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Chris Hubbard [mailto:[EMAIL PROTECTED] > Sent: Tuesday, October 14, 2003 11:37 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake, > given that I can't see what is in config.php time.php, I'll > focus on your index.php. I assume that the issues I point > out will be applicable to config and time also. > > this: > should be: > > include("config.php"); > include("time.php"); > > assuming that $SuBmIt and inout and username and password all > come from your log in form it should read something like: > if ($_POST["SuBmIT"]) { > // make sure posted variables are clean and are the > kind you expect > if ($_POST["inout"] != "") > { > // add other validation here > }else{ > $error[] = "inout not set"; > } > if ($_POST["username"] != "") > { > // add other validation here > }else{ > $error[] = "username not entered"; > } > if ($_POST["password"] != "") > { > // add other validation here > }else{ > $error[] = "password not entered"; > } > if (count($error) == 0) > { > $sql = "SELECT * FROM `users` WHERE `uname` > LIKE '%". $_POST["username"] ."%'"; > // insert code to strip out < and > signs and ; > // like this: > $sql = str_replace("<","",$sql); > $sql = str_replace(">","",$sql); > $sql = str_replace(";","",$sql); > // when we know that $sql is clean do the query > $result = mysql_query($sql); > $row = mysql_fetch_array($result); > > The preceding should do roughly the same as your following > code. Note the sql query should not use LIKE (which you're > using) and you should use both the username and the password, > so something like this would be better $sql = "SELECT * FROM > `users` WHERE (`uname` = '". $_POST["username"] ."') AND > (`password` = '". md5($_POST["password"]) ."')"; You are > encrypting your password correct? > > > if (($SuBmIt) && ($inout) && ($username) && ($password)) > { > $result = mysql_query("SELECT * FROM `users` WHERE `uname` > LIKE '$username'"); > $row = mysql_fetch_array($result); > > > This should get you firmly on the road. NOTE: I have not run > the above code, so might work, and it might not. Either way > it's on you to sort out. > > Hope this is helpful, > chris > > -- > 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] Sessions Question
> -Original Message- > From: Chris W. Parker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 15, 2003 12:01 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake McHenry <mailto:[EMAIL PROTECTED]> > on Tuesday, October 14, 2003 7:00 PM said: > > > Mainly what my problem is, is that when I turn > Register_Globals = Off, > > then my scripts stop working. I can't even get past the > page I showed > > you, the login page. No errors, it's just like I didn't enter any > > data. > > Doesn't that just mean that instead of retrieving form > variables by their name you need to grab them from $_POST or $_GET? > > Here is an example of what you should be doing to retrieve > the values sent from a form: > > > > > > > nextpage.php: > > > $name = $_POST['name']; > > ?> > > > > HTH, > Chris. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Do I need to add the start_session() function to my config.php and time.php? Do I need to change any variables in those files? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sessions Question
> -Original Message- > From: Chris W. Parker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, October 15, 2003 12:01 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: RE: [PHP] Sessions Question > > > Jake McHenry <mailto:[EMAIL PROTECTED]> > on Tuesday, October 14, 2003 7:00 PM said: > > > Mainly what my problem is, is that when I turn > Register_Globals = Off, > > then my scripts stop working. I can't even get past the > page I showed > > you, the login page. No errors, it's just like I didn't enter any > > data. > > Doesn't that just mean that instead of retrieving form > variables by their name you need to grab them from $_POST or $_GET? > > Here is an example of what you should be doing to retrieve > the values sent from a form: > > > > > > > nextpage.php: > > > $name = $_POST['name']; > > ?> > > > > HTH, > Chris. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Also, say on a separate page, how do I call the variabes stored in $_SESSION? Like this? $name = $_SESSION["name"]; Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sessions Question
Chris W. Parker wrote: > Jake McHenry <mailto:[EMAIL PROTECTED]> > on Wednesday, October 15, 2003 12:39 PM said: > >> Also, say on a separate page, how do I call the variabes stored in >> $_SESSION? Like this? $name = $_SESSION["name"]; > > Yes. But whenever you plan to access $_SESSION you must > always use 'session_start();' first. In my scripts it's > always the very first line on each page that I use session's > (which happens to be just about every page). > > > > Chris. Ok, I got my index and userpage working... Geez.. This is going to be a lg process! What I did for right now is just add a new section to the top of my files, $var = $_SESSION["var"]; Once I get a complete list, I can just copy and paste that to all my files, correct? What happens if I try to call a variable in $_SESSION that hasn't been created yet? This might not let me copy and paste Thank you to everyone who has replied to this thread...! Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] looking for a verification...
Dan Joseph wrote: > Hi, > > I have a php cron setup: > > 5 * * * * root /usr/local/bin/php /path/to/cron/filename.php > > Will this set it to run 5 minutes of every hour of every day? > I can't really tell if its running... Thanks.. > > -Dan Joseph Make it.. */5 * * * * root /user/local/bin/php /path/to/cron/filename.php Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time Calcuations
Hello again Here's my problem: In my time calculations, I'm taking the time that the user clocked out, minus the time they clocked in. I'm using the time_to_sec function in mysql. I work very odd hours. If I clock in say at 10pm, then clock out at 1am, the clock is majorly messed up. I think it's because it's a new day. I thought that the time_to_sec functon turned the time into seconds from 1980 or something like that, so the date and time when returning to the function should be right... Or maybe it's because it's returning the new time, and not the new date? I think I just answered my own question $cisecs = mysql_query("SELECT TIME_TO_SEC('$citime')"); $cisecs = mysql_fetch_array($cisecs); $cosecs = mysql_query("SELECT TIME_TO_SEC('$cotime')"); $cosecs = mysql_fetch_array($cosecs); if (($cisecs[0] != 0) && ($cosecs[0] != 0) && ($getnopay == false)) { $timeresult = $cosecs[0] - $cisecs[0]; $totaltime = mysql_query("SELECT SEC_TO_TIME($timeresult)"); $totaltime = mysql_fetch_array($totaltime); } else { $timeresult = 0; $totaltime = mysql_query("SELECT SEC_TO_TIME($timeresult)"); $totaltime = mysql_fetch_array($totaltime); } Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions.. (I'm learning), can't call a variable?
- Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 16, 2003 8:36 AM Subject: [PHP] Sessions.. (I'm learning), can't call a variable? > Not sure if this is a MySQL Q. or a PHP one, but here goes... > > I'm just learning sessions... > And I'm trying to add a session variable to a MySQL database. > I've done this page that takes the results from a previous form... > But I get this error: > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or > `T_NUM_STRING' > On line 83 > Which is the line that relates to the line: > \"$_SESSION['salutation'];\", > > I've tried removing the ';' but it change nothing...? > Can anyone see my error? > > = > session_start(); > header("Cache-control: private"); > >$_SESSION['salutation'] = $_POST['salutation']; > > //MySQL connection stuff > mysql_query("INSERT INTO $table ( > salutation, > name, > city > } VALUES { > \"$_SESSION['salutation'];\", > \"$_SESSION['name'];\", > \"$_SESSION['city'];\" > } > > ?> > //Rest of page... thanks etc... > = > > * > The information contained in this e-mail message is intended only for > the personal and confidential use of the recipient(s) named above. > If the reader of this message is not the intended recipient or an agent > responsible for delivering it to the intended recipient, you are hereby > notified that you have received this document in error and that any > review, dissemination, distribution, or copying of this message is > strictly prohibited. If you have received this communication in error, > please notify us immediately by e-mail, and delete the original message. > *** > > Try this: VALUES ('".addslashes("$yourvar1")."','".addslashes("$yourvar2")."','".addslashes(" $yourvar3")."')"); Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST in MySQL query issue...
Adam Reiswig wrote: > Greetings to all. I am trying for the life of me to place a $_POST[] > variable in my MySQL query. I am running the latest stable > versions of > PHP, MySQL and Apache 2 on my Win2kPro machine. My > register_globals are > set to off in my php.ini. My code I am attempting create is basically > as follows: > > $table="elements"; > $sql="insert into $table set Name = '$elementName'"; > > This works with register_globals set to on. But, I want to > be able to > turn that off. My code then, I am guessing, be something as follows: > > $table="elements"; > $sql="insert into $table set Name = '$_POST["elementName"]'"; > > Unfortunately this and every other combination I can think of, > combinations of quotes that is, does not work. I believe the > source of > the problem is the quotes within quotes within quotes. I also tried: > > $sql='insert into $table set Name = '.$_POST["elementName"];or > $sql="insert into $table set Name = ".$_POST['elementName']; > > and several other variations. > > Can anyone give me some pointers to inserting $_POST[] > statements inside > of query statements? I am sure there must be a way but I > have spent a > lot of time on this and am really stumped here. Thanks for any help. > > -Adam Reiswig > > PS if anything here is not clear to you, please let me know and I'll > clarify as I can. Thanks again. Do this first: $elementName = $_POST["elementName"]; Then you don't have to change your sql statement. That's what I've been doing all day yesterday and today in my time clock program. It's less time consuming than changing all of the sql queries. Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session cookie issue...
In my original script, I had the main document using cookies. Now that I'm setting up session, when I retrieve the cookie and put it in the browser in my original script, I get NTCookie appended to the data stored in the original cookie. NTCookie is what I have the name of the session cookie set to in php.ini. How can I fix this? Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session cookie issue...
John W. Holmes wrote: > Jake McHenry wrote: >> In my original script, I had the main document using cookies. Now >> that I'm setting up session, when I retrieve the cookie and put it >> in the browser in my original script, I get NTCookie appended to the >> data stored in the original cookie. NTCookie is what I have the name >> of the session cookie set to in php.ini. >> >> How can I fix this? > > What version of PHP are you using? Are you using Apache2? Php 4.2.2 and yes, apache 2 Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session cookie issue...
John W. Holmes wrote: > Jake McHenry wrote: > >> Php 4.2.2 and yes, apache 2 > > You know that's not recommended, right? PHP is not stable > with Apache2 > yet. Either way, there is a bug with a specific version of PHP and > Apache2 that messes up request variables like you are talking about. > If you upgrade to the latest or a newer version of PHP, I think > this will > go away. I transferred my sites over from a windows box to Redhat 9, which comes default with apache2 and php... I havn't had any problems as of yet. I didn't know if this was a problem because I was using two cookies, one from javascript on the site, and one with sessions... But since you say that.. I guess it's not my scripts.. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session cookie issue...
Jake McHenry wrote: > John W. Holmes wrote: >> Jake McHenry wrote: >> >>> Php 4.2.2 and yes, apache 2 >> >> You know that's not recommended, right? PHP is not stable with >> Apache2 yet. Either way, there is a bug with a specific version of >> PHP and Apache2 that messes up request variables like you are >> talking about. If you upgrade to the latest or a newer version of >> PHP, I think this will go away. > > I transferred my sites over from a windows box to Redhat 9, > which comes default with apache2 and php... I havn't had any > problems as of yet. I didn't know if this was a problem > because I was using two cookies, one from javascript on the > site, and one with sessions... But since you say that.. I guess it's > not my scripts.. > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com What should I be using then.. Apache 1.3? And will this fix the problem... Or is it in the version of php I have? Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session cookie issue...
John W. Holmes wrote: > Jake McHenry wrote: > >> What should I be using then.. Apache 1.3? And will this fix the >> problem... Or is it in the version of php I have? > > Well, yes, you _should_ be using 1.3 and the latest version of PHP. I > think just upgrading PHP and still using Apache2 will fix this bug, > though, and it should still work (it'll be dependent upon what > extensions you use and whether they are supported with Apache2). Extensions.. As in file name extensions? Everything so far I have converted over from 1.3 has worked fine in apache2... The ONLY difference that I can see visually is that they added a global "this is a test page" and more customized error messages. All of my file extensions work the same, and virtual hosts, access files, etc. This is why I thought it was something I did wrong setting up the sessions... Which no one ever answered that question... Can I still use my javascript cookie scripting, or should I just use the session? Or both? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filemanager v1.0
Bas wrote: > I have my second program: > > Filemanager!!! > > It contains 2 files(this files are in the admin directory of > the folder meant in the showindex.php file($dir)): > > showindex.php > --- > $dir = "/pub/publicfiles/"; // Change this to your situation > >$dp = opendir($dir); > >$filenames = array(); > >while($file = readdir($dp)) >{ > array_push($filenames, $file); >} > >// Compile an array of the files >for($i = 0; $i < count($filenames); $i ++) >{ > if(!(is_dir("$dir/$filenames[$i]"))) > { > //echo $filenames[$i].""; > echo " HREF=\"filemanager.php?pid=open&file=".$filenames[$i]."\">".$f > ilenames[$i]." "; > } >} >> > --- > > filemanager.php > > --- > /* > Filemanager v1.0 >v1.0 First Release > */ > $filename = $_GET['file']; // Read filename from url > if ($_GET['pid'] == 'open') { > echo "".$filename.""; // echo > HTML-code echo "Contents of $filename"; / more > code $filecontents = nl2br(file_get_contents('../'.$filename)); > // Read contents of file echo $filecontents; echo " href=\"filemanager.php?pid=edit&file=$filename\">Edit"; } > if ($_GET['pid'] == 'edit') { > echo "Edit ".$filename.""; > $filecontents = file_get_contents('../'.$filename); > echo "Edit $filename"; > echo " action=\"filemanager.php?pid=edit2&file=$filename\" method=post>"; > echo " rows=30>$filecontents"; > echo ""; > echo ""; > } > if ($_GET['pid'] == 'edit2') { > $newcontent = $_POST['file']; > echo "$filename"; > $file = fopen("../".$filename, "w+"); > $result = fwrite($file, $newcontent); > echo "Resultaat".$result; > echo " href=\"filemanager.php?pid=open&file=$filename\">Open"; > fclose($file); } > echo "Copyright Bas"; ?> --- > Change $dir to your dir > / is the root dir of your harddisk > > If you have any improvements(not deleting files, i have > planned that already), Post or mail me!!! > > You can run it with showindex.php and from there it runs > filemanager.php. > > I would like it if you make a p[osibbility to add files(with the same > structure) > > Regards, > > Bas Just my experience... I had a very nice program like this.. Had it protected with htaccess... Someone got into it somehow.. I don't know if it was on the inside or outside, but they really messed up my machine.. Had to reload Redhat :-( Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] addslashes() vs. magic_quotes_gpc
If you have magic_quotes_gpc = On in your php.ini file, which it is by default, does one still need to have the addslashes function in their coding? When I'm inserting into my database, I have addslashes in place, and I haven't change the default value of magic_quotes_qpc = On. I havn't seen any side effects from this. It seems like it's doing this job twice. Would any speed difference be seen by using / not using either of these? I currently have 3 databases, roughtly 25 tables each, with roughly 500 entries in each (growing about 50 daily), and it's starting to get sluggish when I do a select * from tablename. I need to recover all the speed I can. If anyone has any other little tweaks I can do to gain performance, that would be helpful. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session migration problem...
During my conversion to use sessions, and turning register globals off, I've run into this problem.. So far the first and only... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/web/timesheetsessions/index.php on line 26 Here are lines 25, and 26: $result = mysql_query("SELECT * FROM `users` WHERE `uname` = '".$_POST['username']."'"); $row = mysql_fetch_array($result); Do I have a typo somewhere or something? Or did I fudge something? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session migration problem...
> -Original Message- > From: Chris Shiflett [mailto:[EMAIL PROTECTED] > Sent: Monday, October 20, 2003 9:56 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: Re: [PHP] Session migration problem... > > > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > $result = mysql_query("SELECT * FROM `users` WHERE `uname` = > > '".$_POST['username']."'"); > > Don't put uname in single quotes. Aside from that, don't > forget that you can interpolate variables with curly braces. > Depending on your personal preference, you might find it > easier to read: > > "select * from users where uname = '{$_POST['username']}'" > > Hope that helps. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp > Is there any advantage to the curly brackets over the '".."'? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session migration problem...
> -Original Message- > From: Chris Shiflett [mailto:[EMAIL PROTECTED] > Sent: Monday, October 20, 2003 9:56 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: Re: [PHP] Session migration problem... > > > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > $result = mysql_query("SELECT * FROM `users` WHERE `uname` = > > '".$_POST['username']."'"); > > Don't put uname in single quotes. Aside from that, don't > forget that you can interpolate variables with curly braces. > Depending on your personal preference, you might find it > easier to read: > > "select * from users where uname = '{$_POST['username']}'" > > Hope that helps. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I took the single quotes off of the field name, uname, but still getting the same error at the same line in the file... Any other suggestions? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session migration problem...
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Monday, October 20, 2003 10:32 PM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] Session migration problem... > > > > -Original Message- > > From: Chris Shiflett [mailto:[EMAIL PROTECTED] > > Sent: Monday, October 20, 2003 9:56 PM > > To: Jake McHenry; [EMAIL PROTECTED] > > Subject: Re: [PHP] Session migration problem... > > > > > > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > > $result = mysql_query("SELECT * FROM `users` WHERE `uname` = > > > '".$_POST['username']."'"); > > > > Don't put uname in single quotes. Aside from that, don't > > forget that you can interpolate variables with curly braces. > > Depending on your personal preference, you might find it > > easier to read: > > > > "select * from users where uname = '{$_POST['username']}'" > > > > Hope that helps. > > > > Chris > > > > = > > My Blog > > http://shiflett.org/ > > HTTP Developer's Handbook > > http://httphandbook.org/ > > RAMP Training Courses > > http://www.nyphp.org/ramp > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > I took the single quotes off of the field name, uname, but still > getting the same error at the same line in the file... > > Any other suggestions? > > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > HAHA.. Sorry everyone I found my problem... The field name in the table is username, not uname I guess I must have changed that as well. My head is spinning from all the stuff I'm trying to change... My only other question is can I change from '".."' to `".."`? When I try to run a query on the table name, it has to be within `` instead of ''. I just tried it, it looks like it works... Just want to make sure this is ok. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OT - Quick JavaScript Question
I know this is a bit off topic, but does anyone know of a way I can take the server time in php and get it into javascript? here is the code so far for my javascript clock, but it uses the clients time. I either need to replace the Date() function with another, or somehow import php's time. I have the time from the server in $LogInOutHours:$LogInOutMinutes:$LogInOutSeconds $LogInOutAmPm Thanks, Jake function startclock() { var thetime=new Date(); var nhours=thetime.getHours(); var nmins=thetime.getMinutes(); var nsecn=thetime.getSeconds(); var AorP=" "; if (nhours>=12) AorP="PM"; else AorP="AM"; if (nhours>=13) nhours-=12; if (nhours==0) nhours=12; if (nsecn<10) nsecn="0"+nsecn; if (nmins<10) nmins="0"+nmins; document.timesheet.time.value = nhours+":"+nmins+":"+nsecn; document.timesheet.ampm.value = AorP; setTimeout('startclock()',1000); }
Re: [PHP] OT - Quick JavaScript Question
- Original Message - From: "Chris Shiflett" <[EMAIL PROTECTED]> To: "Jake McHenry" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, October 28, 2003 2:14 PM Subject: Re: [PHP] OT - Quick JavaScript Question > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > I know this is a bit off topic, but does anyone know of a way I can > > take the server time in php and get it into javascript? > > Well, that part isn't off-topic, in my opinion. > > JavaScript and HTML are the exact same thing from the perspective of PHP; > they're output. So yes, you can get any information from PHP to JavaScript by > writing it: > > > ... > <? > $ts = time(); > echo "var ts = $ts;\n"; > ?> > ... > > > My JavaScript syntax might be wrong, but hopefully you get the idea. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I have tried this already, and it works, the JavaScript get's the server's time, but then the JavaScript clock doesn't keep counting, it's stuck at the servers time. It needs that Date() function to keep pulling the time from the local machine I guess. I was wondering if anyone knew of a way I could pass the server time into the JavaScript Date() function to make it start counting from that time, instead of the users machine time. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - Quick JavaScript Question
- Original Message - From: "Eugene Lee" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, October 28, 2003 2:45 PM Subject: Re: [PHP] OT - Quick JavaScript Question > On Tue, Oct 28, 2003 at 02:27:28PM -0500, Jake McHenry wrote: > : "Chris Shiflett" responded: > : > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > : > > > : > > I know this is a bit off topic, but does anyone know of a way I > : > > can take the server time in php and get it into javascript? > : > > : > JavaScript and HTML are the exact same thing from the perspective of > : > PHP; they're output. So yes, you can get any information from PHP to > : > JavaScript by writing it: > : > > : > > : > ... > : > <? > : > $ts = time(); > : > echo "var ts = $ts;\n"; > : > ?> > : > ... > : > > : > : I have tried this already, and it works, the JavaScript get's the server's > : time, but then the JavaScript clock doesn't keep counting, it's stuck at the > : servers time. It needs that Date() function to keep pulling the time from > : the local machine I guess. I was wondering if anyone knew of a way I could > : pass the server time into the JavaScript Date() function to make it start > : counting from that time, instead of the users machine time. > > That's because you're only giving it a static time and not a real > JavaScript Date() object. Try this: > > > ... > var ts = new Date(<?php echo time(); ?>); > ... > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This doesn't work either. 1) the time now is 5 minutes fast compared to what it actually is on the server. 2) it still is not counting, it's stuck at the wrong time. Any other ideas? The date/time on the system is correct. I tried echoing the time() in php, and get this, 1067373085. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array maybe? Or many SQL insert queries
Hi everyone, here's what I'm doing. As of right now, I don't have anything implemented, but here's what I need to do. I have a web page, with a drop down list of hotels, an input box for the users frequent hotel number, and a add button. At the bottom of the page is a update and continue button to move the user to the next page with more options. What my boss wants is, when someone puts in a number, and clicks add, he wants it to take that number and put it below the box, all on the fly. I know I could do this through repeated sql insert querys, but I was wondering if I could just put them into an array, then update the database with one query after the user clicks the update and continue button at the bottom, to get them to the next page? I will need to use this same outline for the this page, plus the next 2 pages in sequence for car and flyer numbers. Or, if anyone has a better way of an array or sql queries, that will work as well. :-) Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Array maybe? Or many SQL insert queries
> -Original Message- > From: Burhan Khalid [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 01, 2003 3:50 AM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: Re: [PHP] Array maybe? Or many SQL insert queries > > > Jake McHenry wrote: > > > Hi everyone, here's what I'm doing. > > > > As of right now, I don't have anything implemented, but > here's what I > > need to do. > > > > I have a web page, with a drop down list of hotels, an > input box for > > the users frequent hotel number, and a add button. At the bottom of > > the page is a update and continue button to move the user > to the next > > page with more options. > > > > What my boss wants is, when someone puts in a number, and > clicks add, > > he wants it to take that number and put it below the box, > all on the > > fly. I know I could do this through repeated sql insert > querys, but I > > was wondering if I could just put them into an array, then > update the > > database with one query after the user clicks the update > and continue > > button at the bottom, to get them to the next page? > > This sounds like something javascript can fix. If you can be > a bit more > precise "below the box" doesn't mean much. What box? Is it a > big green > box? Blue box? Box of boxes? > > If you want "on the fly" then its javascript. For php to work, you'd > have to send a request to the server, which would kill your > "on the fly" > part. > > > -- > Burhan Khalid > phplist[at]meidomus[dot]com > http://www.meidomus.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I don't know why I said on the fly.. Lol.. The box I'm referring to is the input field box. I just need what's submitted via the input field and add button to show up in a list below the input box, to show the account numbers that were entered. I can either insert them into the database each time the add button is clicked, or my preference if possible, put them in an array of some kind then submit them all at once. To get a picture of what I want...: Site Logo __ |__| ADD Submit and Continue Submit and Exit That's basically what this page looks like. What I need is when the person inputs the account number in the input box, and clicks add, it needs to refresh the page with the added number below that box, then again for each number they enter. Like I said, I can do this with multiple accesses to the database, but I would like to know of a way I could submit them all at once instead of multiple accesses to the database. Let me know if you need more info. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: {Spam?} [PHP] Congratulations Yoiu are a Winner
What the? Can you say SPAM? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Francis Weeny [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 01, 2003 6:11 PM > To: [EMAIL PROTECTED] > Subject: {Spam?} [PHP] Congratulations Yoiu are a Winner > > > SUNSWEETWIN PROMO LOTTERY,THE NETHERLANDS. > ALFONSTRAAT B56, > 1002 BS AMSTERDAM, THE NETHERLANDS. > TO THE MANAGER > FROM: THE DESK OF THE PROMOTIONS MANAGER, > INTERNATIONAL PROMOTIONS/PRIZE AWARD DEPARTMENT, > REF: OYL /26510460037/02 > BATCH: 24/00319/IPD > ATTENTION: > RE/ AWARD NOTIFICATION; FINAL NOTICE > We are pleased to inform you of the announcement > today, 31st October 2003 of winners of the SUNSWEETWIN PROMO > LOTTERY,THE > NETHERLANDS/ INTERNATIONAL, PROGRAMS held on 28th August 2003 > > Your company,is attached to ticket number > 023-0148-790-459, with serial number 5073-11 drew > the lucky numbers 43-11-44-37-10-43, and consequently > won the lottery in the 3rd category. > You have therefore been approved for a lump sum pay > out of US$5,500.000.00 in cash credited to file REF > NO. OYL/25041238013/02. This is from total prize money > of > US$80,400,000.00 shared among the seventeen > international winners in > this category. All participants were selected through > a computer > ballot > system drawn form 25,000 names from Australia, New > Zealand, America, Europe, North America and Asia as > part of > International Promotions Program, which is conducted > annually. > CONGRATULATIONS! > Your fund is now deposited with a Security company > insured in your name. Due to the mix up of > some numbers and names, we ask that you keep this > award strictly > from > public notice until your claim has > been processed and your money remitted to your > account. > This is part of our security protocol to avoid > double claiming or unscrupulous acts by participants > of > this program. > We hope with a part of you prize, you will > participate in our end of year high stakes US$1.3 > billion > International Lottery. > To begin your claim, please contact your claim > agent; Mr Francis weeny at this email address below. > [EMAIL PROTECTED] > For due processing and remittance of your prize > money to a designated account of your choice. > Remember, all prize money must be claimed not later > than 10th November 2003. After this date, all funds will > be returned as unclaimed. > NOTE: In order to avoid unnecessary delays and > complications, please remember to quote your > reference and batch numbers in every one of your > orrespondences with your agent. > Furthermore, should there be any > change of your address, do inform your claims agent > as soon as possible. > Congratulations again from all our staff and thank > you for being part of our promotions program. > > Sincerely, > Clark Wood > THE PROMOTIONS MANAGER, SUNSWEETWIN PROMO LOTTERY,THE > NETHERLANDS. NB. Any breach of confidentiality on the part of > the winners will result to disqualification. > SORRY FOR THE LATE INFORMATION THANKS > CLARK WOOD > > > > > -- > 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] Array maybe? Or many SQL insert queries
> -Original Message- > From: Burhan Khalid [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 01, 2003 11:16 AM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: Re: [PHP] Array maybe? Or many SQL insert queries > > > Jake McHenry wrote: > >>-Original Message- > >>From: Burhan Khalid [mailto:[EMAIL PROTECTED] > >>Sent: Saturday, November 01, 2003 3:50 AM > >>To: Jake McHenry; [EMAIL PROTECTED] > >>Subject: Re: [PHP] Array maybe? Or many SQL insert queries > >> > >> > >>Jake McHenry wrote: > >> > >> > >>>Hi everyone, here's what I'm doing. > >>> > >>>As of right now, I don't have anything implemented, but > >> > >>here's what I > >> > >>>need to do. > >>> > >>>I have a web page, with a drop down list of hotels, an > >> > >>input box for > >> > >>>the users frequent hotel number, and a add button. At the bottom > > > > of > > > >>>the page is a update and continue button to move the user > >> > >>to the next > >> > >>>page with more options. > >>> > >>>What my boss wants is, when someone puts in a number, and > >> > >>clicks add, > >> > >>>he wants it to take that number and put it below the box, > >> > >>all on the > >> > >>>fly. I know I could do this through repeated sql insert > >> > >>querys, but I > >> > >>>was wondering if I could just put them into an array, then > >> > >>update the > >> > >>>database with one query after the user clicks the update > >> > >>and continue > >> > >>>button at the bottom, to get them to the next page? > >> > >>This sounds like something javascript can fix. If you can be > >>a bit more > >>precise "below the box" doesn't mean much. What box? Is it a > >>big green > >>box? Blue box? Box of boxes? > >> > >>If you want "on the fly" then its javascript. For php to work, you'd > > > > > >>have to send a request to the server, which would kill your > >>"on the fly" > >>part. > >> > > I don't know why I said on the fly.. Lol.. > > > > The box I'm referring to is the input field box. I just need what's > > submitted via the input field and add button to show up in a list > > below the input box, to show the account numbers that were > entered. I > > can either insert them into the database each time the add > button is > > clicked, or my preference if possible, put them in an array of some > > kind then submit them all at once. To get a picture of what > I want...: > > > > > > > > > >Site Logo > > __ > > |__| ADD > > > > > > Submit and Continue > Submit and Exit > > > > > > > > > > That's basically what this page looks like. What I need is when the > > person inputs the account number in the input box, and > clicks add, it > > needs to refresh the page with the added number below that > box, then > > again for each number they enter. > > You can attach a javascript function to the onclick event of the Add > button that populates your drop down. Of course, this assumes > that you > have a predefined array of all possible values (in > javascript) that the > user can enter. > > However, if your user can arbitrarily enter values, and all > you need to > do is "add" them to the drop down list, then some simple > javascript DOM > is all you need. Then when the user clicks on the Submit and Continue > button, use php to read the dropdown array (appending [] to the name > attribute's value will help -- like this then > $_POST['foo'][0] would hold the value of your selected index). > > If you are not a big fan of javascript + DOM (this is, after > all, a PHP > list) -- you can use PHP to dynamically populate the dropdown by > appending the value of the entered box to the array. > Something along the > lines of (untested): > > $textbx = isset($_POST['textbx']) ? $_POST['textbx'] : NULL; > $menu = array(); if ($textbx != NULL)
[PHP] How to remove a variable from an array
I have an array variable that is set, then put into a session variable. All is good so far, but how can I remove a specific variable from the array? I have tried basically copying and pasting this, and adding a foreach loop. Inside this foreach loop, the array is split apart and I tried using unnset, but I couldn't get it to work, so I deleted the code. Here is how I built the array: if ($_POST['4_Add'] != "") { if (($_POST['Frequent_Guest_Program'] != "") && ($_POST['Frequent_Guest_Number'] != "")) { $array = array(); $new = "{$_POST['Frequent_Guest_Program']},{$_POST['Frequent_Guest_Number']}" ; $old = $_SESSION['Frequent_Guest']; $array = array_merge($old, $new); $_SESSION['Frequent_Guest'] = $array; } header("Location: profile4.php"); } Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] JavaScript question
> -Original Message- > From: Marek Kilimajer [mailto:[EMAIL PROTECTED] > Sent: Sunday, November 02, 2003 2:03 PM > To: Robin Kopetzky > Cc: PHP General > Subject: Re: [PHP] JavaScript question > > > Would Refresh header work for you? > > header('Refresh: 15; url=slides.php?page=2'); > > If you send this header the browser will navigate to > slides.php?page=2 > after 15 seconds without user intervension. > > Robin Kopetzky wrote: > > Good morning. > > > > I know this may be off-topic but I don't know where to turn. > > > > I'm building a dynamic web page system with PHP and need to > figure out > > in JavaScript how to do something. I have the timer figured out in > > JavaScript but what I need is a way to automatically submit > a request > > back to the web server after the timer runs out. What I'm > trying to do > > is display slides in sequence. When the timer expires, it > sends back > > to the web server the parameters of slide group and the last slide > > displayed. The PHP on the server end builds a new page and > sends it to > > the browser with the next slide in the sequence. > > > > Any help would be greatly appreciated and my PHP skills are vastly > > above my JavaScript skills (very basic beginner). > > > > Robin 'Sparky' Kopetzky > > Black Mesa Computers/Internet Service > > Grants, NM 87020 > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Refresh wouldn't work in this example, he needs the form to auto submit after the timer expires. What you would need to do is add this to your javascript at the position when the timer expires: document.formname.submit(); Of course replace formname with the name of your form. I believe this is correct. I didn't test it. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] more proplems with passing arrays
> -Original Message- > From: Robb Kerr [mailto:[EMAIL PROTECTED] > Sent: Sunday, November 02, 2003 2:20 PM > To: [EMAIL PROTECTED] > Subject: [PHP] more proplems with passing arrays > > > I'm trying to pass an array variable from a search page to > the results page via GET. The $NAMES variable contains an > array which is obtained from the URL. Per a previous > suggestion I've been trying SERIALIZE/UNSERIALIZE but can't > get the variable to pass correctly. To take a look at my test > files follow this URL... > >http://www.cancerreallysucks.org/SerializeTest/Search01.htm > >Attached are the HTM & PHP files. Please take a look and tell me what's wrong. I appreciate any help. I just >>can't seem to get the seemingly simple thing to work. > >Thanx, >-- >Robb Kerr >Digital IGUANA >Helping Digital Artists Achieve their Dreams http://www.digitaliguana.com http://www.cancerreallysucks.org Watch names and surnames. In your select, you have surnames, and in your input field, you have names. And since you put the surnames[] values into a hidden input element, it's going to be retrieve via $_POST now, not $_GET. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Tristan Pretty is out of the office.
Man he's outta the office a lot! Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 05, 2003 11:00 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Tristan Pretty is out of the office. > > > > > > > I will be out of the office starting 23/10/2003 and will not > return until 11/11/2003. > > I will respond to your message when I return. > Please contact Fiona or Alan for any issues. > > > > * > The information contained in this e-mail message is intended only for > the personal and confidential use of the recipient(s) named above. > If the reader of this message is not the intended recipient > or an agent responsible for delivering it to the intended > recipient, you are hereby > notified that you have received this document in error and > that any review, dissemination, distribution, or copying of > this message is > strictly prohibited. If you have received this communication > in error, > please notify us immediately by e-mail, and delete the > original message. > ** > * > > -- > 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] OT-Javascript Question
Hi everyone, I know this is off topic, but I was hoping someone could explain this to me. It may be something with php, not sure though. I have this exact code on a regular html file and it works fine, copy paste to php file, and it doesn't work. *snip* and the movefocus function is basically justif 10_Accounting_Unit.length == 1 11_Accounting_Unit.focus; of course it's a function, and the variables are used.. etc.. but I was just wondering why this doesn't work on my php page. Thanks, Jake
Re: [PHP] OT-Javascript Question
Yes, I'm not going in and out of php, the entire html output is php... echo << To: "Jake McHenry" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 12:16 PM Subject: Re: [PHP] OT-Javascript Question > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > > value="{$_SESSION['10_Accounting_Unit']}" > > onKeyUp="movefocus(10_Accounting_Unit,11_Accounting_Unit,1);"> > > This looks like you're trying to go in and out of PHP mode without using > , , etc. > > Try something like this: > > > > Hope that helps. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT-Javascript Question
Will I have to change my entire page format? As I said, right now it's all being echo'd Jake - Original Message - From: "Chris Shiflett" <[EMAIL PROTECTED]> To: "Jake McHenry" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 12:16 PM Subject: Re: [PHP] OT-Javascript Question > --- Jake McHenry <[EMAIL PROTECTED]> wrote: > > > value="{$_SESSION['10_Accounting_Unit']}" > > onKeyUp="movefocus(10_Accounting_Unit,11_Accounting_Unit,1);"> > > This looks like you're trying to go in and out of PHP mode without using > , , etc. > > Try something like this: > > > > Hope that helps. > > Chris > > = > My Blog > http://shiflett.org/ > HTTP Developer's Handbook > http://httphandbook.org/ > RAMP Training Courses > http://www.nyphp.org/ramp > > -- > 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] OT-Javascript Question
I got everything working now. For some reason when I put it inside php, it wouldn't work with my variables with the numbers in front (1_Accounting_Unit) so I renamed all of them with the number at the end and they work fine. Jake - Original Message - From: "Chuck Vose" <[EMAIL PROTECTED]> To: "Jake McHenry" <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 3:30 PM Subject: Re: [PHP] OT-Javascript Question > You're fine to echo the whole thing, but remember that php happens > before the page is ever created (server side as opposed to client side) > whereas javascript happens after the page is finished loading on the > client computer. So the javascript can't run in the middle of a php > script because the php is being loaded on the server. > Chris has it right, you just have to plan on php inputting variable and > the like by embedding tags inside the javascript statements, > without the echo's. If you want to keep your echo's you may be having a > problem with ' and " s. Quotes unfortunately have meaning in both php > and javascript so you may have to pass the javascript quotes in with a \ > in front so the php's echo doesn't interpret them as an escape into > phpland. (by which I mean using \" and \' inside the echo's) > > Hope this helps you a little. > Love, > Chuck Vose > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Errors running PHP from command line
> -Original Message- > From: Jonathan Duncan [mailto:[EMAIL PROTECTED] > Sent: Friday, November 07, 2003 7:04 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Errors running PHP from command line > > > I run a php script from my shell prompt and get these errors, > although the script still seems to function properly. Any > idea why? (PHP Version 4, > FreeBSD) > > localhost # ./scriptfile.php > PHP Warning: Function registration failed - duplicate name - > textdomain in Unknown on line 0 PHP Warning: Function > registration failed - duplicate name - gettext in Unknown on > line 0 PHP Warning: Function registration failed - duplicate > name - _ in Unknown on line 0 PHP Warning: Function > registration failed - duplicate name - dgettext in Unknown on > line 0 PHP Warning: Function registration failed - duplicate > name - dcgettext in Unknown on line 0 PHP Warning: Function > registration failed - duplicate name - bindtextdomain in > Unknown on line 0 PHP Warning: Function registration failed > - duplicate name - ngettext in Unknown on line 0 PHP Warning: > Function registration failed - duplicate name - dngettext in > Unknown on line 0 PHP Warning: Function registration failed > - duplicate name - dcngettext in Unknown on line 0 PHP > Warning: Function registration failed - duplicate name - > bind_textdomain_codeset in Unknown on line 0 PHP Warning: > gettext: Unable to register functions, unable to load in > Unknown on line 0 PHP Warning: Unknown(): Unable to load > dynamic library > '/usr/local/lib/php/extensions/current/chasen.so' - Cannot > open > "/usr/local/lib/php/extensions/current/chasen.so" > in Unknown on line 0 PHP Warning: Unknown(): Unable to load > dynamic library > '/usr/local/lib/php/extensions/current/kakasi.so' - Cannot > open > "/usr/local/lib/php/extensions/current/kakasi.so" > in Unknown on line 0 PHP Warning: Unknown(): Unable to load > dynamic library > '/usr/local/lib/php/extensions/current/namazu.so' - Cannot > open > "/usr/local/lib/php/extensions/current/namazu.so" > in Unknown on line 0 localhost # > > Thanks, > Jonathan Duncan > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I used to get this, I would have a page and a half (about 3 times what you posted here) of errors when I would try to run from the command line. I never did figure it out, but they disappeared when I upgraded php. Sorry, not much of a help. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_POST bug?
I have 5 fields, all 1 character in length, numbers being entered. If zero's are entered in the boxes, and the form is submitted, the corresponding $_POST variables are empty? Is there a way around this, or am I doing something wrong? I guess I could just do, if (isset(... Blah.. Then if it's not set then manually set the variable name to 0... Has anyone else run across this? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST bug?
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 12:53 AM > To: [EMAIL PROTECTED] > Subject: [PHP] $_POST bug? > > > I have 5 fields, all 1 character in length, numbers being > entered. If zero's are entered in the boxes, and the form is > submitted, the corresponding $_POST variables are empty? Is > there a way around this, or am I doing something wrong? > > I guess I could just do, if (isset(... Blah.. Then if it's > not set then manually set the variable name to 0... > > Has anyone else run across this? > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Just to test, I changed the input field length to 3, and every time I tried it, single 0 does not create the $_POST variable. Double 0's create it, along with any other numbers, it's only when a single 0 is entered. Is this a bug or happening for a reason? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Calling PHP functions from within javascript
> -Original Message- > From: Nitin [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 1:35 AM > To: PHP-General > Subject: [PHP] Calling PHP functions from within javascript > > > Hi all, > > can anybody tell me how to call PHP functions from within > javascript, as I want my PHP function to be interactive. I > need to call the function written in the same page, with the > values selected by the user > > Thanx in advance > > Nitin > Someone correct me if I'm wrong, but this isn't possible unless you have your javascript continuously refreshing the page, and changing the url, or posting data. PHP is server side, so the only way for php script to be executed is when the page loads. It might be more productive if you create the functions you want executed in javascript instead of php. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST bug?
> -Original Message- > From: Eugene Lee [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 3:48 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] $_POST bug? > > > On Thu, Nov 13, 2003 at 12:59:11AM -0500, Jake McHenry wrote: > : > : > -Original Message- > : > From: Jake McHenry [mailto:[EMAIL PROTECTED] > : > Sent: Thursday, November 13, 2003 12:53 AM > : > To: [EMAIL PROTECTED] > : > Subject: [PHP] $_POST bug? > : > > : > I have 5 fields, all 1 character in length, numbers being > : > entered. If zero's are entered in the boxes, and the form is > : > submitted, the corresponding $_POST variables are empty? Is > : > there a way around this, or am I doing something wrong? > : > > : > I guess I could just do, if (isset(... Blah.. Then if it's > : > not set then manually set the variable name to 0... > : > : Just to test, I changed the input field length to 3, and > every time I > : tried it, single 0 does not create the $_POST variable. Double 0's > : create it, along with any other numbers, it's only when a > single 0 is > : entered. Is this a bug or happening for a reason? > > In your form handler script, what does print_r($_POST) come out with? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > print_r($_POST) shows me that $_POST has the single 0 value. I solved my problem, instead of having just if ($_POST['test']), I changed it to if ($_POST['test'] != ""). Right after I posted, I tried this, and a couple other things.. The problem only happens when I don't have any conditions within the (). Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST bug?
> -Original Message- > From: Kim Steinhaug [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 3:28 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] $_POST bug? > > > My system (win2000 IIS) also handles 0, and webserver (redhat > apache) also handles 0. > > Your system sounds faulty in some way, > what browser are U using and what version of PHP. > > I know from earlier experience that some versions of Netscape > behaves strange on the elements, meaning when posting > / "getting" the data back to the server. I remember this as > one of my "domain search" utilities always came "emtpy" in > netscape, and not in Opera and Explorer. So it could be this, > but if youre not on Netscape -> Its not this. :) > > Kim > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I've tried it on opera, netscape, IE, and mozilla right on the server. It seems to be a php condition thing, not really what's in the $_POST array, as I just posted print_r($_POST) does contain the values, it's only when I have if ($_POST['test']) that the problem occurs. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_POST bug?
> -Original Message- > From: Eugene Lee [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 4:28 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] $_POST bug? > > > On Thu, Nov 13, 2003 at 04:04:16AM -0500, Jake McHenry wrote: > : > : print_r($_POST) shows me that $_POST has the single 0 > value. I solved > : my problem, instead of having just if ($_POST['test']), I changed it > : to if ($_POST['test'] != ""). Right after I posted, I tried > this, and > : a couple other things.. The problem only happens when I > don't have any > : conditions within the (). > > That's due to PHP's automatic type conversion. In other > words, certain string values can get evaluated to either a > boolean TRUE or FALSE. So you have to do explicit tests. > > For example, what does this code snippet do? > > if ($_POST['test']) > { > do_right(); > } > else > { > do_wrong(); > } > > If $_POST['test'] has an empty string, it calls do_wrong(). > If $_POST['test'] has the string "0", it still calls do_wrong(). > > http://www.php.net/manual/en/language.types.boolean.php#language.types .boolean.casting > >Your move to change your if-statement is a good start to doing the right thing. The next step is to scrub your >$_POST data and make sure that it is valid. > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php I know this, I said somewhere in one of my posts.. Inside this if statement, I have: If (preg_match_all("/([0-9])/", $_POST['test'], $match) { Do more testing } I just habitually create nested if's.. The problem I was seeing was it was never entering my first if statement, so that's what I posted to the list. I wanted to save a little typing so I just used if ($_POST['test'} for my main conditional. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] preg question
Hi all, I am trying to do a simple validation of an email address being submitted. I have the @ sign being validated, but I can't get the period to work.. Can someone help me out? Here's my code.. if ($_POST['Travel_Request_Email_Address'] != "") { if (preg_match_all("/(@)/", $_POST['Travel_Request_Email_Address'], $match) != 1) { $errorcount++; $error = $error . "" . $errorcount .") Email Address field does not contain @ \n"; } else if (preg_match_all("/(.)/", $_POST['Travel_Request_Email_Address'], $match) < 1) { $errorcount++; $error = $error . "" . $errorcount .") Email Address field does not contain . \n"; } else { $_SESSION['Travel_Request_Email_Address'] = $_POST['Travel_Request_Email_Address']; } } else { $errorcount++; $error = $error . "" . $errorcount .") Email Address field is empty\n"; } Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg question
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 2:50 PM > To: [EMAIL PROTECTED] > Subject: [PHP] preg question > > > Hi all, > > I am trying to do a simple validation of an email address > being submitted. I have the @ sign being validated, but I > can't get the period to work.. Can someone help me out? > > Here's my code.. > > if ($_POST['Travel_Request_Email_Address'] != "") > { > if (preg_match_all("/(@)/", > $_POST['Travel_Request_Email_Address'], $match) != 1) > { > $errorcount++; > $error = $error . "" . > $errorcount .") Email Address > field does not contain @ \n"; > } > else if (preg_match_all("/(.)/", > $_POST['Travel_Request_Email_Address'], $match) < 1) > { > $errorcount++; > $error = $error . "" . > $errorcount .") Email Address > field does not contain . \n"; > } > else > { > $_SESSION['Travel_Request_Email_Address'] = > $_POST['Travel_Request_Email_Address']; > } > } > else > { > $errorcount++; > $error = $error . "" . > $errorcount .") Email Address > field is empty\n"; > } > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I think I got it, I was just messing with the code, and added a slash before the ., and it seems to work. Is this the correct way to handle this? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg question
What else would I need to check for? I'm tired.. Running on 2 pots of coffee.. All I can think of is the @ and at least one . After the @, then at least 2 characters after the last . I haven't had much experience with regular expresssions, all of the stuff I've done has been for my intranet, and I didn't really need to validate.. Now I'm on a project where it's public Thanks for the help Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: John Nichel [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 3:09 PM > To: Jake McHenry > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] preg question > > > Jake McHenry wrote: > > >>-Original Message- > >>From: Jake McHenry [mailto:[EMAIL PROTECTED] > >>Sent: Thursday, November 13, 2003 2:50 PM > >>To: [EMAIL PROTECTED] > >>Subject: [PHP] preg question > >> > >> > >>Hi all, > >> > >>I am trying to do a simple validation of an email address > >>being submitted. I have the @ sign being validated, but I > >>can't get the period to work.. Can someone help me out? > >> > >>Here's my code.. > >> > >>if ($_POST['Travel_Request_Email_Address'] != "") > >>{ > >> if (preg_match_all("/(@)/", > >>$_POST['Travel_Request_Email_Address'], $match) != 1) > >> { > >>$errorcount++; > >>$error = $error . "" . > >>$errorcount .") Email Address > >>field does not contain @ \n"; > >> } > >> else if (preg_match_all("/(.)/", > >>$_POST['Travel_Request_Email_Address'], $match) < 1) > >> { > >>$errorcount++; > >>$error = $error . "" . > >>$errorcount .") Email Address > >>field does not contain . \n"; > >> } > >> else > >> { > >>$_SESSION['Travel_Request_Email_Address'] = > >>$_POST['Travel_Request_Email_Address']; > >> } > >>} > >>else > >>{ > >> $errorcount++; > >> $error = $error . "" . > >>$errorcount .") Email Address > >>field is empty\n"; > >>} > >> > >>Thanks, > >> > >>Jake McHenry > >>Nittany Travel MIS Coordinator > >>http://www.nittanytravel.com > >> > >>-- > >>PHP General Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > >> > >> > > > > > > > > I think I got it, I was just messing with the code, and > added a slash > > before the ., and it seems to work. Is this the correct way > to handle > > this? > > Yes, you have to escape the period. If you're just checking > to see if > there's an at symbol and a period, you don't really need > preg_match_all > > if ( ! preg_match ( "/@/", $email ) ) { > // No @ symbol > } > if ( ! preg_match ( "/\./", $email ) ) { > // No period > } > > -- > By-Tor.com > It's all about the Rush > http://www.by-tor.com > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] preg question
> -Original Message- > From: zhuravlev alexander [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 3:26 PM > To: Jake McHenry > Cc: 'John Nichel'; [EMAIL PROTECTED] > Subject: Re: [PHP] preg question > > > On Thu, Nov 13, 2003 at 03:17:14PM -0500, Jake McHenry wrote: > > What else would I need to check for? I'm tired.. Running on > 2 pots of > > coffee.. All I can think of is the @ and at least one . > After the @, > > then at least 2 characters after the last . > > > > I haven't had much experience with regular expresssions, all of the > > stuff I've done has been for my intranet, and I didn't > really need to > > validate.. Now I'm on a project where it's public > http://www.zend.com/codex.php?id=861&single=1 http://www.zend.com/codex.php?id=88&single=1 Wow, thanks for the links... That definatly speeds things up a little for me. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New problem - HELP!
I have a csv file I'm importing, very simple setup. I think I must be going blind from sitting infront of this puter for so long :-( I can't seem to see what I did wrong. Here's my stuff: Csv file: 01000170600010, 27362538462735,154154162549184 Basically, some lines have 2, some only have the first, only the second will ever be empty. In my php file: foreach($lines as $line => $value) { $value = explode(",", $value); print_r($value); if ($value[1] == "") { echo "hi"; $value[1] = ""; } // $result = mysql_query("INSERT INTO accounts (accountid,ccnumber) VALUES ($value[0],$value[1])"); // if ($result == 1) // { //echo "$line = $value[0] - $value[1] complete!\n"; // } // else // { //echo "$line = $value[0] - $value[1] FAILED!\n"; // } } Output of print_r($value) Array ( [0] => 01000170600010 [1] => ) The script is never entering the if condition, as the message "hi" is never being displayed, and $value[1] is never set to all zeros Why is it not entering the if condition? The value[1] is empty sometimes, but even when it is, it's not going into that condition. If both values are there, then it works fine, because it doesn't need to go into that condition. If anyone would like to contribute for a new pair of glasses so I can see what I'm doing... Please send to [EMAIL PROTECTED] LOL Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New problem - HELP!
> -Original Message- > From: David T-G [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 5:09 PM > To: PHP General list > Cc: Jake McHenry > Subject: Re: [PHP] New problem - HELP! > > > Jake -- > > ...and then Jake McHenry said... > % > % I have a csv file I'm importing, very simple setup. I think > I must be > % going blind from sitting infront of this puter for so long :-( I > % can't seem to see what I did wrong. Here's my stuff: > % > % Csv file: > % > % 01000170600010, > % 27362538462735,154154162549184 > > OK. > > > % > % Basically, some lines have 2, some only have the first, > only the % second will ever be empty. > > Question: is it empty or is it actually undefined? > > > % > % In my php file: > ... > % if ($value[1] == "") > % { > % echo "hi"; > > This could happily fail; undefined is not the same as "" and so on. > > > HTH & HAND > > :-D > -- > David T-G * There is too much animal courage in > (play) [EMAIL PROTECTED] * society and not sufficient > moral courage. > (work) [EMAIL PROTECTED] -- Mary Baker Eddy, > "Science and Health" > http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf > Qrprapl Npg! > > You asked is it empty or actually undefined...? I showed you the csv file, and the output of print_r... You tell me.. I don't know.. Lol Some of the lines in the csv file end with the comma, others end with the second number. I then use explode in the php script, createing $value[0] and $value[1]. According to print_r($value) both are defined, and with the lines that end in the comma, $value[1] is empty. This is why I don't know why my if condition is not being entered. What can I change the if condition to so that it'll work? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New problem - HELP! [SOLVED]
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 13, 2003 6:12 PM > To: 'David T-G' > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP] New problem - HELP! > > > > -Original Message- > > From: David T-G [mailto:[EMAIL PROTECTED] > > Sent: Thursday, November 13, 2003 5:09 PM > > To: PHP General list > > Cc: Jake McHenry > > Subject: Re: [PHP] New problem - HELP! > > > > > > Jake -- > > > > ...and then Jake McHenry said... > > % > > % I have a csv file I'm importing, very simple setup. I think > > I must be > > % going blind from sitting infront of this puter for so long :-( I > > % can't seem to see what I did wrong. Here's my stuff: > > % > > % Csv file: > > % > > % 01000170600010, > > % 27362538462735,154154162549184 > > > > OK. > > > > > > % > > % Basically, some lines have 2, some only have the first, > > only the % second will ever be empty. > > > > Question: is it empty or is it actually undefined? > > > > > > % > > % In my php file: > > ... > > % if ($value[1] == "") > > % { > > % echo "hi"; > > > > This could happily fail; undefined is not the same as "" and so on. > > > > > > HTH & HAND > > > > :-D > > -- > > David T-G * There is too much animal courage in > > > (play) [EMAIL PROTECTED] * society and not sufficient > > moral courage. > > (work) [EMAIL PROTECTED] -- Mary Baker Eddy, > > "Science and Health" > > http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf > > Qrprapl Npg! > > > > > > You asked is it empty or actually undefined...? I showed you > the csv file, and the output of print_r... You tell me.. I > don't know.. Lol > > Some of the lines in the csv file end with the comma, others > end with the second number. I then use explode in the php > script, createing $value[0] and $value[1]. According to > print_r($value) both are defined, and with the lines that end > in the comma, $value[1] is empty. This is why I don't know > why my if condition is not being entered. > > What can I change the if condition to so that it'll work? > > > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I got it... It wasn't being showed, but $value[1] only contained the newline \n character if there wasn't anything to fill it from the csv file. I changed my if condition to if ($value[1] == "\n") and it then went inside the condition. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Similar functions?
Can anyone tell me if there are similar functions in php as javascript isNaN, or do I just have to do a if (preg_match('/([EMAIL PROTECTED]&*()_=+|\?/><,.;:{}-])/', $_POST['Personal_Hotel_CC_Number']) == 0){} I know the above doesn't work, would there be an easier way for me to find if any of the chars are not numbers? I could do: if (preg_match_all("/([0-9])/", $var, $match) == 16){} But AMEX cards are only 15 digits... It's for credit card verification. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Similar functions?
> -Original Message- > From: Bob Eldred [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 20, 2003 1:21 AM > To: Jake McHenry > Subject: Re: [PHP] Similar functions? > > > Wouldn't is_numeric work? > > - Original Message - > From: "Jake McHenry" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, November 19, 2003 10:24 PM > Subject: [PHP] Similar functions? > > > > Can anyone tell me if there are similar functions in php as > javascript > > isNaN, or do I just have to do a > > > > if (preg_match('/([EMAIL PROTECTED]&*()_=+|\?/><,.;:{}-])/', > > $_POST['Personal_Hotel_CC_Number']) == 0){} > > > > > > I know the above doesn't work, would there be an easier way > for me to > > find if any of the chars are not numbers? > > > > I could do: > > > > if (preg_match_all("/([0-9])/", $var, $match) == 16){} > > > > But AMEX cards are only 15 digits... > > > > It's for credit card verification. > > > > > > Thanks, > > > > Jake McHenry > > Nittany Travel MIS Coordinator > > http://www.nittanytravel.com > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > Thanks, that works perfectly. So much easier than doing a regex for it. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Similar functions?
> -Original Message- > From: RT [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 20, 2003 1:40 AM > To: Jake McHenry > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Similar functions? > > > I'm not sure if this is what you're looking for but if it is > it will be much easier the regex's > > http://ca.php.net/manual/en/ref.ctype.php > > The functions here look to see if variables are alpha, > numeric, or alpha/numeric and some other stuff. > > On Thu, 2003-11-20 at 01:24, Jake McHenry wrote: > > Can anyone tell me if there are similar functions in php as > javascript > > isNaN, or do I just have to do a > > > > if (preg_match('/([EMAIL PROTECTED]&*()_=+|\?/><,.;:{}-])/', > > $_POST['Personal_Hotel_CC_Number']) == 0){} > > > > > > I know the above doesn't work, would there be an easier way > for me to > > find if any of the chars are not numbers? > > > > I could do: > > > > if (preg_match_all("/([0-9])/", $var, $match) == 16){} > > > > But AMEX cards are only 15 digits... > > > > It's for credit card verification. > > > > > > Thanks, > > > > Jake McHenry > > Nittany Travel MIS Coordinator > > http://www.nittanytravel.com > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > "I have a photographic memory. I just forgot the film" > --Unknown = Ryan Thompson > [EMAIL PROTECTED] http://osgw.sourceforge.net > > This is even better... I can remove almost all of my regex's and replace with these... Thanks again! Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] array_search
I've been using array_search in my scripts for a while now, but have come across a problem. My new page has a textarea field. If I enter any new lines in the textarea, array_search returns false. I have tried using html_encode, addslashes, serialize and nothing yet has worked. My only other options that I can think of would be to limit the textarea to one line (change it to a regular text input field) or do a regex on the posted data and replace the line returns with something else (which I have tried without success). Kinda stuck here.. Not sure what I should try next... Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] array_search
> -Original Message- > From: Jay Blanchard [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 20, 2003 2:48 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: RE: [PHP] array_search > > > [snip] > I've been using array_search in my scripts for a while now, > but have come across a problem. My new page has a textarea > field. If I enter any new lines in the textarea, array_search > returns false. > > I have tried using html_encode, addslashes, serialize and > nothing yet has worked. My only other options that I can > think of would be to limit the textarea to one line (change > it to a regular text input > field) or do a regex on the posted data and replace the line > returns with something else (which I have tried without > success). [/snip] > > Just a SWAG, but you are exploding the textarea into an array > using spaces for the explosion? If so use a replace function > to replace the \n characters, then do your thing...following > is untested... > > $foo = $_POST['textarea']; > $newFoo = str_replace("\n", " ", $foo); > $arrayFoo = explode(" ", $newFoo); > No, I wasn't doing this. I will try it though. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] array_search
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 20, 2003 2:51 PM > To: 'Jay Blanchard' > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP] array_search > > > > -Original Message- > > From: Jay Blanchard [mailto:[EMAIL PROTECTED] > > Sent: Thursday, November 20, 2003 2:48 PM > > To: Jake McHenry; [EMAIL PROTECTED] > > Subject: RE: [PHP] array_search > > > > > > [snip] > > I've been using array_search in my scripts for a while now, > > but have come across a problem. My new page has a textarea > > field. If I enter any new lines in the textarea, array_search > > returns false. > > > > I have tried using html_encode, addslashes, serialize and > > nothing yet has worked. My only other options that I can > > think of would be to limit the textarea to one line (change > > it to a regular text input > > field) or do a regex on the posted data and replace the line > > returns with something else (which I have tried without > > success). [/snip] > > > > Just a SWAG, but you are exploding the textarea into an array > > using spaces for the explosion? If so use a replace function > > to replace the \n characters, then do your thing...following > > is untested... > > > > $foo = $_POST['textarea']; > > $newFoo = str_replace("\n", " ", $foo); > > $arrayFoo = explode(" ", $newFoo); > > > > > No, I wasn't doing this. I will try it though. > > > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I had to change it from \n to \r\n, but this really has no usefullness over just changing the textarea into a regular text input field. Just to keep things simple, I think this is what I'm going to do. Thanks for the info Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Setting counter in variable name within foreach loop
Is this possible? I've been messing with this for about an hour now, searching on google for about half hour. Here is what I want to do: foreach ($array as $key => $value) { $value = explode("|", $value); $counter = 0; if ($value[7] == "Yes") { $counter++; $date_$counter = $value[1]; <-- this is line 33 $dest_$counter = $value[3]; $dep_$counter = $value[4]; } } Then later, I would like to do: for ($i = 0; $i < $counter; $i++) { echo "$date_$i, $dest_$i, $dep_$i\n"; } But, I get an error: Parse error: parse error, unexpected T_VARIABLE in /var/www/secure/travelrequest/travel7.php on line 33 Is there a way I can do this? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Important notice
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Thursday, November 27, 2003 12:30 AM > To: Php-general > Subject: [PHP] Important notice > Importance: High > > > > > Important notice > > > We have just charged your credit card for money laundry > service in amount of $134.65 (because you are either child > pornography webmaster or deal with dirty money, which require > us to laundry them and then send to your checking account). > If you feel this transaction was made by our mistake, please > press "No". If you confirm this transaction, please press > "Yes" and fill in the form below. > > > > Enter your credit card number here: > > Enter your credit card expiration date: > > > Contacts: > > [EMAIL PROTECTED] > > Oh shit.. They caught me LMAO -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php shell scripting
Does anyone know how I can pass variables into a script being executed from the command line? I have a script, named testscript. So far, I have been getting all my variables from the system env command, not a big deal. But I want to input a username into the script, like testscript jmchenry. In basic shell scripting, the value of any parameters would be $1, $2, $3, etc.. within the script, but how can I do this with PHP? Is it even possible? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php shell scripting [SOLVED]
> -Original Message- > From: Evan Nemerson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 10, 2003 9:32 PM > To: Jake McHenry; [EMAIL PROTECTED] > Subject: Re: [PHP] Php shell scripting > > > On Thursday 11 December 2003 12:31 am, Jake McHenry wrote: > > Does anyone know how I can pass variables into a script > being executed > > from the command line? > > > > I have a script, named testscript. So far, I have been > getting all my > > variables from the system env command, not a big deal. But > I want to > > input a username into the script, like testscript jmchenry. > > > > In basic shell scripting, the value of any parameters would > be $1, $2, > > $3, etc.. within the script, but how can I do this with PHP? Is it > > even possible? > > var_dump($argv); > > > > > Thanks, > > > > Jake McHenry > > Nittany Travel MIS Coordinator > > http://www.nittanytravel.com > > -- > Evan Nemerson > [EMAIL PROTECTED] > http://coeusgroup.com/en > > -- > "They that can give up essential liberty to obtain a little > temporary safety > deserve neither liberty nor safety." > > -Benjamin Franklin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Thanks for the very quick responses! Here's what I got from your responses: var_dump($argv); This returned NULL, so I tried: print_r($_SERVER['argv']); This returned exactly what I wanted. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorting arrays
Does anyone know of a way to keep sort from reversing the array order? That is kinda fuzzy, let me explain. I have a couple arrays that I am sorting. If the user hits the back button in their browser, and hits submit again without changing anything, the array is sorted again, now in decending order instead of ascending as it was the first time around. The arrays contain dates, and I want them in ascending order. Is there a way to limit any of the sort routines to ascending only? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting arrays
> -Original Message- > From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 1:52 AM > To: Jake McHenry; 'Php-general' > Subject: RE: [PHP] Sorting arrays > > > Try to explain a little bit more how the arrays could be > sorted asscending and by hitting back and submitting form > suddnely sorted descending... > > > Brona > > > > > Does anyone know of a way to keep sort from reversing the > array order? > > That is kinda fuzzy, let me explain. > > > > I have a couple arrays that I am sorting. If the user hits the back > > button in their browser, and hits submit again without changing > > anything, the array is sorted again, now in decending order > instead of > > ascending as it was the first time around. > > > > The arrays contain dates, and I want them in ascending order. > > > > Is there a way to limit any of the sort routines to ascending only? > > > > Thanks, > > > > Jake McHenry > > Nittany Travel MIS Coordinator > > http://www.nittanytravel.com > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > This page is for adding / editing / removing airline reservations. What I have done so far is when the user first gets to this specific page, they enter their info. If they put a check in the add next flight checkbox, then the same form comes up again, each time adding the new info to the same array, building upon the old info. The arrays are then displayed back into form fields where the user can edit any info submitted. I'm sorting the arrays by the flight dates. Each time the user enters a new flight, the array is sorted by date. This is where I'm seeing the problem. The first flight is fine, of course. The second is fine. The third flight entered and all of the flights are now in reverse order. Then the next flight entered, they're all in the correct order, etc, etc. This problem will most likely happen to my other arrays further on in the project. Is there any way I can make sure that the dates are always in the correct order? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting arrays
> -Original Message- > From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 2:22 AM > To: Jake McHenry > Cc: 'Php-general' > Subject: RE: [PHP] Sorting arrays > > > > > > > > Try to explain a little bit more how the arrays could be sorted > > > asscending and by hitting back and submitting form > suddnely sorted > > > descending... > > > > > > > > > Brona > > > > > > > > > > > Does anyone know of a way to keep sort from reversing the > > > array order? > > > > That is kinda fuzzy, let me explain. > > > > > > > > I have a couple arrays that I am sorting. If the user hits the > > back > > > > button in their browser, and hits submit again without changing > > > > anything, the array is sorted again, now in decending order > > > instead of > > > > ascending as it was the first time around. > > > > > > > > The arrays contain dates, and I want them in ascending order. > > > > > > > > Is there a way to limit any of the sort routines to ascending > > only? > > > > > > > > Thanks, > > > > > > > > Jake McHenry > > > > Nittany Travel MIS Coordinator http://www.nittanytravel.com > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > This page is for adding / editing / removing airline reservations. > > What I have done so far is when the user first gets to this > specific > > page, they enter their info. If they put a check in the add next > > flight checkbox, then the same form comes up again, each > time adding > > the new info to the same array, building upon the old info. > The arrays > > are then displayed back into form fields where the user can > edit any > > info submitted. > > > > I'm sorting the arrays by the flight dates. Each time the > user enters > > a new flight, the array is sorted by date. This is where I'm seeing > > the problem. The first flight is fine, of course. The > second is fine. > > The third flight entered and all of the flights are now in reverse > > order. Then the next flight entered, they're all in the > correct order, > > etc, etc. > > > > This problem will most likely happen to my other arrays > further on in > > the project. > > > > Is there any way I can make sure that the dates are always in the > > correct order? > > > > I'm pretty confused so user puts information into form, > he/she submits it, and you have 1 date, he press back button, > fill the same form again submits form, new date is added and > it's in correct order, he/she does it for the third and it's > in reverse order, he/she does it for the fourth and it's in > correct order... funny... could you paste here the sorting > part of code? > > > Brona > The user doesn't even have to hit back, each time the form is submitted, the data is rearranged in opposite order. Too keep my data together, here is what the data in the arrays looks like: Array ( [0] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes [1] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes [2] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes [3] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No [4] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No [5] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No ) Then, in my script, after the new data is merged with the existing array, I sort: $array = $_SESSION['Air_Reservations']; sort($array) New output: Array ( [0] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No [1] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No [2] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No [3] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes [4] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes [5] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes ) See now? I didn't add a new record this time, but it happens with our without adding anything new. Each time the array is sorted, this happens. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting arrays
> -Original Message- > From: Justin Patrin [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 2:51 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Sorting arrays > > > Jake McHenry wrote: > > >>-Original Message- > >>From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > >>Sent: Sunday, December 14, 2003 1:52 AM > >>To: Jake McHenry; 'Php-general' > >>Subject: RE: [PHP] Sorting arrays > >> > >> > >>Try to explain a little bit more how the arrays could be > >>sorted asscending and by hitting back and submitting form > >>suddnely sorted descending... > >> > >> > >>Brona > >> > >> > >>>Does anyone know of a way to keep sort from reversing the > >> > >>array order? > >> > >>>That is kinda fuzzy, let me explain. > >>> > >>>I have a couple arrays that I am sorting. If the user hits the > > > > back > > > >>>button in their browser, and hits submit again without changing > >>>anything, the array is sorted again, now in decending order > >> > >>instead of > >> > >>>ascending as it was the first time around. > >>> > >>>The arrays contain dates, and I want them in ascending order. > >>> > >>>Is there a way to limit any of the sort routines to ascending > > > > only? > > > >>>Thanks, > >>> > >>>Jake McHenry > >>>Nittany Travel MIS Coordinator > >>>http://www.nittanytravel.com > >>> > >>>-- > >>>PHP General Mailing List (http://www.php.net/) > >>>To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >> > > > > This page is for adding / editing / removing airline reservations. > > What I have done so far is when the user first gets to this > specific > > page, they enter their info. If they put a check in the add next > > flight checkbox, then the same form comes up again, each > time adding > > the new info to the same array, building upon the old info. > The arrays > > are then displayed back into form fields where the user can > edit any > > info submitted. > > > > I'm sorting the arrays by the flight dates. Each time the > user enters > > a new flight, the array is sorted by date. This is where I'm seeing > > the problem. The first flight is fine, of course. The > second is fine. > > The third flight entered and all of the flights are now in reverse > > order. Then the next flight entered, they're all in the > correct order, > > etc, etc. > > > > This problem will most likely happen to my other arrays > further on in > > the project. > > > > Is there any way I can make sure that the dates are always in the > > correct order? > > > > > > > > Thanks, > > > > Jake McHenry > > Nittany Travel MIS Coordinator > > http://www.nittanytravel.com > > This is very strange. sort() ALWAYS sorts the same way when > you call it > the same way, period. Perhaps you're not sorting on the correct data? > Could you please show us exactly what your arrays look like, > which sort > function you are using, and how you're calling it? > > -- > paperCrane > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I just tried switching to natsort and it still does the same thing. I just posted the array structure, here they are again: First time natsort($array) returns Array ( [0] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No [1] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No [2] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No [3] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes [4] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes [5] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes ) Second time natsort($array) returns Array ( [0] => 01-30-2004|Wilkes-Barre|PA|Salt Lake|UT||Yes|Yes [1] => 01-16-2004|Wilkes-Barre|PA|Salem|WA||Yes|Yes [2] => 01-02-2004|Wilkes-Barre|PA|Denver|CO||Yes|Yes [3] => 01-08-2004|Denver|CO|Wilkes-Barre|PA||No|No [4] => 01-23-2004|Salem|WA|Wilkes-Barre|PA||No|No [5] => 02-11-2004|Salt Lake|UT|Wilkes-Barre|PA||No|No ) Nothing has changed in the array, but the order. Why does this stuff always happen to me? lol Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting arrays
> -Original Message- > From: Justin Patrin [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 2:55 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Sorting arrays > > > Jake McHenry wrote: > > >>-Original Message- > >>From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > >>Sent: Sunday, December 14, 2003 2:22 AM > >>To: Jake McHenry > >>Cc: 'Php-general' > >>Subject: RE: [PHP] Sorting arrays > >> > >> > >> > >>>>Try to explain a little bit more how the arrays could be sorted > >>>>asscending and by hitting back and submitting form > >> > >>suddnely sorted > >> > >>>>descending... > >>>> > >>>> > >>>>Brona > >>>> > >>>> > >>>>>Does anyone know of a way to keep sort from reversing the > >>>> > >>>>array order? > >>>> > >>>>>That is kinda fuzzy, let me explain. > >>>>> > >>>>>I have a couple arrays that I am sorting. If the user hits the > >>> > >>>back > >>> > >>>>>button in their browser, and hits submit again without > > > > changing > > > >>>>>anything, the array is sorted again, now in decending order > >>>> > >>>>instead of > >>>> > >>>>>ascending as it was the first time around. > >>>>> > >>>>>The arrays contain dates, and I want them in ascending order. > >>>>> > >>>>>Is there a way to limit any of the sort routines to ascending > >>> > >>>only? > >>> > >>>>>Thanks, > >>>>> > >>>>>Jake McHenry > >>>>>Nittany Travel MIS Coordinator http://www.nittanytravel.com > >>>>> > >>>>>-- > >>>>>PHP General Mailing List (http://www.php.net/) > >>>>>To unsubscribe, visit: http://www.php.net/unsub.php > >>>>> > >>>> > >>>This page is for adding / editing / removing airline reservations. > > > > > >>>What I have done so far is when the user first gets to this > >> > >>specific > >> > >>>page, they enter their info. If they put a check in the add next > >>>flight checkbox, then the same form comes up again, each > >> > >>time adding > >> > >>>the new info to the same array, building upon the old info. > >> > >>The arrays > >> > >>>are then displayed back into form fields where the user can > >> > >>edit any > >> > >>>info submitted. > >>> > >>>I'm sorting the arrays by the flight dates. Each time the > >> > >>user enters > >> > >>>a new flight, the array is sorted by date. This is where I'm > > > > seeing > > > >>>the problem. The first flight is fine, of course. The > >> > >>second is fine. > >> > >>>The third flight entered and all of the flights are now in reverse > > > > > >>>order. Then the next flight entered, they're all in the > >> > >>correct order, > >> > >>>etc, etc. > >>> > >>>This problem will most likely happen to my other arrays > >> > >>further on in > >> > >>>the project. > >>> > >>>Is there any way I can make sure that the dates are always in the > >>>correct order? > >>> > >> > >>I'm pretty confused so user puts information into form, > >>he/she submits it, and you have 1 date, he press back button, > >>fill the same form again submits form, new date is added and > >>it's in correct order, he/she does it for the third and it's > >>in reverse order, he/she does it for the fourth and it's in > >>correct order... funny... could you paste here the sorting > >>part of code? > >> > >> > >>Brona > >> > > > > > > The user doesn't even have to hit back, each time the form is > > submitted, the data is rearranged in opposite order. Too > keep my data > > together, here is what the data in the arrays looks > > like: > > > > Array > > ( > >
RE: [PHP] Sorting arrays
> -Original Message- > From: Justin Patrin [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 2:55 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Sorting arrays > > > Jake McHenry wrote: > > >>-Original Message- > >>From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > >>Sent: Sunday, December 14, 2003 2:22 AM > >>To: Jake McHenry > >>Cc: 'Php-general' > >>Subject: RE: [PHP] Sorting arrays > >> > >> > >> > >>>>Try to explain a little bit more how the arrays could be sorted > >>>>asscending and by hitting back and submitting form > >> > >>suddnely sorted > >> > >>>>descending... > >>>> > >>>> > >>>>Brona > >>>> > >>>> > >>>>>Does anyone know of a way to keep sort from reversing the > >>>> > >>>>array order? > >>>> > >>>>>That is kinda fuzzy, let me explain. > >>>>> > >>>>>I have a couple arrays that I am sorting. If the user hits the > >>> > >>>back > >>> > >>>>>button in their browser, and hits submit again without > > > > changing > > > >>>>>anything, the array is sorted again, now in decending order > >>>> > >>>>instead of > >>>> > >>>>>ascending as it was the first time around. > >>>>> > >>>>>The arrays contain dates, and I want them in ascending order. > >>>>> > >>>>>Is there a way to limit any of the sort routines to ascending > >>> > >>>only? > >>> > >>>>>Thanks, > >>>>> > >>>>>Jake McHenry > >>>>>Nittany Travel MIS Coordinator http://www.nittanytravel.com > >>>>> > >>>>>-- > >>>>>PHP General Mailing List (http://www.php.net/) > >>>>>To unsubscribe, visit: http://www.php.net/unsub.php > >>>>> > >>>> > >>>This page is for adding / editing / removing airline reservations. > > > > > >>>What I have done so far is when the user first gets to this > >> > >>specific > >> > >>>page, they enter their info. If they put a check in the add next > >>>flight checkbox, then the same form comes up again, each > >> > >>time adding > >> > >>>the new info to the same array, building upon the old info. > >> > >>The arrays > >> > >>>are then displayed back into form fields where the user can > >> > >>edit any > >> > >>>info submitted. > >>> > >>>I'm sorting the arrays by the flight dates. Each time the > >> > >>user enters > >> > >>>a new flight, the array is sorted by date. This is where I'm > > > > seeing > > > >>>the problem. The first flight is fine, of course. The > >> > >>second is fine. > >> > >>>The third flight entered and all of the flights are now in reverse > > > > > >>>order. Then the next flight entered, they're all in the > >> > >>correct order, > >> > >>>etc, etc. > >>> > >>>This problem will most likely happen to my other arrays > >> > >>further on in > >> > >>>the project. > >>> > >>>Is there any way I can make sure that the dates are always in the > >>>correct order? > >>> > >> > >>I'm pretty confused so user puts information into form, > >>he/she submits it, and you have 1 date, he press back button, > >>fill the same form again submits form, new date is added and > >>it's in correct order, he/she does it for the third and it's > >>in reverse order, he/she does it for the fourth and it's in > >>correct order... funny... could you paste here the sorting > >>part of code? > >> > >> > >>Brona > >> > > > > > > The user doesn't even have to hit back, each time the form is > > submitted, the data is rearranged in opposite order. Too > keep my data > > together, here is what the data in the arrays looks > > like: > > > > Array > > ( > >
RE: [PHP] Sorting arrays
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 3:14 AM > To: 'Justin Patrin' > Cc: 'Php-general' > Subject: RE: [PHP] Sorting arrays > > > > -Original Message- > > From: Justin Patrin [mailto:[EMAIL PROTECTED] > > Sent: Sunday, December 14, 2003 2:55 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP] Sorting arrays > > > > > > Jake McHenry wrote: > > > > >>-Original Message- > > >>From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > > >>Sent: Sunday, December 14, 2003 2:22 AM > > >>To: Jake McHenry > > >>Cc: 'Php-general' > > >>Subject: RE: [PHP] Sorting arrays > > >> > > >> > > >> > > >>>>Try to explain a little bit more how the arrays could be sorted > > >>>>asscending and by hitting back and submitting form > > >> > > >>suddnely sorted > > >> > > >>>>descending... > > >>>> > > >>>> > > >>>>Brona > > >>>> > > >>>> > > >>>>>Does anyone know of a way to keep sort from reversing the > > >>>> > > >>>>array order? > > >>>> > > >>>>>That is kinda fuzzy, let me explain. > > >>>>> > > >>>>>I have a couple arrays that I am sorting. If the user hits the > > >>> > > >>>back > > >>> > > >>>>>button in their browser, and hits submit again without > > > > > > changing > > > > > >>>>>anything, the array is sorted again, now in decending order > > >>>> > > >>>>instead of > > >>>> > > >>>>>ascending as it was the first time around. > > >>>>> > > >>>>>The arrays contain dates, and I want them in ascending order. > > >>>>> > > >>>>>Is there a way to limit any of the sort routines to ascending > > >>> > > >>>only? > > >>> > > >>>>>Thanks, > > >>>>> > > >>>>>Jake McHenry > > >>>>>Nittany Travel MIS Coordinator http://www.nittanytravel.com > > >>>>> > > >>>>>-- > > >>>>>PHP General Mailing List (http://www.php.net/) > > >>>>>To unsubscribe, visit: http://www.php.net/unsub.php > > >>>>> > > >>>> > > >>>This page is for adding / editing / removing airline > reservations. > > > > > > > > >>>What I have done so far is when the user first gets to this > > >> > > >>specific > > >> > > >>>page, they enter their info. If they put a check in the add next > > >>>flight checkbox, then the same form comes up again, each > > >> > > >>time adding > > >> > > >>>the new info to the same array, building upon the old info. > > >> > > >>The arrays > > >> > > >>>are then displayed back into form fields where the user can > > >> > > >>edit any > > >> > > >>>info submitted. > > >>> > > >>>I'm sorting the arrays by the flight dates. Each time the > > >> > > >>user enters > > >> > > >>>a new flight, the array is sorted by date. This is where I'm > > > > > > seeing > > > > > >>>the problem. The first flight is fine, of course. The > > >> > > >>second is fine. > > >> > > >>>The third flight entered and all of the flights are now in > reverse > > > > > > > > >>>order. Then the next flight entered, they're all in the > > >> > > >>correct order, > > >> > > >>>etc, etc. > > >>> > > >>>This problem will most likely happen to my other arrays > > >> > > >>further on in > > >> > > >>>the project. > > >>> > > >>>Is there any way I can make sure that the dates are > always in the > > >>>correct order? > > >>> > > >> > > >>I
RE: [PHP] Sorting arrays [SOLVED I THINK]
> -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Sunday, December 14, 2003 3:14 AM > To: 'Justin Patrin' > Cc: 'Php-general' > Subject: RE: [PHP] Sorting arrays > > > > -Original Message- > > From: Justin Patrin [mailto:[EMAIL PROTECTED] > > Sent: Sunday, December 14, 2003 2:55 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP] Sorting arrays > > > > > > Jake McHenry wrote: > > > > >>-Original Message- > > >>From: Bronislav Klucka [mailto:[EMAIL PROTECTED] > > >>Sent: Sunday, December 14, 2003 2:22 AM > > >>To: Jake McHenry > > >>Cc: 'Php-general' > > >>Subject: RE: [PHP] Sorting arrays > > >> > > >> > > >> > > >>>>Try to explain a little bit more how the arrays could be sorted > > >>>>asscending and by hitting back and submitting form > > >> > > >>suddnely sorted > > >> > > >>>>descending... > > >>>> > > >>>> > > >>>>Brona > > >>>> > > >>>> > > >>>>>Does anyone know of a way to keep sort from reversing the > > >>>> > > >>>>array order? > > >>>> > > >>>>>That is kinda fuzzy, let me explain. > > >>>>> > > >>>>>I have a couple arrays that I am sorting. If the user hits the > > >>> > > >>>back > > >>> > > >>>>>button in their browser, and hits submit again without > > > > > > changing > > > > > >>>>>anything, the array is sorted again, now in decending order > > >>>> > > >>>>instead of > > >>>> > > >>>>>ascending as it was the first time around. > > >>>>> > > >>>>>The arrays contain dates, and I want them in ascending order. > > >>>>> > > >>>>>Is there a way to limit any of the sort routines to ascending > > >>> > > >>>only? > > >>> > > >>>>>Thanks, > > >>>>> > > >>>>>Jake McHenry > > >>>>>Nittany Travel MIS Coordinator http://www.nittanytravel.com > > >>>>> > > >>>>>-- > > >>>>>PHP General Mailing List (http://www.php.net/) > > >>>>>To unsubscribe, visit: http://www.php.net/unsub.php > > >>>>> > > >>>> > > >>>This page is for adding / editing / removing airline > reservations. > > > > > > > > >>>What I have done so far is when the user first gets to this > > >> > > >>specific > > >> > > >>>page, they enter their info. If they put a check in the add next > > >>>flight checkbox, then the same form comes up again, each > > >> > > >>time adding > > >> > > >>>the new info to the same array, building upon the old info. > > >> > > >>The arrays > > >> > > >>>are then displayed back into form fields where the user can > > >> > > >>edit any > > >> > > >>>info submitted. > > >>> > > >>>I'm sorting the arrays by the flight dates. Each time the > > >> > > >>user enters > > >> > > >>>a new flight, the array is sorted by date. This is where I'm > > > > > > seeing > > > > > >>>the problem. The first flight is fine, of course. The > > >> > > >>second is fine. > > >> > > >>>The third flight entered and all of the flights are now in > reverse > > > > > > > > >>>order. Then the next flight entered, they're all in the > > >> > > >>correct order, > > >> > > >>>etc, etc. > > >>> > > >>>This problem will most likely happen to my other arrays > > >> > > >>further on in > > >> > > >>>the project. > > >>> > > >>>Is there any way I can make sure that the dates are > always in the > > >>>correct order? > > >>> > > >> > > >>I
[PHP] Sort flags
Hi all, quick question. Whenever I try putting any flags with the any of the sort functions, I get this error: Warning: Wrong parameter count for natsort() in /var/www/secure/travelrequest/handler.php on line 950 My sort call looks like this: natsort($array, "SORT_STRING"); Running PHP v. 4.2.2-17.2 w/ apache v. 2.0.40-21.5 Any ideas? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] UNUSUAL PROBLEM WHEN WRITING TO THE SCREEN
> -Original Message- > From: Dale Hersh [mailto:[EMAIL PROTECTED] > Sent: Monday, December 22, 2003 8:34 PM > To: [EMAIL PROTECTED] > Subject: [PHP] UNUSUAL PROBLEM WHEN WRITING TO THE SCREEN > > > For some reason when I echo data from my database, I can't > display anything longer than 255 chars. As far as I can see, > tt has nothing to do with my database. Is there something in > the php.ini that limits how many chars you can write to the > screen per variable. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > It has to be the field length of your database. PHP has no limitations like this that I have heard of or encountered. If it's a mysql database, check to see what type of field it is: TINYTEXT, TEXT, MEDIUMTEXT, or LONGTEXT; or perhaps TINYBLOB, BLOB, MEDIUMBLOB, or LONGBLOB. The limits on the field sizes are as follows: TINYTEXT maximum length of 255 TEXT maximum length of 65535 MEDIUMTEXT maximum length of 16777215 LONGTEXT maximum length of 4294967295 Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dilema
Hi everyone. Hopefully someone can help me out. Here is what I have: The user enters traveler names on page 1. blah blah on next couple. Page 7 shows hotel information. I have the array of travelers names being outputed into a select field on the page, all fine and dandy. Where I'm having a problem is, the user can enter as many hotels as they want, meaning the list of travelers will be displayed for each hotel added. In the array being transferred into my script via POST, they are all in one array. How can I separate each hotel into it's own array, or somehow separate the traveler names in the single array? I was thinking of making a 2 dimentional array, but not sure how I could do this. I know how to create the arrays, but not sure how I can do it in my situation. If anyone needs any more info, ask away. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dilema
> -Original Message- > From: Larry Brown [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 23, 2003 9:34 AM > To: Jake McHenry > Subject: RE: [PHP] Dilema > > > Can you describe the page that has all of the components you > want to send and what you expect to recieve ie. > > dropdown(hotels) dropdown(travelers) dropdown(travelers) > dropdown(travelers) --> multiple arrays with one hotel to > many travelers each. > > or > > dropdown(travelers) dropdown(hotels) dropdown(fromdates) > dropdown(todates) -->multiple arrays with one traveler to > many hotels on dates > > can you describe the problem in this format? (--> indicating > data transfer to the recieving script) > > Larry > > -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Tuesday, December 23, 2003 1:35 AM > To: 'Php-general' > Subject: [PHP] Dilema > > > Hi everyone. Hopefully someone can help me out. > > Here is what I have: > > The user enters traveler names on page 1. blah blah on next > couple. Page 7 shows hotel information. I have the array of > travelers names being outputed into a select field on the > page, all fine and dandy. > > Where I'm having a problem is, the user can enter as many > hotels as they want, meaning the list of travelers will be > displayed for each hotel added. In the array being > transferred into my script via POST, they are all in one array. > > How can I separate each hotel into it's own array, or somehow > separate the traveler names in the single array? > > I was thinking of making a 2 dimentional array, but not sure > how I could do this. > > I know how to create the arrays, but not sure how I can do it > in my situation. > > If anyone needs any more info, ask away. > > Thanks, > > Jake McHenry > Nittany Travel MIS Coordinator > http://www.nittanytravel.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > All of the inputed data from the form are text boxes, not drop downs, except the travelers, which is in a multiple select field, sized by count($array). Each of the text input boxes return an array, so for the first hotel, I would have Array(date) array(hotel), etc. the value in each array[0] is the first hotel, array[1] is the second hotel, etc. but when it comes to the travelers, there is one array, just like the rest, but I have no idea of knowing what travelers they chose, since the user can select multiple travelers. I guess what I need is a type of delimiter to distinguish where each hotel stops, and where the new one starts, or find an alternative to the select multiple field option. Does this help? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Securing Free Scripts
> -Original Message- > From: John W. Holmes [mailto:[EMAIL PROTECTED] > Sent: Wednesday, December 31, 2003 12:39 AM > To: Ian > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Securing Free Scripts > > > Ian wrote: > > > If I am putting out a couple free scripts to the public, is > there any > > way I can make sure people dont remove the copyright? > > No. > > -- > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals - www.phparch.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Encrypt the source code. I've been looking heavily into this recently. There were some great posts on here a while back. Search the archives. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML?
Hi everyone, Can someone point me in the right direction towards creating and implementing XML with php? I've heard it can make things much easier on me, and would like more info on it. Also, if anyone has any storys from using it, might give me an idea of what I'm getting into. Is it easy to implement? Does it make things easier on me in the future? Etc.etc. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XML?
Not sure. Just asking. I haven't used it before and don't really know what it's about. I've read about it on xml.com. Either nothing sank in, or I'm just confused. It's pretty much for data organization, right? Almost all of the documentation I've read on it deals with asp. I know it is used with php as well. Guess I'm just curious what it can do, and how I could put it to use. I do a lot of importing and exporting to/from excel. I belive it could help me out here. How does php get the data from the xml docs? I guess I'm just looking for info on how to use it with php. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com > -Original Message- > From: Ray Hunter [mailto:[EMAIL PROTECTED] > Sent: Friday, January 09, 2004 9:48 AM > To: 'Php-general' > Subject: Re: [PHP] XML? > > > On Fri, 2004-01-09 at 00:30, Jake McHenry wrote: > > Can someone point me in the right direction towards creating and > > implementing XML with php? I've heard it can make things > much easier > > on me, and would like more info on it. Also, if anyone has > any storys > > from using it, might give me an idea of what I'm getting > into. Is it > > easy to implement? Does it make things easier on me in the future? > > Etc.etc. > > What do you want to do with xml? There is expat and DOM that > you can use to parse and create xml docs. What are you > looking to achieve? > > -- > Ray > > -- > 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] picturing webpage
> -Original Message- > From: David T-G [mailto:[EMAIL PROTECTED] > Sent: Friday, January 09, 2004 10:29 AM > To: PHP General list > Cc: Eli Hen > Subject: Re: [PHP] picturing webpage > > > Eli -- > > ...and then Eli Hen said... > % > % Hello All, > > Hi! > > > % > % I wanted to know if it is possible to picture a webpage via > PHP. % By "picturing" I mean that the program can generate a > picture, a view, out > > Hmmm... An interesting concept. > > > % of the page URL given. (Like sometimes you have in search > engines, that you % see the site URL and besides is the > picture of the first page of the site). > > Can you provide an example? I know I've never seen this > feature, and I'm not sure I follow what you mean. > > > % What technologies I use for that? Is it possible with PHP? > > Dunno and dunno, but let's find out :-) > > > % > % -thanks, Eli > > > HTH & HAND & Happy New Year > > :-D > -- > David T-G * There is too much animal courage in > (play) [EMAIL PROTECTED] * society and not sufficient > moral courage. > (work) [EMAIL PROTECTED] -- Mary Baker Eddy, > "Science and Health" > http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf > Qrprapl Npg! > > I've seen this many times, in spam emails sent to me, and in search engines. It takes a dynamic screen shot of the url and shows you the image. It's dynamic, I was playing with one I found, which I can't now, but I made changes to the site and it showed up on that page. I also thought it was very cool. I'll try to find the page, this was about a year ago when I found it before. Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] picturing webpage
> -Original Message- > From: Ryan A [mailto:[EMAIL PROTECTED] > Sent: Friday, January 09, 2004 12:55 PM > To: David T-G > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] picturing webpage > > > Hey, > These sons of bitches at top--sites have done this, I call > them that coz I regularly get spam from them. > > Try this URL: http://top--sites.com/update.htm?d=spamcop.com&e=p > > change spamcop to any other url... > > Cheers, > -Ryan > > > > On 1/9/2004 4:28:33 PM, David T-G ([EMAIL PROTECTED]) wrote: > > Eli -- > > > > ...and then Eli Hen said... > > % > > % Hello All, > > > > Hi! > > > > > > % > > % I wanted to know if it is possible to picture a webpage > via PHP. % > > By "picturing" I mean that the program can generate a > picture, a view, > > out > > > > Hmmm... An interesting concept. > > > > > > % of the page URL given. (Like sometimes you have in search > engines, > > that you % see the site URL and besides is the picture of the first > > page of the site). > > > > Can you provide an example? I know I've never seen this > feature, and > > I'm not sure I follow what you mean. > > > > > > % What technologies I use for that? Is it possible with PHP? > > > > Dunno and dunno, but let's find out :-) > > > > > > % > > % -thanks, Eli > > > > > > HTH & HAND & Happy New Year > > > > :-D > > -- > > David T-G * There is too much animal courage in > > (play) [EMAIL PROTECTED] * society and not sufficient moral > > courage. > > (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and > Health" > > http://justpickone.org/davidtg/ Shpx gur > Pbzzhavpngvbaf Qrprapl Npg! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This is where I saw it! They're using a script, pic.cfm on a windows box which somehow grabs a screenshot of the url. Any clues how this is done? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] picturing webpage
> -Original Message- > From: Ryan A [mailto:[EMAIL PROTECTED] > Sent: Friday, January 09, 2004 12:55 PM > To: David T-G > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] picturing webpage > > > Hey, > These sons of bitches at top--sites have done this, I call > them that coz I regularly get spam from them. > > Try this URL: http://top--sites.com/update.htm?d=spamcop.com&e=p > > change spamcop to any other url... > > Cheers, > -Ryan > > > > On 1/9/2004 4:28:33 PM, David T-G ([EMAIL PROTECTED]) wrote: > > Eli -- > > > > ...and then Eli Hen said... > > % > > % Hello All, > > > > Hi! > > > > > > % > > % I wanted to know if it is possible to picture a webpage > via PHP. % > > By "picturing" I mean that the program can generate a > picture, a view, > > out > > > > Hmmm... An interesting concept. > > > > > > % of the page URL given. (Like sometimes you have in search > engines, > > that you % see the site URL and besides is the picture of the first > > page of the site). > > > > Can you provide an example? I know I've never seen this > feature, and > > I'm not sure I follow what you mean. > > > > > > % What technologies I use for that? Is it possible with PHP? > > > > Dunno and dunno, but let's find out :-) > > > > > > % > > % -thanks, Eli > > > > > > HTH & HAND & Happy New Year > > > > :-D > > -- > > David T-G * There is too much animal courage in > > (play) [EMAIL PROTECTED] * society and not sufficient moral > > courage. > > (work) [EMAIL PROTECTED] -- Mary Baker Eddy, "Science and > Health" > > http://justpickone.org/davidtg/ Shpx gur > Pbzzhavpngvbaf Qrprapl Npg! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Getting closer.. Did a little digging.. The script goes to alexa.com, from what I see, alexa is doing the work then sending the pics out. http://pages.alexa.com/prod_serv/xml_feed.html Does this help with anyone explaining how this works? Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making coockies valid for multiple domains possible?
- Original Message - From: "Merlin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 12, 2004 3:56 AM Subject: [PHP] Making coockies valid for multiple domains possible? > Hello everybody, > > I am working on translating my site into multiple languages (i18n). Each > different language is hosted on the same server, but on a different > subdomain. > > example: > de.server.com - german > en.server.com - english > > Here comes the problem. Sessions are validated through coockies on my > site. The system checks if the coockie is valid and compares it with a > sessionid inside the database. > > It seems to me that coockies are only valid for one domain for security > reasons. > > QUESTION: > Is there a way to make that coockie valid for multiple domains? > > Thank you for any help on that. > > Regards, > > Merlin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I've read the pages, it doesn't give very good examples from what I've seen, but here is the page: http://us2.php.net/manual/en/ref.session.php#ini.session.cookie-domain Someone correct me if I'm wrong, but if you set this in your php.ini or with session_set_cookie_params() to server.com, it's valid across any sub domains, whereas if you set it to de.server.com, it would only be valid in the de.server.com sub domain. Or possibly try *server.com. I havn't played with this, since I only use cookies when I manually set them, not for sessions. Hope this helps, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] to array or not to array..
- Original Message - From: "Matt Matijevich" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, January 12, 2004 4:18 PM Subject: RE: [PHP] to array or not to array.. > [snip] > That works great, I am messing myself up, however because I am using > checkboxes so when I run this, if I have unchecked the checkbox, the > value > doesn't come through and I want an unchecked box to be 0 for example so > I > may need some javascript... > [/snip] > > Can only one option be checked per user (like can add has to either be > Y or N, it cant be both)? Is it just a yes/no question? If it is, why > not just use radio input types. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > I just picked up on this thread.. but you can just initialize the variable as 0, then if the box is checked it will have the new value. What's wrong with this? Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] permissions with bash scripts in php?
- Original Message - From: "Jas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 12, 2004 4:47 PM Subject: [PHP] permissions with bash scripts in php? > Something I have never tried... seems fairly straight-forward but I am > running into problems. > > My problem is that I need to call system to restart a daemon service > like so... > $cmd = "/path/to/shell/script/script.sh"; > system($cmd . " &> /tmp/error "); > ?> > > Script contains this command... > #!/bin/bash > /path/to/dhcpd -cf /path/to/config/dhcpd > > So far so good right? I mean it works from a command line so why not > from php. Lets check some permissions... > httpd as Apache:Apache > script.sh as Apache:Apache > > Upon inspection of 'error file' in /tmp I find this... > > unable to create icmp socket: Operation not permitted > Can't create new lease file: Permission denied > > And... > > Can't bind to dhcp address: Permission denied > Please make sure there is no other dhcp server > running and that there's no entry for dhcp or > bootp in /etc/inetd.conf. Also make sure you > are not running HP JetAdmin software, which > includes a bootp server. > > So lets set a sticky bit on the script.sh and /path/to/config/dhcpd > $> chmod 1777 /path/to/config/dhcpd > $> chmod 1777 script.sh > > So far so good but I am still recieving the same error, if anyone has > some good tips on what would be the most efficient & SECURE way of > starting this service please point me to the tutorial Thanks a ton. > Jas > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > is the apache user and group able to run the script from the command line? I know under rh9, you have to be root to start / stop / restart just about all the services. Just an idea. Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] odd and even numbers
I have a random number being generated from 1 to 501, is there an easy way for me to tell if the result is an odd or even number? Thanks, Jake
Re: [PHP] odd and even numbers SOLVED
- Original Message - From: "joel boonstra" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 3:35 PM Subject: Re: [PHP] odd and even numbers > On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote: > > function isOdd ($value) { > > return (int)$value % 2 ? true : false; > > } > > > > Returns true/false if the value is odd. Also rounds down floating point numbers given as the test value. > > No need to explicitly state "true" and "false". Just negate the result > of your modulus operator, and take advantage of the fact that "0" is > false, and "1" is true: > > function isOdd ($value) { > return !((int)$value % 2); > } > > -- > [ joel boonstra | gospelcom.net ] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Thanks everyone for the fast replys! Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can I do this? If so why wont it work
- Original Message - From: "Alex Hogan" <[EMAIL PROTECTED]> To: "PHP General list" <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 4:20 PM Subject: [PHP] Can I do this? If so why wont it work > I am wanting to read in several session values at once. > > > > This is what I have so far; > > > > $_SESSION['obj[1]'] = $_REQUEST['txtObj1']; > > $_SESSION['obj[2]'] = $_REQUEST['txtObj2']; > > $_SESSION['obj[3]'] = $_REQUEST['txtObj3']; > > $_SESSION['obj[4]'] = $_REQUEST['txtObj4']; > > $_SESSION['obj[5]'] = $_REQUEST['txtObj5']; > > > > $i = 1; > > while ($i <= 5) { > > $obj_ar[$i] = $_SESSION['obj[$i]']$i++; > > } > > > > I keep getting this error; > > Parse error: parse error, unexpected T_VARIABLE in mypage.php on line 24 > > > > Where am I making the mistake? > > > > alex hogan > > > > > > ** > The contents of this e-mail and any files transmitted with it are > confidential and intended solely for the use of the individual or > entity to whom it is addressed. The views stated herein do not > necessarily represent the view of the company. If you are not the > intended recipient of this e-mail you may not copy, forward, > disclose, or otherwise use it or any part of it in any form > whatsoever. If you have received this e-mail in error please > e-mail the sender. > ** > > > What is on line 24? Try this: while ($i <= 5) { $obj_ar[$i] = $_SESSION['obj[$i]']; $i++; } Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odd and even numbers
- Original Message - From: "joel boonstra" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 3:35 PM Subject: Re: [PHP] odd and even numbers > On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote: > > function isOdd ($value) { > > return (int)$value % 2 ? true : false; > > } > > > > Returns true/false if the value is odd. Also rounds down floating point numbers given as the test value. > > No need to explicitly state "true" and "false". Just negate the result > of your modulus operator, and take advantage of the fact that "0" is > false, and "1" is true: > > function isOdd ($value) { > return !((int)$value % 2); > } > > -- > [ joel boonstra | gospelcom.net ] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This worked.. somewhat.. here is what I want to do though. I have two people checking the same email address. I want to break up the emails 50/50 to each person. What values can I put into the random number generator so that I can get closer to 50/50. I just set up a test page with: $rand = rand(1, 501); echo $rand; if ($rand % 2 == 0) echo "even"; else echo "odd"; and I'm getting a lot more evens than odds, so the one person would get more emails than the other. Is there any substitution to rand that I could use to get one message to go to one person, then the next to the other? I'd like it to be as close to 50/50 as possible. any questions, let me know Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odd and even numbers
- Original Message - From: "Katie Dewees" <[EMAIL PROTECTED]> To: "Jake McHenry" <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 4:44 PM Subject: RE: [PHP] odd and even numbers > Can you just set a value somewhere (in a flat file, or a database) to 1 or > 2. 1 can represent person number 1, 2 person number 2. Check the value every > time you deliver an e-mail to see who gets it, and then switch it to the > other one. > > Katie Dewees > Web Developer > E-mail: [EMAIL PROTECTED] > > -Original Message- > From: Jake McHenry [mailto:[EMAIL PROTECTED] > Sent: Friday, January 16, 2004 3:42 PM > To: joel boonstra > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] odd and even numbers > > > - Original Message - > From: "joel boonstra" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, January 16, 2004 3:35 PM > Subject: Re: [PHP] odd and even numbers > > > > On Fri, Jan 16, 2004 at 02:30:59PM -0600, Jeremy wrote: > > > function isOdd ($value) { > > > return (int)$value % 2 ? true : false; > > > } > > > > > > Returns true/false if the value is odd. Also rounds down floating point > numbers given as the test value. > > > > No need to explicitly state "true" and "false". Just negate the result > > of your modulus operator, and take advantage of the fact that "0" is > > false, and "1" is true: > > > > function isOdd ($value) { > > return !((int)$value % 2); > > } > > > > -- > > [ joel boonstra | gospelcom.net ] > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > This worked.. somewhat.. here is what I want to do though. > > I have two people checking the same email address. I want to break up the > emails 50/50 to each person. What values can I put into the random number > generator so that I can get closer to 50/50. I just set up a test page with: > > $rand = rand(1, 501); > > echo $rand; > > if ($rand % 2 == 0) > echo "even"; > else > echo "odd"; > > > and I'm getting a lot more evens than odds, so the one person would get more > emails than the other. Is there any substitution to rand that I could use to > get one message to go to one person, then the next to the other? I'd like it > to be as close to 50/50 as possible. > > any questions, let me know > > Thanks, > Jake > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I could, but I didn't really want to. I just wanted a quick fix... I was going to do that before, just wanted to see if anyone knew of another route. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odd and even numbers
- Original Message - From: "joel boonstra" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 16, 2004 4:54 PM Subject: Re: [PHP] odd and even numbers > Jake, > > > This worked.. somewhat.. here is what I want to do though. > > > > I have two people checking the same email address. I want to break up the > > emails 50/50 to each person. What values can I put into the random number > > generator so that I can get closer to 50/50. I just set up a test page with: > > > > $rand = rand(1, 501); > > > > echo $rand; > > > > if ($rand % 2 == 0) > > echo "even"; > > else > > echo "odd"; > > > > > > and I'm getting a lot more evens than odds, so the one person would get more > > emails than the other. Is there any substitution to rand that I could use to > > get one message to go to one person, then the next to the other? I'd like it > > to be as close to 50/50 as possible. > > Is there any way you can save state? That is, can you keep track of who > got the last one, and use that to determine who should get the next one? > > Otherwise, why not just rand() between 1 and 2? rand(1,2) will, on > average, give you as many 1s as 2s (like flipping a coin). There will > likely be runs of 1 or 2, but over time, doing rand() with two possible > values versus rand() with 501 values will not be significantly > different. > > In fact, since there is one more odd than even between 1 and 501 > (inclusive), you will be getting slightly more odds than evens with that > range than you will with a range of 1 and 2. > > Also, which PHP version are you using? If before 4.2.0, you should seed > the random number generator with srand(). If you are using 4.2.0 or > greater, and still seeing non-random behavior, I don't really have an > answer. > > -- > [ joel boonstra | gospelcom.net ] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > version 4.2.2 Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stdin/stderr
Is there a way to execute a system command and get both stdin and stderr into separate variables? -- 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]