hello, have 3 tables in my database. IN_MASTER, IN_CATEGORIES, IN_ASSOCIATIONS.
I need to post a name and description to IN_MASTER, select the row, set the row ID in a variable, then post it along with the category ID into IN_ASSOCIATIONS all in the same script. I don't know what i am doing wrong. Here is a snipit of my code.
if($in_name && $in_desc && $is_it){
$sql1 = "INSERT INTO in_master (ingredient, description) VALUES ('$in_name', '$in_desc')";
if(@mysql_query($sql1)){
echo 'success!<br />';
} else {
echo 'an error occured ' . mysql_error();
}
$sql2 = "SELECT in_id FROM in_master WHERE ingredient = '$in_name'";
$result = mysql_query($sql2);
$num = mysql_numrows($result);
while ($num == 1){
$id = mysql_result($result, "in_id");
++$num;
}
$sql3 = "INSERT INTO in_associations (in_id, ca_id) VALUES ('$id', '$is_it')";
if(@mysql_query($sql)){
echo 'success!<br />';
} else {
echo 'an error occured ' . mysql_error();
}