NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Explain this please

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-28-2005, 07:10 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes

Explain this please


Code:
<?php
$line = date("m.d.y") . "|" . $HTTP_POST_VARS['name'];
$line .= "|" . $HTTP_POST_VARS['news'];
$line = str_replace("\r\n","<BR>",$line);
$line .= "\r\n";
?>
Okay, I am reading a tutorial and i really dont get this part and they didnt explain it either
????: NamePros.com http://www.namepros.com/programming/110631-explain-this-please.html

y is there 4 $line variables? i thought u could only have one
and y is there a "." before the "="

and whats "/r/n" etc...
unknowngiver is offline  
Old 07-28-2005, 07:23 AM   #2 (permalink)
Senior Member
 
luxinterior's Avatar
Join Date: Jul 2004
Location: Kizmiaz
Posts: 1,091
luxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of light
 



The . is appending the second part of the string to the first (which is happening twice in your example). And /r/n means line feed and carriage return (basically a new line). In this example it's replacing the line feed characters with the html equivolent '<br>'.

Lux
luxinterior is offline  
Old 07-28-2005, 07:27 AM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
still dont get it
can u explain the whole code..from start to the end and wt it means {wt its suppose to do}
unknowngiver is offline  
Old 07-28-2005, 09:28 AM   #4 (permalink)
NamePros Member
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 127
eagle12 will become famous soon enougheagle12 will become famous soon enough
 



PHP Code:

<?php
//This line is appending the date with a user entered named
//i.e.: 07.28.2005|Kris
????: NamePros.com http://www.namepros.com/showthread.php?t=110631
$line date("m.d.y") . "|" $HTTP_POST_VARS['name'];
//This line appends the previous line with the user entered news
//the line now looks like this: 
//07.28.2005|Kris|news the user entered.
//This is another line the user entered for the news.
$line .= "|" $HTTP_POST_VARS['news'];
//This line checks to see if the user pressed enter, and replaces it with <br>
//The line now looks like this:
//07.28.2005|Kris|news the user entered.<br>This is another line the user entered for the news.
$line str_replace("\r\n","<BR>",$line);
/*This last line adds a new line character to the end of the string so that it is easier to read. Moves it down the next line in the source, but not on the page.*/
$line .= "\r\n";
?>

Hope this helps.
eagle12 is offline  
Old 07-28-2005, 10:43 AM THREAD STARTER               #5 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
okay great thanks
unknowngiver is offline  
Old 07-29-2005, 06:24 PM THREAD STARTER               #6 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
okay i read it again and again
but i stil dont get this part


$line = str_replace("\r\n","<BR>",$line);

wt is \r\n ?
thts the code to see if someone pressed ENTER?
unknowngiver is offline  
Old 07-29-2005, 06:32 PM   #7 (permalink)
Senior Member
 
luxinterior's Avatar
Join Date: Jul 2004
Location: Kizmiaz
Posts: 1,091
luxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of light
 



The str_replace is a function. It replaces the first part with the second part found in the third part so...

str_replace(find_this, replace_with_this, in_this).

You might want to take a look at www.php.net and find some basic tutorials on Google.

BTW I think eagle12 went above and beyond the call of duty with his explanation. I hope he gets some rep points for it

Good luck

Lux
luxinterior is offline  
Old 07-29-2005, 07:03 PM   #8 (permalink)
Senior Member
 
harkster's Avatar
Join Date: Mar 2004
Location: Red State
Posts: 1,605
harkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to behold
 



Spiffy little snippit.

The \r\n -- in linux the \ is an escape character that says there is something special about the next character.

The \r = carriage return (cr). on most systems it tlaces the cursor at the beginning of the current line but on some systems it is a cr + lf and can be frustrating when trying to build a mime email.

The \n is a new line (lf). The crusor is placed on the next line at the end of the previous line.

Together they place the cursor at the far left of the next line.

I am not an expert but got this pounded in while writing my FormMail script.
harkster is offline  
Old 07-29-2005, 07:22 PM THREAD STARTER               #9 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Thanks guyz
rep added

here is a lil bit of more code tht i need help with :$

Code:
foreach($data as $element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b><BR><BR>";
}
k i THINK tht
????: NamePros.com http://www.namepros.com/showthread.php?t=110631
foreach($data as $element)
converts all the stuff from $data to $element? am i right
unknowngiver is offline  
Old 07-29-2005, 10:32 PM   #10 (permalink)
Senior Member
 
harkster's Avatar
Join Date: Mar 2004
Location: Red State
Posts: 1,605
harkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to beholdharkster is a splendid one to behold
 



Originally Posted by unknowngiver
Thanks guyz
rep added

here is a lil bit of more code tht i need help with :$

Code:
foreach($data as $element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b><BR><BR>";
}
k i THINK tht
????: NamePros.com http://www.namepros.com/showthread.php?t=110631
foreach($data as $element)
converts all the stuff from $data to $element? am i right
I hope this is right.
Data is an array of elements ($elements) where each element is a string like xxx|yyy|zzz. Foreach will loop through all elements.
$element = trim($element); // strip any leading or trailing blanks
$pieces = explode("|", $element); //Break the string $element into pieces defined by | and create an array of $pieces.
the echo prints the pieces in the desired order for each element of $data. In this case zzz Posted by yyy on xxx

Help??
harkster is offline  
Old 07-31-2005, 11:46 AM THREAD STARTER               #11 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
yup tht makes sense thanks
unknowngiver is offline  
Old 08-02-2005, 11:16 AM THREAD STARTER               #12 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
okay a little help now

