twilightnights Posted January 14, 2007 Share Posted January 14, 2007 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: afdssubcat1: College, Pickup Lines, Ethnicsubbody: fasubauthor: afdssubanswer:In the database it only takes the first one, CollegeWhat 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] Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/ Share on other sites More sharing options...
fenway Posted January 14, 2007 Share Posted January 14, 2007 Assuming all the values come back correctly from the $POST, this is a PHP logic issue, not a MySQL problem. Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-160615 Share on other sites More sharing options...
twilightnights Posted January 14, 2007 Author Share Posted January 14, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-160674 Share on other sites More sharing options...
fenway Posted January 15, 2007 Share Posted January 15, 2007 So what does an echo of $query show? Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-161455 Share on other sites More sharing options...
twilightnights Posted January 15, 2007 Author Share Posted January 15, 2007 When I view my database only College goes into the subcat field, the rest of it is ignoredBut the entire sting obviously has all 3 as seen when I echo the stringsubname: afdssubcat1: College, Pickup Lines, Ethnicsubbody: fasubauthor: afdssubanswer: Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-161491 Share on other sites More sharing options...
fenway Posted January 16, 2007 Share Posted January 16, 2007 Again, I believe you about subcat1, I need to see the query. Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-162122 Share on other sites More sharing options...
twilightnights Posted January 18, 2007 Author Share Posted January 18, 2007 Thank you for helping me. Sorry for the late response.Here is the Querysubanswer: INSERT INTO `submittals` (subname,subcat1,subbody,subauthor) values ('asdf','College, Medical, Men','fdsa','afds') Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-163958 Share on other sites More sharing options...
fenway Posted January 19, 2007 Share Posted January 19, 2007 That looks fine to me... unless you can't have the extra space. You may want to re-read [url=http://dev.mysql.com/tech-resources/articles/mysql-set-datatype.html]this refman page, too[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-164177 Share on other sites More sharing options...
twilightnights Posted January 19, 2007 Author Share Posted January 19, 2007 Thanks a ton, the spaces caused the problem. Quote Link to comment https://forums.phpfreaks.com/topic/34145-only-taking-partial-inputs-into-set/#findComment-164592 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.