ipPHPadmin Posted November 29, 2010 Share Posted November 29, 2010 Hello all, I can't get the data store in the $ART_ID variable to pass into the database. The original $Artisan variable is set up like this: 1. Artisan Name. So the explode is taking just the number. If I put an echo after the explode and the $ART_ID variable it outputs the correct information but it doesn't store in the database as that data. The query is in correct order too. Thanks in advance. $CType_Type = $_REQUEST["CTYPE_Type"]; $Artisan = $_REQUEST['Artisan']; $Quantity = $_POST['Quantity']; $HAnswer1 = $_POST["HAnswer1"]; $HAnswer2 = $_POST["HAnswer2"]; $HAnswer3 = $_POST["HAnswer3"]; $HAnswer4 = $_POST["HAnswer4"]; $break = explode(".", $Artisan); $ART_ID = $break[0]; if(!$Quantity) { die('Quantity field is empty. Please enter the quantity of handicrafts made.'); } else { $ctypeQuery = mysql_query("SELECT CTYPE_ID FROM CraftType WHERE CTYPE_Type = '".$CType_Type."'"); while($row = mysql_fetch_array($ctypeQuery)) { $CTYPE_ID = $row["CTYPE_ID"]; $sql = ("INSERT INTO Handicraft VALUES (`HANDI_ID`, '".$Quantity."', 'NULL', '".$CTYPE_ID."', '".$ART_ID."', 'NULL', '1')"); if(!mysql_query($sql)) { die('Error inserting Handicraft Type into table: ' . mysql_error()); } else { -----data in this section doesn't affect the rest of the code---- } } } Quote Link to comment Share on other sites More sharing options...
devilinc Posted November 29, 2010 Share Posted November 29, 2010 just to get it clear before i respond do you want to insert "1. Artisan Name" in your table or "1" or "Artisan Name" in your table? Quote Link to comment Share on other sites More sharing options...
devilinc Posted November 29, 2010 Share Posted November 29, 2010 check your data type in your table to see if it supports alpha numeric i.e. varchar type for the $ART_ID variable Quote Link to comment Share on other sites More sharing options...
devilinc Posted November 29, 2010 Share Posted November 29, 2010 $sql = ("INSERT INTO Handicraft VALUES (`HANDI_ID`, '".$Quantity."', 'NULL', '".$CTYPE_ID."', '".$ART_ID."', 'NULL', '1')"); try changing it to $sql = "INSERT INTO Handicraft VALUES (`HANDI_ID`, '$Quantity', NULL, '$CTYPE_ID', '$ART_ID', NULL, 1)"; OR keeping it simple omit null values but be sure to include the column names when u do so like insert into (col_name1,col_name2,col_name4,col_name6) values ('blah','blah','blah','blah') Quote Link to comment Share on other sites More sharing options...
ipPHPadmin Posted November 29, 2010 Author Share Posted November 29, 2010 Alright, first off, thanks for the timely responses devilinc. As for your questions, I am trying to insert just the "1" part and the data type of the database field is correct. I tried what you said in your most recent post and it worked! Do you have any idea why removing the " and . would make it work correctly? Thanks again for the help. Quote Link to comment 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.