Jump to content

jasonkirk

Members
  • Posts

    3
  • Joined

  • Last visited

jasonkirk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yea, I'm starting to see that treating ' and " the same has finally caught up and bit me. I tended to do it to avoid escape characters so I could have quotes inside quotes without the confusion of \ all over the place. Still haven't figured out the right combination yet. I can break things worse but can't seem to go in the other direction.
  2. Thanks it helps a bit though still haven't quite grasped. Tried making the original array variable have the $ instead of after the fact and using the mysql escape but still get the variable name $rel_student_uid instead of the actual uid. INSERT INTO tbl_detentions (rel_student_uid, detention_date) VALUES ('$rel_student_uid', '2013-3-3') $database_info = array("db_table_name" => tbl_detentions, "db_field_names" => array("rel_student_uid", "detention_date"), "form_fields" => array('$rel_student_uid', "$detention_date")); // Add detention to database BEGIN $testt = mysql_real_escape_string($database_info['form_fields'][0]); $query = "INSERT INTO ". $database_info['db_table_name']; $query .= " (" . $database_info['db_field_names'][0] . ", " . $database_info['db_field_names'][1] . ") VALUES "; $query .= "('" . mysql_real_escape_string($testt) . "', '$detention_date')"; $message .= $query; $result = mysql_query($query); if($result) { $message .= "<center>Student given detention.</center>"; } else { $message .= "Problem adding detention to student record."; $message .= "<br>" . $query; } $detention_count++; } // Add detention to database END
  3. Setup a array that held all the query info for a database with the plan to put the second of code that updates the database into a function. But hasn't been working. In the end I widdled it down to the question, why don't these two bits of code work the same? Array: $database_info = array("db_table_name" => tbl_detentions, "db_field_names" => array("rel_student_uid", "detention_date")); Database code: $query = "INSERT INTO ". $database_info['db_table_name']; $query .= " (" . $database_info['db_field_names'][0] . ", " . $database_info['db_field_names'][1] . ") VALUES "; $query .= "($" . "rel_student_uid, '$detention_date')"; $result = mysql_query($query); $query = "INSERT INTO ". $database_info['db_table_name']; $query .= " (" . $database_info['db_field_names'][0] . ", " . $database_info['db_field_names'][1] . ") VALUES "; $query .= "($rel_student_uid, '$detention_date')"; $result = mysql_query($query);
×
×
  • 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.