I am having a problem getting text to insert properly into the db. It inserts but ONLY the first word of what was written.
The text comes from a form that has a text area named "comments".All of the info is passing correctly but it keeps cutting off the rest of the text.
Any ideas anyone?
Only first word of submitted text gets inserted
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Sure! Here it is and I warn you ahead of time... yes I am new to this lol and not sure if I should have posted this here or in the php forum.
Once the form is submitted it gets "previewed" before it arrives at this code. All of the text input into the textarea is displayed right. They then click a submit button from there that passes the info to the above code. The only thing that gets inserted into the comments field of the db is the first word. Everything else is cut off.
Code: Select all
if($attend==no){
mysql_select_db($database_dbi, $dbi);
$query_getstrike = "SELECT * FROM ".$user_prefix."_strike_count WHERE uname='$uname'";
$getstrike = mysql_query($query_getstrike, $dbi) or die(mysql_error());
$row_getstrike = mysql_fetch_assoc($getstrike);
$totalRows_getstrike = mysql_num_rows($getstrike);
$numstrikes=$row_getstrikeї'strikes'];
$memname=$row_getstrikeї'uname'];
if($numstrikes < 3){
$numstrikes++;
$totalstrikes=$numstrikes;
if (!isset($memname)){
mysql_query(" INSERT INTO ".$prefix ."_attendance ( tid, uname, mday, month, year, attend, comments )
VALUES ( '$tid', '$uname', '$mday', '$month', '$year','$attend', '$comments' )",$dbi) or die ("Couldn't insert info");
echo "<center>";
echo "<br><br><br>";
echo " Failure to attend training for $uname was successfully recorded";
}
if (!isset($memname)){
$numstrikes=1;
mysql_query(" INSERT INTO ".$prefix ."_strike_count ( uname, strikes) VALUES ('$uname','$numstrikes')", $dbi) or die (mysql_error());
echo "<br><br>";
echo "Strike for missed training was recorded for $uname";
}
elseif (isset($memname)) {
mysql_query(" UPDATE ".$prefix."_strike_count SET strikes='$totalstrikes' WHERE uname ='$uname'", $dbi) or die (mysql_error());
echo "<center>";
echo "<br><br><br>";
echo "Strike count for $uname was updated";
}
}
}
if($attend == excused){
mysql_select_db($database_dbi, $dbi);
mysql_query(" INSERT INTO ".$prefix ."_attendance ( tid, uname, mday, month, year, attend, comments) VALUES ( '$tid', '$uname', '$mday', '$month', '$year','$attend', '$comments')", $dbi)
or die (mysql_error());
echo "<center>";
echo "<br><br><br>";
echo " Excused abscence from training for $uname was successfully recorded";
}
if($attend == yes){
mysql_select_db($database_dbi, $dbi);
mysql_query(" INSERT INTO ".$prefix ."_attendance ( tid, uname, mday, month, year, attend, comments) VALUES ( '$tid', '$uname', '$mday', '$month', '$year','$attend', '$comments')", $dbi)
or die (mysql_error());
echo "<center>";
echo "<br><br><br>";
echo " Attendance for $uname was successfully recorded";
}
}- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
I have it set up so that the information from the form goes to a preview page and asks if the information is correct then using a hidden form on that page it gets passed to this one. I look into the database and all of the submitted info is in there but if any comments are entered all it puts into the table is the first word.
I have it going into a field called comments set as a type "text".
I have it going into a field called comments set as a type "text".
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
When you put the value into the hidden field you do put quotation marks around it?
If there weren't any quotation marks around the value attribute this might explain why only one word gets passed through to the database.
Mac
Code: Select all
<input type="hidden" name="comments" value="here are the comments" />Mac
Ahhh you were definitely correct!
This is how I was passing from the preview form:
then I changed it to this:
And that fixed it. Thank you so much for pointing that out! This was driving me crazy because I knew I had it working before then once I added the preview before insertion it broke.
Thank you! Thank you!
This is how I was passing from the preview form:
Code: Select all
<input name=comments type=hidden value=$comments>Code: Select all
<input name=comments type=hidden value="$comments">Thank you! Thank you!