Jump to content

Couple string related questions


python72

Recommended Posts

I am trying to store website address in a variable but when I do so the dots in the address are missing. I guess it takes it as string concatenation, for example:

$address='www.lottocomplete.com';

will actually give me: wwwlottocompletecom

How can I make sure these dots will be preserved?

 

I am also trying to store email address in a variable but I get error, something about @ symbol being in wrong spot, wonder how this can be resolved as well.

 

One more questions relates to the new line issue that I have when I concatenate string, for example if I do the following:

 

$string = "1\n";
$string .= "2\n";
$string .= "3\n";

 

I would think that each number would be printed on new line but instead it shows up as: 123

 

What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/227429-couple-string-related-questions/
Share on other sites

For the first issue, there's no reason for that to happen. Can you post the actual problematic code?

 

The second issue, if you look at the html source, those will be on new lines. To get it to render in the browser on new lines, you'd need to use nl2br.

Here is the code, when I receive the email the dots in the website address are missing.

		if(@mysql_query($sql)){
		$yoursite = 'www.lottocomplete.com';
		$webmaster = 'Webmaster';
		$youremail = '[email protected]';

		$subject = "You have successfully registered at $yoursite...";
		$message = "Dear $previousfname, you are now registered at our web site.  
    			To login, simply go to our web page and enter in the following details in the login form:
    			Username: $previoususername
    			Password: $previouspassword
    
    			Please print this information out and store it for future reference.
    
    			Thanks,
    			$webmaster";
    
		mail($previousemail, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());

		//$urlname = urlencode($$_POST['username']);
            header("location: www.lottocomplete.com/registered/thankyou.php");
	}
	else{
		$errormessage = "Your information was not entered into our database.\n
				    Please check your information and try again.";
	}

When I use the following:

 

echo "$yoursite";

 

The address is displayed properly with dots in it, I guess it has something to do with the emailing, do you have any idea what can cause it?

 

When I try to save email addres in variable I get error message related to @ symbol,  how should this be done, I am trying to do the following:

$email='[email protected]';

Pikachu,

Not sure what was the problem but now everything is working ok. The dots show in my website address and it takes the email without a hitch, I guess there is something else causing erratic errors, will have to investigate that before I progress any further.

Thanks a lot for all your help.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.