Skip to content

Instantly share code, notes, and snippets.

@mebrett
Created September 25, 2012 22:14
Show Gist options
  • Save mebrett/3784800 to your computer and use it in GitHub Desktop.
Save mebrett/3784800 to your computer and use it in GitHub Desktop.
sender works, written doesn't. Why?
//create join link between sender and document
$senders=($_POST['senders']);
print_r ($senders);
foreach($senders as $sender) {
if ($sender >='1') {
$addSender = "INSERT INTO sender (sender_doc_id, sender_pers_id) VALUES ('".$newDocid."', '".$sender."')";
mysql_query($addSender) or die('Error '. mysql_error());
echo "<br />Sender(s) successfully linked to document." ;
}
else{
echo "<br />No senders entered, none added.";}
}
//create join between sender location and document
$written=mysql_real_escape_string($_POST['written']);
echo "<br />Written is $written";
if ($written >=1) {
$addWritten = "INSERT INTO written (writ_doc_id, writ_place_id) VALUES ('".$newDocid."', '"$written."')";
mysql_query($addWritten) or die(mysql_error());
echo "<br />Sender location successfully linked to document.";
}
else {
echo "<br />No location entered for sender(s).";
}
@rungiraffe
Copy link

This is a total shot in dark, but in the VALUES in your sql query try single quotations only. i.e. instead of VALUES ('".$newDocid."', '"$written."'), try ('$newDocid', '$written').

This doesn't explain why it DOES work for $sender, but it's been my experience (and Fred has been reminding me) that the program seems to get picky. I use single quotes in my queries and they work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment