[wdvltalk] Re: PHP question
- Original Message - From: "William Stewart" > I have a variable that I want to define as an include of > a .txt file. In other words, I want something like: > > $subcontent = "include("text.txt")"; Simplest is just to put the whole variable definition into the include file: where the contents of vardef.txt is the one line: But if you only want the include file to contain the value to be assigned, then you have to get php to open the text file for input, and read a line from it into the variable: If vardef.txt contained the one line "Happy Birthday" then $subcontent would now have that as its value. The WDVL Discussion List from WDVL.COM To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP question concerning folders
William Stewart wrote: I am trying to dynamically include a file based on what folder the file that is calling it is in. For instance: The file www.whatever.com/abc/index.php would include the file: www.whatever.com/template/abc.php and the file www.whatever.com/xyz/index.php would include the file: www.whatever.com/template/xyz.php Does this make sense, oh gurus? I would appreciate your help! Sure that makes sense. You want the name of script's parent directory. You will use that to build the path to the include file. Here's test script: // get the full url to the script $script_name = $_SERVER['SCRIPT_NAME']; echo "script_name -> $script_name "; // split the url into an array of it's parts $parts = explode('/', $script_name); // the second to last member of the $parts array is the parent directory $parent_dir = $parts[count($parts)-2]; echo "parent directory -> $parent_dir "; ?> There are other ways to do this but this will work. You might want to add some error checking and make sure $parts has at least two elements. Sheila -- Sheila Fenelon http://www.shefen.com/ The WDVL Discussion List from WDVL.COM To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
- Original Message - From: "Anitha Paruchuri" > what suprises me is that all the while it did not > give any problem until i tried entering a > password starting with numbers. Well, look at it this way. By comparing $password with a number you are forcing it to evaluate to a numeric value. The numeric value of "123abc" is 123, which is greater than 16 so gives you an error. "abc123" evaluates to 0, which is less than 16, so no error. To prove this to yourself try: print "Numeric value of $password is " . 1 * $password . ""; Bj • The WDVL Discussion List from WDVL.COM • To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
Thanks so much...Huh sometimes you feel like such a stupid to do these small errors. But Thanks everyone it is definately the ')' but what suprises me is that all the while it did not give any problem until i tried entering a password starting with numbers. I think I must have entered atleast 10 records but it worked fine. Can anyone think of any explanation for this? Thanks again. Anitha >>> [EMAIL PROTECTED] 1/13/2004 1:25:09 PM >>> Anitha Paruchuri wrote: > The code where it does this is here-- > > if (strlen($cpassword)<5 || strlen($cpassword >16)) A misplaced ) You probably want this: if (strlen($cpassword)<5 || strlen($cpassword) >16) Sheila * The WDVL Discussion List from WDVL.COM * To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with. • The WDVL Discussion List from WDVL.COM • To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
Anitha Paruchuri wrote: The code where it does this is here-- if (strlen($cpassword)<5 || strlen($cpassword >16)) A misplaced ) You probably want this: if (strlen($cpassword)<5 || strlen($cpassword) >16) Sheila The WDVL Discussion List from WDVL.COM To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
Complete newbie guess Should if (strlen($cpassword)<5 || strlen($cpassword >16)) not be if (strlen($cpassword)<5 || strlen($cpassword)>16) ? "Anitha Paruchuri" To: [EMAIL PROTECTED] <[EMAIL PROTECTED] cc: .niu.edu> Subject: [wdvltalk] Re: PHP Question 13/01/2004 19:10 Please respond to wdvltalk The code where it does this is here-- if (strlen($cpassword)<5 || strlen($cpassword >16)) { echo "Your password must be between 5 and 16 characters. Please go back and try again."; exit; // check password length is ok } I tried printing the values of strlen before the if statement and it does give me 6 for the length of 123abc but it also gives me the error message saying "Your password must be." I now realize that this is not the strlen problem. But What else could be going wrong here?. I am checking that the user password is between 5 and 16 characters in length. In this example if it is 6 it shouldn't be printing the message, but it does. Anitha >>> [EMAIL PROTECTED] 1/13/2004 11:50:16 AM >>> Anitha Paruchuri wrote: > Hi, > I am trying to check the length of the password entered by the user > using strlen($password). It works fine when say I enter a password as > 'abc123' but if I entered '123abc' it somehow doesn't work fine. Am I > missing something here? Should the $password or the variable for the > function strlen() cannot start with a number?? > Strings can be all digits. Do you have a sample of the code that doesn't work? I've tested this and can't recreate the problem. Here's my test script: http://demo.fenelon.us/testCode/strlen_test.php?test3=43434 Change the value for test3 to try different strings. Sheila * The WDVL Discussion List from WDVL.COM * To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with. ? The WDVL Discussion List from WDVL.COM ? To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with. john.f.hughes Goodbody Stockbrokers Private Clients Ballsbridge Park + 353 1 6416048 This information is confidential and may be privi
[wdvltalk] Re: PHP Question
The code where it does this is here-- if (strlen($cpassword)<5 || strlen($cpassword >16)) { echo "Your password must be between 5 and 16 characters. Please go back and try again."; exit; // check password length is ok } I tried printing the values of strlen before the if statement and it does give me 6 for the length of 123abc but it also gives me the error message saying "Your password must be." I now realize that this is not the strlen problem. But What else could be going wrong here?. I am checking that the user password is between 5 and 16 characters in length. In this example if it is 6 it shouldn't be printing the message, but it does. Anitha >>> [EMAIL PROTECTED] 1/13/2004 11:50:16 AM >>> Anitha Paruchuri wrote: > Hi, > I am trying to check the length of the password entered by the user > using strlen($password). It works fine when say I enter a password as > 'abc123' but if I entered '123abc' it somehow doesn't work fine. Am I > missing something here? Should the $password or the variable for the > function strlen() cannot start with a number?? > Strings can be all digits. Do you have a sample of the code that doesn't work? I've tested this and can't recreate the problem. Here's my test script: http://demo.fenelon.us/testCode/strlen_test.php?test3=43434 Change the value for test3 to try different strings. Sheila * The WDVL Discussion List from WDVL.COM * To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with. • The WDVL Discussion List from WDVL.COM • To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
- Original Message - From: "Anitha Paruchuri" > I am trying to check the length of the password entered > by the user using strlen($password). It works fine when > say I enter a password as 'abc123' but if I entered > '123abc' it somehow doesn't work fine. Am I missing > something here? Either string should be treated the same - try putting in the code: print "Length of abc123: "; ...then the same for 123abc, and you should see them both print on the page as 6. If you are getting a different result when dealing with form fields, then something is going wrong in the process. First try using $HTTP_POST_VARS["password"] instead of $password, to make sure you are actually looking at the value passed from the form. Bj The WDVL Discussion List from WDVL.COM To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.
[wdvltalk] Re: PHP Question
Anitha Paruchuri wrote: Hi, I am trying to check the length of the password entered by the user using strlen($password). It works fine when say I enter a password as 'abc123' but if I entered '123abc' it somehow doesn't work fine. Am I missing something here? Should the $password or the variable for the function strlen() cannot start with a number?? Strings can be all digits. Do you have a sample of the code that doesn't work? I've tested this and can't recreate the problem. Here's my test script: http://demo.fenelon.us/testCode/strlen_test.php?test3=43434 Change the value for test3 to try different strings. Sheila The WDVL Discussion List from WDVL.COM To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED] To set a personal password send an email to [EMAIL PROTECTED] with the words: "set WDVLTALK pw=yourpassword" in the body of the email. To change subscription settings to the wdvltalk digest version: http://wdvl.internet.com/WDVL/Forum/#sub http://www.wdvl.com ___ You are currently subscribed to wdvltalk as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] To unsubscribe via postal mail, please contact us at: Jupitermedia Corp. Attn: Discussion List Management 475 Park Avenue South New York, NY 10016 Please include the email address which you have been contacted with.