$password='zubair'
if($HTTP_POST_VARS['submit']) {
if($HTTP_POST_VARS['password'] == '$password') {

here is the code
now what i want is tht the script should check if the password is what i defined in "$password" .... but it gives me this error



Parse error: parse error, unexpected T_IF in /home/zubair/public_html/news/addnews.php on line 13
unknowngiver is offline  
Old 08-02-2005, 12:37 PM   #13 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
You want to make sure that $HTTP_POST_VARS['password'] is equal to $password?

Here:

Code:
if (isset($HTTP_POST_VARS['submit]))
{
if ($HTTP_POST_VARS['password'] != $password) {
echo('The passwords do not match.');
}
}
That what you mean?
mholt is offline  
Old 08-02-2005, 08:25 PM THREAD STARTER               #14 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Dont think so
????: NamePros.com http://www.namepros.com/showthread.php?t=110631
here is the full code

Code:
$password='zubair'
if($HTTP_POST_VARS['submit']) {
    if($HTTP_POST_VARS['password'] == '$password') {
        if(!$HTTP_POST_VARS['name']) {
            echo "You must enter a name";
            exit;
        }
        if(!$HTTP_POST_VARS['news']) {
            echo "You must enter some news";
            exit;
        }
        if(strstr($HTTP_POST_VARS['name'],"|")) {
            echo "Name cannot contain the pipe symbol - |";
            exit;
        }
        if(strstr($HTTP_POST_VARS['news'],"|")) {
            echo "News cannot contain the pipe symbol - |";
            exit;
        }
        $fp = fopen('news.txt','a');
        if(!$fp) {
            echo "Error opening file!";
            exit;
        }
        $line = date("m.d.y") . "|" . $HTTP_POST_VARS['name'];
        $line .= "|" . $HTTP_POST_VARS['news'];
        $line = str_replace("\r\n","<BR>",$line);
        $line .= "\r\n";
        fwrite($fp, $line);
        if(!fclose($fp)) {
            echo "Error closing file!";
            exit;
        }
    } else {
        echo "Bad Password";
    }
}

?>
unknowngiver is offline  
Old 08-02-2005, 08:31 PM   #15 (permalink)
Senior Member
 
luxinterior's Avatar
Join Date: Jul 2004
Location: Kizmiaz
Posts: 1,091
luxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of lightluxinterior is a glorious beacon of light
 



Your've got the variable $password in single quotation marks making it a string literal as in no longer a variable but the string $password. Remove them and it should be ok.

Lux
luxinterior is offline  
Old 08-03-2005, 10:31 AM THREAD STARTER               #16 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
Still the same
here is the code now

Code:
$password='zubair'
if($HTTP_POST_VARS['submit']) {
    if($HTTP_POST_VARS['password'] == $password) {
        if(!$HTTP_POST_VARS['name']) {
            echo "You must enter a name";
            exit;
        }
        if(!$HTTP_POST_VARS['news']) {
            echo "You must enter some news";
            exit;
        }
unknowngiver is offline  
Old 08-05-2005, 09:23 AM THREAD STARTER               #17 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes
anyone wana give it a try please
unknowngiver is offline  
Old 08-05-2005, 11:24 AM   #18 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
You have to close two more curly brackets at the end.
mholt is offline  
Old 08-05-2005, 11:45 AM   #19 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
 


Cancer Survivorship Save a Life
you missing a semi colon at the end of the first line
__________________
Webmaster Words
Amnezia is offline  
Old 08-05-2005, 12:14 PM   #20 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Yes!!! Amnezia wins the prize! ^_^ (Lol my post was just a test to see if it'd distract you )
mholt is offline  
Old 08-05-2005, 12:51 PM   #21 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Originally Posted by unknowngiver
Still the same
here is the code now

Code:
$password='zubair'
if($HTTP_POST_VARS['submit']) {
    if($HTTP_POST_VARS['password'] == $password) {
        if(!$HTTP_POST_VARS['name']) {
            echo "You must enter a name";
            exit;
        }
        if(!$HTTP_POST_VARS['news']) {
            echo "You must enter some news";
            exit;
        }
PHP Code:
$password='zubair';
if(
$HTTP_POST_VARS['submit']) {
    if(
$HTTP_POST_VARS['password'] == $password) {
        if(!
$HTTP_POST_VARS['name']) {
            echo 
"You must enter a name";
            exit();
        }
        if(!
$HTTP_POST_VARS['news']) {
????: NamePros.com http://www.namepros.com/showthread.php?t=110631
            echo 
"You must enter some news";
            exit();
        }

Eric is offline  
Old 08-05-2005, 10:11 PM   #22 (permalink)
Account Closed
 
Refrozen's Avatar
Join Date: Jun 2005
Posts: 745
Refrozen will become famous soon enoughRefrozen will become famous soon enough
 



. means append
\r\n means Winodws newline
Refrozen is offline  
Old 08-07-2005, 09:34 PM THREAD STARTER               #23 (permalink)
Senior Member
Join Date: May 2005
Location: Ontario Canada
Posts: 3,088
unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold
 


Diabetes

Help


didnt work guys
unknowngiver is offline  
Old 08-07-2005, 10:10 PM   #24 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
nvmd

Just changed a couple of things.. Modified from my original post.
PHP Code:
<?php
$password 
'zubair';
if(
$HTTP_POST_VARS['submit']) {
    if(
$HTTP_POST_VARS['password'] == $password) {
        if(!
$HTTP_POST_VARS['name']) {
            echo 
"You must enter a name";
            exit;
        }
        if(!
$HTTP_POST_VARS['news']) {
            echo 
"You must enter some news";
            exit;
        }
}
?>
Eric is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Things you can't explain? UFOs? Ghosts? vip-ip The Break Room 20 07-24-2005 03:51 AM
can someone explain me ? saigon Domain Newbies 3 06-16-2005 05:32 AM
Domain Sponsors? Someone explain. Eric Domain Newbies 16 04-04-2005 02:14 AM
Please Explain To Me What Parking A Domain Is!! entrep Domain Newbies 3 11-12-2004 02:08 AM
Some things you just can't explain cityit The Break Room 3 11-02-2004 01:07 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:12 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger