PHP Question

Permabanned
Joined
22 Apr 2007
Posts
1,805
Here's my code

Code:
<?php
} else {

$name = stripslashes(mysql_real_escape_string($_POST['name']));
$address = stripslashes(mysql_real_escape_string($_POST['address']));
$postcode = stripslashes(mysql_real_escape_string($_POST['postcode']));
$telephone = stripslashes(mysql_real_escape_string($_POST['telephone']));
$contact = stripslashes(mysql_real_escape_string($_POST['contact']));

mysql_query("INSERT INTO `site` (name, address, postcode, telephone, contact) VALUES ('$name','$address','$postcode','$telephone','$contact')");
echo "Thank you. The site has been added to the database";
}


mysql_close();

?>

All this does is take input from the form and shove it in to a MySQL database.

problem is, the address is a text area and I use 'return' for a new line. Now within MySQL it adds 'rn' to the end so when I display the results on a different page I get 'rn' showing.

Not sure how to get around this apart from str_replace.

Also, when it displays the results it just gives the address in one long line. Is there a way to break it up into the correct format?

123 fake street
fake town
fake city

as opposed to 123 fake streetrnfaketownrnfakecityrn

Ta
 
Thanks, I've sorted it now though. Well, as in, it works....

Code:
<?php

While ($row = mysql_fetch_array($results)) { 
//inputs the data into the table
		$id = stripslashes($row['id']);
		$name = stripslashes($row['name']);
		$address = stripslashes($row['address']);
		$address = str_replace("rn","<br>",$address);
		$postcode = stripslashes($row['postcode']);		
		$telephone = stripslashes($row['telephone']);
		$contact = stripslashes($row['contact']);

?>
<p><strong>Site Name:</strong></p>
<strong><?php echo $name; ?></strong><br /><?php echo $address; ?><br /><?php echo $postcode; ?>
<p><strong>Contact:</strong>&nbsp;<?php echo $contact; ?></p>
<p><strong>Telephone:</strong>&nbsp;<?php echo $telephone; ?></p>
 
Back
Top Bottom