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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.