Jump to content

Only taking partial inputs into set


twilightnights

Recommended Posts

I have this a check box form which sends values from the form to this script, then from this script it goes to the database.  While all 3 values reach the php script, as it outputs them as shown here:

Thanks for your submittal! We will review your joke and add it to the database shortly!
subname: afds
subcat1: College, Pickup Lines, Ethnic
subbody: fa
subauthor: afds
subanswer:

In the database it only takes the first one, College

What am I doing wrong?
[code]
<?
include("dbinfo.inc.php");
include("dbconnect.inc.php");


$subname = $_POST['jokename'];
$cat1[0] = $_POST['cat1'][0];
$cat1[1] = $_POST['cat1'][1];
$cat1[2] = $_POST['cat1'][2];
$subbody = $_POST['jokebody'];
$subauthor= $_POST['author'];
$subanswer= $_POST['jokeanswer'];



$strcat1="";

$count=count($cat1);

if($count < 3)
{$count=3;}


for($i=0;$i<$count;$i++)
{if($cat1[$i] == "")
{}
else if($i==0)
{$strcat1="$strcat1$cat1[$i]";}
else
{$strcat1="$strcat1, $cat1[$i]";}
}




if ($subauthor==null)
{$subauthor="Anonymous";}
if ($subanswer=="none")
{$subanswer=null;}
if ($subanswer==null)
{
$query ="INSERT INTO `submittals` (subname,subcat1,subbody,subauthor)
values ('$subname','$strcat1','$subbody','$subauthor')";
}
else
{
$query ="INSERT INTO `submittals` (subname,subcat1,subbody,subauthor,subanswer)
values ('$subname','$strcat1','$subbody','$subauthor','$subanswer')";
}

Echo "<p align=\"center\">Thanks for your submittal! We will review your joke and add it to the database

shortly!<br>subname: $subname<br>subcat1: $strcat1<br>subbody: $subbody<br>subauthor: $subauthor<br>

subanswer: $subanswer";

mysql_query($query);
mysql_close();

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/
Share on other sites

Well, as I said its posting all of the values into my output, showing that the string is receiving the correct value.  But its not sending the correct value to the database.  I believe it has something to do with it being a set.  The subcat1 is a set value.
When I view my database only College goes into the subcat field, the rest of it is ignored

But the entire sting obviously has all 3 as seen when I echo the string

subname: afds
subcat1: College, Pickup Lines, Ethnic
subbody: fa
subauthor: afds
subanswer:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.