Page 1 of 1

textarea's not being add to data base?

Posted: Wed Jul 02, 2003 9:35 am
by Darkside
Making a little thing where u can send messages to team mates and stuff like that. Just started out making a table name memebers 4 fields ID, Name, Team, and Messages.
To add data i used this form.

Code: Select all

<form action="messages.php" method="POST">
  <p>Username: 
    <input type="text" name="Name" size="20">
    <br>
    Message: 
    <textarea name="Messages"></textarea>
    <br>
    Team? 
    <select name="Team">
      <option value="client" selected>Client</option>
      <option value="Team">Team</option>
    </select>
    <br>
    <input type="submit" value="Send!">
  </p>
  </form>
and this php code

Code: Select all

include("config.inc");
$Mestable = "messages";
if(!($link_id = mysql_connect($Host, $User, $Pass))) die(mysql_erorr());
mysql_select_db($DB);
$sql = "INSERT INTO " . $Mestable . " VALUES('',
'". addslashes($_POST&#1111;'Name']) . "'
, '" . addslashes($_POST&#1111;'Team']) . "'
, '" . addslashes($_POST&#1111;'Messages']) . "'
)";
if(!($result = mysql_query($sql))) &#123;
    die(mysql_error());
&#125; else &#123;
    echo "Your message has been added!<br>";
    echo "<a href=mesdisplay.php>Continues</a> to the messages page";
&#125;
Then I'm using a simple fench_array to echo out everything in the data base and messages is not coming out. I'm sure its cus its a textarea cus i changed it to a single line and it came out fine.. Its prolly something simple fink its in my messages.php code above. any help thanks!
darkside!

Posted: Wed Jul 02, 2003 9:45 am
by m3rajk
1: mysql has escapes that you have to \ out.
when you process it, do you use addslashes() ?

Posted: Wed Jul 02, 2003 9:54 am
by Darkside
I'm just using this

Code: Select all

$mySQL_ID = mysql_connect($Host, $User, $Pass);
        mysql_select_db($DB, $mySQL_ID)
           or die("unable to select database 'db': ".msql_error());
    $result = mysql_query("SELECT id, name, Messages, Team FROM messages");

   while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) &#123;
        printf ("ID: %s  Name: %s  Team: %s  Messages: %s", $row&#1111;"id"], $row&#1111;"name"], $row&#1111;"Team"], $row&#1111;"Messages"]);
    &#125;

    mysql_free_result($result);
to show me whats in the table..

Posted: Wed Jul 02, 2003 11:02 am
by phice
m3rajk: Neither addslashes() or stripslashes() is needed when using the mysql functions. They automatically do it for you. ;)

Posted: Fri Jul 04, 2003 6:34 pm
by bionicdonkey
try changing the datatype in the db to text