[SOLVED] Question on Field Types - Text

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
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Question on Field Types - Text

Post by C_Calav »

i have a text area on a insert form and i get errors when adding in text information.

what charachters can be entered into a text area? and what about speaical characters? eg. ":?><}{)(*&^%44

thanx
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

show us your code.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

i was just wondering what chharters can be inserted or does it now matter?

Code: Select all

<?php
 
    $db = mysql_pconnect() or die ("Could not connect to database");

    # mysql_select_db('models') or die ("Could not select database!"); 

	# this is processed when the form is submitted
	# back on to this page (POST METHOD)
	if ($_SERVER['REQUEST_METHOD'] == "POST") 
        {
		# escape data and set variables
 		mysql_select_db('models') or die ("Could not select database!");

		$P_Stock = stripslashes($_POST["P_Stock"]);
		$P_Name = stripslashes($_POST["P_Name"]);
 		$P_Cat = stripslashes($_POST["P_Cat"]);
		$P_Scale = stripslashes($_POST["P_Scale"]);
		$P_Length = stripslashes($_POST["P_Length"]);	
		$P_Span = stripslashes($_POST["P_Span"]);
		$P_Price = stripslashes($_POST["P_Price"]);
		$P_Desc = stripslashes($_POST["P_Desc"]);
	
            
              if (!empty($P_Stock) && !empty($P_Name)) 
              { 
              $sql  = "INSERT INTO planes (P_Stock, P_Name, P_Cat, P_Scale, P_Length, P_Span, P_Price, P_Desc) VALUES ('$P_Stock','$P_Name','$P_Cat','$P_Scale','$P_Length','$P_Span','$P_Price','$P_Desc')";
              $result = mysql_query($sql, $db) or die ("Execution failed."); 

	      move_uploaded_file($_FILES['file']['tmp_name'], '/var/users/modelair/modelaircraft.co.nz/htdocs/Pics/'.$_FILES['file']['name']); 
	      echo 'File has been stored in your uploads directory.';
        
	      print "<br><b>new aircraft added</b><br><br>";
              } 

              else 
              { 
              echo "<br><b>Make sure stock code AND name are filled out</b><br><br>"; 
              } 


       }

?>
and heres my html for text area

<tr>
<td><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Description:</font></b> </td>
<td><textarea cols="40" rows="5" name="P_Desc"></textarea></td>
</tr>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it generally doesn't matter.. I was just trying to see if you were accidently doing something to the value, which it looks like you aren't really.. have you tried echoing $P_Desc after you load it in from the post? .. You may need to addslashes() to it before inserting it.

However, if it's binary data, use a blob instead. As those are intended to store binary data.
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

thanx feyd, ill try a blob and see, just dont like errors! ha. thanx consider this thread solved
Post Reply