Using HTML area to update database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Using HTML area to update database

Post by katd »

Hi
I don't know if anyone can help but I put HTMLarea onto my textarea's so that users can format the look of the content. When the user enters a new page uses the HTMLarea the content goes into the database fine but if they then try and update that same area the text adds little characters like ?????? and spaces between words. If they switch to the code view and update the text it goes into the database fine. Has anyone got any ideas. I'm using the same page for adding a page and updating it.

Thanks :)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Do you mean <area rows="50" cols="100"></area> ?

Please post code.
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Post by katd »

I'm using HTMLarea so the only thing telling the textarea it's a HTMLarea is the id. But here's the code i'm using to add/update my database.

Code: Select all

<?php # Script - add_home.php
// This page allows the administrator to add and update a home (product).

//Require authentication.
require_once ('../../authentication.php');

$page_title = 'Staffordshire Open Studios - Add/Edit an Open Studio Artist';
include_once ('../includes/header_admin.html');

//Check for authorization.
if (!$authorized) {
	echo '<p><font color="red">Please enter a valid username and password! Click <a href="administration.php">here</a> to try again!</font></p>';
} else {

require_once ('../../mysql_connect.php'); // conect to the database.

function get_home_record($studioartist_id)
{
  $query = "select * from openstudiosartists where studioartist_id = '$studioartist_id'";
  if (!$result = mysql_query($query))
  {
        die("There was a problem with query::$query - " . mysql_error());
  }
  return(mysql_fetch_array($result));
}


/* 
function query_select($name, $query, $default='')
{
  $result = mysql_query($query);

  if (!$result)
    return('<select name="category" id="category">
    <option value="New Home" selected >New Home</option>
    <option value="Used Home">Used Home</option>
  </select>');

  $select  = "<SELECT NAME=\"$name\">";
  $select .= "<OPTION VALUE=\"\">-- Choose --</OPTION>";

  for ($i=0; $i < mysql_numrows($result); $i++) {
    $opt_code = mysql_result($result, $i, 0);

    $select .= "<OPTION VALUE=\"$opt_code\"";
    if ($opt_code == $default) {
      $select .= ' SELECTED';
    }
    $select .=  ">[$opt_code] $opt_desc</OPTION>";
  }
  $select .= "</SELECT>\n";

  return($select);

} 

*/



if (isset($HTTP_GET_VARS['studioartist_id']))
        $sa = get_home_record($HTTP_GET_VARS['studioartist_id']);

if (isset($_POST['submit'])) { // Handle the form.
        // Validate the name, description, craft, area, address, tel, fax, email, website, mobile, opening, car parking, demonstrations, disabled access, toilets, disabled toilets, refreshments, gallery and schools liaison.
        //Check for a name.
        if (!empty($_POST['name'])) {
                        $n = escape_data($_POST['name']);
        } else {
                        $n = FALSE;
                        echo '<p><font color="red">Please enter the artists name!</font></p>';
        }
   
   		// Check for a username.
		if (eregi ("^[[]_]{4,40}$", stripslashes(trim($_POST['username'])))) {
			$u = escape_data($_POST['username']);
		} else {
			$u = FALSE;
			echo '<p><font color="red">Please enter a valid username!</font></p>';
		}
		
		// Check for a password and match against the confirmed password.
			if (eregi ("^[[]]{4,30}$", stripslashes(trim($_POST['password1'])))) {
				if ($_POST['password1'] == $_POST['password2']) {
					$p = escape_data($_POST['password1']);
				} else {
					$p = FALSE;
					echo '<p><font color="red">Your password did not match the confirmed password!</font></p>';
				}
			} else {
				$p = '';
		}

           // Check for description
        if(!empty($_POST['description'])) {
                        $d = escape_data($_POST['description']);
        } else {
                        $d = FALSE;
                        echo '<p><font color="red">Please enter a description!</font></p>';
        }
   
        // Check for area
        if(!empty($_POST['location'])) {
                        $l = escape_data($_POST['location']);
        } else {
                        $l = '';
        }
   
        // Check for address
        if(!empty($_POST['address'])) {
                        $a = escape_data($_POST['address']);
        } else {
                        $a = FALSE;
                        echo '<p><font color="red">Please enter an address</font></p>';
        }
   
        // Check for tel
        if(!empty($_POST['tel'])) {
                        $t = escape_data($_POST['tel']);
        } else {
                        $t = '';
        }
   
   		// Check for home tel
        if(!empty($_POST['home_tel'])) {
                        $ht = escape_data($_POST['home_tel']);
        } else {
                        $ht = '';
        }
   
        // Check for a fax
        if(!empty($_POST['fax'])) {
                        $f = escape_data($_POST['fax']);
        } else {
                        $f = '';
        }
   
        // Check for an email (not required).
        if (eregi ("^[[]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) {
                        $e = escape_data($_POST['email']);
        } else {
                        $e = '';
        }
		
		// Check for a website (not required).
        if (!empty($_POST['website'])) {
                        $w = escape_data($_POST['website']);
        } else {
                        $w = '';
        }

		// Check for a website (not required).
        if (!empty($_POST['website2'])) {
                        $wtw = escape_data($_POST['website2']);
        } else {
                        $wtw = '';
        }

// Check for a website (not required).
        if (!empty($_POST['website3'])) {
                        $wth = escape_data($_POST['website3']);
        } else {
                        $wth = '';
        }
		
		// Check for a website (not required).
        if (!empty($_POST['website4'])) {
                        $wf = escape_data($_POST['website4']);
        } else {
                        $wf = '';
        }
		
		// Check for a mobile (not required).
        if (!empty($_POST['mobile'])) {
                        $m = escape_data($_POST['mobile']);
        } else {
                        $m = '';
        }

		// Check for opening times (not required).
        if (!empty($_POST['open'])) {
                        $o = escape_data($_POST['open']);
        } else {
                        $o = '';
        }

		// Check for directions (not required).
        if (!empty($_POST['directions'])) {
                        $di = escape_data($_POST['directions']);
        } else {
                        $di = '';
        }

		// Check for car parking (not required).
        if (!empty($_POST['carparking'])) {
                        $cp = escape_data($_POST['carparking']);
        } else {
                        $cp = '';
        }

		// Check for demonstrations (not required).
        if (!empty($_POST['demonstrations'])) {
                        $dm = escape_data($_POST['demonstrations']);
        } else {
                        $dm = '';
        }

		// Check for disabled access (not required).
        if (!empty($_POST['disabledaccess'])) {
                        $da = escape_data($_POST['disabledaccess']);
        } else {
                        $da = '';
        }

		// Check for toilets (not required).
        if (!empty($_POST['toilets'])) {
                        $tl = escape_data($_POST['toilets']);
        } else {
                        $tl = '';
        }

		// Check for disabled toilets (not required).
        if (!empty($_POST['disabledtoilets'])) {
                        $dt = escape_data($_POST['disabledtoilets']);
        } else {
                        $dt = '';
        }

		// Check for refreshments (not required).
        if (!empty($_POST['refreshments'])) {
                        $r = escape_data($_POST['refreshments']);
        } else {
                        $r = '';
        }

		// Check for a gallery (not required).
        if (!empty($_POST['gallery'])) {
                        $g = escape_data($_POST['gallery']);
        } else {
                        $g = '';
        }

		// Check for school liaison (not required).
        if (!empty($_POST['schoolliaison'])) {
                        $sl = escape_data($_POST['schoolliaison']);
        } else {
                        $sl = '';
        }


				$query = "SELECT studioartist_id FROM openstudiosartists WHERE username='$u' AND studioartist_id != '$studioartist_id'";		
				$result = @mysql_query ($query);
		
				if (mysql_num_rows($result) == 0) { // Available.

        if (isset($HTTP_POST_VARS['studioartist_id']) && $HTTP_POST_VARS['studioartist_id']!='')
        { // It's an update			
							  $studioartist_id = $HTTP_POST_VARS['studioartist_id'];
				              $query = "update openstudiosartists set
                                        name = '$n',
										username = '$u',
                                        description = '$d',
                                        location = '$l',
                                        address = '$a',
                                        tel = '$t',
										home_tel = '$ht',
                                        fax = '$f',
										mobile = '$m',
                                        email = '$e',
										website = '$w',
										website2 = '$wtw',
										website3 = '$wth',
										website4 = '$wf',
										open = '$o',
										directions = '$di',
										carparking = '$cp',
										demonstrations = '$dm',
										disabledaccess = '$da',
										toilets = '$tl',
										disabledtoilets = '$dt',
										refreshments = '$r',
										gallery = '$g',
										schoolliaison = '$sl'
                                        where studioartist_id = $studioartist_id";  
        } else {   // It's a new story
                if ($n && $d && $a && $u && $p) {
                        // Add the home to the database.
                        $query = "INSERT INTO openstudiosartists(name, description, location, address, tel, home_tel, fax, mobile, email, website, website2, website3, website4, open, directions, carparking, demonstrations, disabledaccess, toilets, disabledtoilets, refreshments, gallery, schoolliaison, username, password)
                        VALUES('$n', '$d', '$l', '$a', '$t', '$ht', '$f', '$m', '$e', '$w', '$wtw', '$wth', '$wf', '$o', '$di', '$cp', '$dm', '$da', '$tl', '$dt', '$r', '$g', '$sl', '$u', PASSWORD('$p'))";
                } else { // Failed a test.
                        /******************************************
                         * THIS SHOULD BE DIE SEEING AS QUERY DOES
                         * NOT EXIST HERE
                         *****************************************/
                        die('<p><font color="red">Please check that you have entered data for the following fields: <br>Name<br>Description<br>Address<br>Username<br>Password<br><br><a href="javascript:history.go(-1)">back ></a></font></p>');
                }
                /**********************************************
                 * CLOSE THE ISSET CHECK HERE AND RUN THE QUERY
                 * OUTSIDE OF IT
                 *********************************************/
		 
        }
		       
         if ($result = mysql_query($query)) { // Worked.
		 	if (isset($HTTP_POST_VARS['studioartist_id']) && $HTTP_POST_VARS['studioartist_id']!='') {
			echo 'The participating artist has been successfully updated. <a href="artist_more.php?studioartist_id='.$HTTP_POST_VARS['studioartist_id'].'" class="link">Back ></a>';
			} else {
                        echo 'The participating artist has been successfully added. <a href="participating_artists.php" class="link">Back ></a>';
			}
        } else { // If the query did not run OK.
            die('<p><font color="red">Your submission could not be processed due to a system error: ' . mysql_error() . '.</font></p>');
        }
               
			  				} else {
		 // The username is not available.
			echo '<font color="red">That username is already taken.</font><br><br><a href="javascript:history.go(-1)">back ></a>'; 
		} 
			   
} else { // Display the form.
?>



<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="studioartist_id" value="<?php print $HTTP_GET_VARS['studioartist_id'];?>">

<input type="hidden" name="MAX_FILE_SIZE" value="77524288">
<h1>Add/Edit an Open Studio Artist</h1><br>
Fill out the form to add or edit an Open Studios Artist:
<br>
<br><span class="red">*</span>_ Denotes Required Field<br>
<br>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="180" height="26" align="left" valign="top"><strong>Artist Name & Area Code:</strong> <span class="red">*</span></td>
    <td align="left" valign="top"><input name="name" class="form_fields" type="text" value="<?php print $sa['name'];?>" size="30" maxlength="100"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Username:</strong> <span class="red">*</span></td>
    <td align="left" valign="top"><input name="username" class="form_fields" type="text" value="<?php print $sa['username']; if (isset($_POST['username'])) echo $_POST['username'];?>" size="30" maxlength="30" />
      <br>
      <small>Use only letters, numbers, and the underscore. Must be between 4 and 30 characters long.</small></td>
  </tr>
<?php if ($sa['studioartist_id']) {
		} else {
			print  '<tr>
    <td height="26" align="left" valign="top"><strong>Password:</strong> <span class="red">*</span></td>
    <td align="left" valign="top">	  
	<input type="password" name="password1" class="form_fields" size="30" maxlength="30"/>
      <br><small>Use only letters and numbers. Must be between 4 and 30 characters long.</small></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Confirm Password: </strong><span class="red">*</span></td>
    <td align="left" valign="top"><input type="password" class="form_fields" name="password2" size="30" maxlength="30" /></td>
  </tr>
';	
		}
?>
    <tr>
    <td height="26" align="left" valign="top"><strong>Short description:</strong> <span class="red">*</span><!-- <br>
    <span class="small">Please type text directly into the textarea, or copy and paste from Notepad. <br>
    Do not take text directly <br>
    from Microsoft Word.</span> --></td>
    <td align="left" valign="top">     <textarea name="description" class="form_fields" wrap="hard" cols="58" rows="8" id="description" onKeyPress="textCounter(this,this.form.counter,600);"><?php print $sa['description'];?></textarea>
</td></tr>
  <tr>
    <td height="26" align="left" valign="top">&nbsp;</td>
    <td align="left" valign="top"><!-- <input
	type="text"
	name="counter"
	maxlength="3"
	size="3"
	value="600"
	onBlur="textCounter(this.form.counter,this,600);">  -->
     Approximately one paragraph of text</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Area:</strong></td>
    <td align="left" valign="top"><?php if ($sa['studioartist_id']) {
	  	if ($sa['location'] == 'SOUTH') {
			print' <select name="location" id="location" class="form_fields">
        <option value="SOUTH" selected >South</option>
        <option value="CENTRAL">Central</option>
		        <option value="NORTH">North</option>
      </select>';
	  	} else if ($sa['location'] == 'CENTRAL') {
			print' <select name="location" id="location" class="form_fields">
        <option value="CENTRAL" selected >Central</option>
        <option value="SOUTH">South</option>
		        <option value="NORTH">North</option>
      </select>';
	  	} else {
			print' <select name="location" id="location" class="form_fields">
        <option value="NORTH" selected >North</option>
        <option value="SOUTH">South</option>
		        <option value="CENTRAL">Central</option>
      </select>';
		}
	  }else {
	  	echo '<select name="location" id="location" class="form_fields">
        <option value="SOUTH" selected >South</option>
        <option value="CENTRAL">Central</option>
		        <option value="NORTH">North</option>
      </select>';
	  }?></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Address:</strong> <span class="red">*</span></td>
    <td align="left" valign="top"><textarea name="address" class="form_fields" cols="35" rows="5"><?php print $sa['address'];?></textarea></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Telephone no:</strong></td>
    <td align="left" valign="top"><input type="text" name="tel" class="form_fields" size="30" maxlength="15" value="<?php print $sa['tel'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Home Telephone no: </strong></td>
    <td align="left" valign="top"><input type="text" name="home_tel" class="form_fields" size="30" maxlength="15" value="<?php print $sa['home_tel'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Fax no:</strong></td>
    <td align="left" valign="top"><input type="text" name="fax" class="form_fields" size="30" maxlength="15" value="<?php print $sa['fax'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Mobile no:</strong></td>
    <td align="left" valign="top"><input type="text" name="mobile" class="form_fields" size="30" maxlength="15" value="<?php print $sa['mobile'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Email:</strong></td>
    <td align="left" valign="top"><input type="text" name="email" class="form_fields" size="30" maxlength="80" value="<?php print $sa['email'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Website:</strong></td>
    <td align="left" valign="top"><input type="text" name="website" class="form_fields" size="30" maxlength="80" value="<?php print $sa['website'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Website no.2: </strong></td>
    <td align="left" valign="top"><input type="text" name="website2" class="form_fields" size="30" maxlength="80" value="<?php print $sa['website2'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Website no. 3: </strong></td>
    <td align="left" valign="top"><input type="text" name="website3" class="form_fields" size="30" maxlength="80" value="<?php print $sa['website3'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Website no. 4: </strong></td>
    <td align="left" valign="top"><input type="text" name="website4" class="form_fields" size="30" maxlength="80" value="<?php print $sa['website4'];?>"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Opening times:</strong></td>
    <td align="left" valign="top"><input name="open" type="text" class="form_fields" value="<?php print $sa['open'];?>" size="30" maxlength="100"></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Directions:</strong></td>
    <td align="left" valign="top"><textarea name="directions" class="form_fields" cols="35" rows="5"><?php print $sa['directions'];?></textarea></td>
  </tr>
 <?php if ($sa['studioartist_id'])
  {
  			print '<tr>
    <td height="26" align="left" valign="top"><strong>Car parking :</strong></td>
    <td align="left" valign="top">';
	if ($sa['carparking']) {
		print '<select name="carparking" id="carparking" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="carparking" id="carparking" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}	
	print '</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Demonstrations:</strong></td>
    <td align="left" valign="top">';
		if ($sa['demonstrations']) {
		print '<select name="demonstrations" id="demonstrations" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="demonstrations" id="demonstrations" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
    print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Disabled Access :</strong></td>
    <td align="left" valign="top">';
		if ($sa['disabledaccess']) {
		print '<select name="disabledaccess" id="disabledaccess" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="disabledaccess" id="disabledaccess" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Toilets:</strong></td>
    <td align="left" valign="top">';
			if ($sa['toilets']) {
		print '<select name="toilets" id="toilets" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="toilets" id="toilets" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Disabled toilets:</strong></td>
    <td align="left" valign="top">';
			if ($sa['disabledtoilets']) {
		print '<select name="disabledtoilets" id="disabledtoilets" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="disabledtoilets" id="disabledtoilets" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Refreshments:</strong></td>
    <td align="left" valign="top">';
			if ($sa['refreshments']) {
		print '<select name="refreshments" id="refreshments" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="refreshments" id="refreshments" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Gallery:</strong></td>
    <td align="left" valign="top">';
		if ($sa['gallery']) {
		print '<select name="gallery" id="gallery" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="gallery" id="gallery" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Schools Liaison :</strong></td>
    <td align="left" valign="top">';
			if ($sa['schoolliaison']) {
		print '<select name="schoolliaison" id="schoolliaison" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select>';
	} else {
	print '<select name="schoolliaison" id="schoolliaison" class="form_fields">
      <option value="" selected >No</option>
      <option value="yes">Yes</option>
    </select>';
	}
	print'</td>
  </tr>';

} else {
	print '<tr>
    <td height="26" align="left" valign="top"><strong>Car parking :</strong></td>
    <td align="left" valign="top">
	<select name="carparking" id="carparking" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Demonstrations:</strong></td>
    <td align="left" valign="top"><select name="demonstrations" id="demonstrations" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Disabled Access :</strong></td>
    <td align="left" valign="top"><select name="disabledaccess" id="disabledaccess" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Toilets:</strong></td>
    <td align="left" valign="top"><select name="toilets" id="toilets" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Disabled toilets:</strong></td>
    <td align="left" valign="top"><select name="disabledtoilets" id="disabledtoilets" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Refreshments:</strong></td>
    <td align="left" valign="top"><select name="refreshments" id="refreshments" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Gallery:</strong></td>
    <td align="left" valign="top"><select name="gallery" id="gallery" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
  <tr>
    <td height="26" align="left" valign="top"><strong>Schools Liaison :</strong></td>
    <td align="left" valign="top"><select name="schoolliaison" id="schoolliaison" class="form_fields">
      <option value="yes" selected >Yes</option>
      <option value="">No</option>
    </select></td>
  </tr>
';
	}
  		 ?>
  <tr align="center">
    <td valign="top" colspan="2"><input type="submit" name="submit" value="Submit"></td>
  </tr>
</table>
</form><!-- End of Form -->
<?php
} //End of main conditional.
}
include_once ('../includes/footer_nothing.html'); // Require the HTML footer.
?>     

</body>
</html>
When the user updates the description box in HTML it adds random spaces and characters. But if they click to update in code mode it updates fine
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Wow, how do people work with code like that :?
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Post by katd »

Sorry :oops:

Have you any idea why the htmlarea effects the code when updating it, could it be something do with when I'm pulling it from the database to display in the text area?
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Post by katd »

Has anyone else had any problems with updating a database and using HTMLarea?

Thanks in advance
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

I use FCK editor.

Always works for me.

And please dont bump your posts (read rule at bottom)

And, another point, you will find you will not get help when posting code like that. People aren't going to sift through that amount of code.

One final point, have you written this yourself? Why are you using $HTTP_POST_VARS in one instance, then using $_POST in another. Better to keep it consitent for readbale code.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not recieve a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Post by katd »

Hi

Thanks for that was thinking of using a different method.

Sorry for bumping my message it wasn't intentional just trying to refrase what help I needed and to someone with may have a had a similar problem.

The code is a mixture of me writing it from scratch and something I'd done before for another project which I've been adapting so that's the reason it's not that consistent. Thanks for the advice I will go over my code when i'm finished and sort it out just trying to get it working at the moment.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

I still don't understand what your problem is.

Using a textarea for SQL is fine as long as you give it a name and it is within a form for submission, you can treat it like any other type of input:

Code: Select all

$textarea = mysql_real_escape_string($_POST['textarea']);

mysql_query("UPDATE `table` SET `column` = '$textarea'");
katd
Forum Commoner
Posts: 34
Joined: Thu Nov 10, 2005 9:12 am

Post by katd »

It only causes a problem in Internet Explorer, Firefox is fine. In Internet Explorer if I update the text using the HTML area it adds spaces and basically messes up the text. It's ashame I can't force everyone to use Firefox. Would I be better off using a different editor?
Post Reply