Reputation: 43
I have constructed the following query
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO selection (student_id, id_project, level_of_want)
VALUES ((SELECT id FROM users WHERE Username = ".$_SESSION['MM_Username']." ), %s, %s)",
GetSQLValueString($_POST['Project_id'], "int"),
GetSQLValueString($_POST['Want'], "text"));
mysql_select_db($database_projectsite, $projectsite);
$Result1 = mysql_query($insertSQL, $projectsite) or die(mysql_error());
}
The student_id comes from the session information that is compared in the table.
The id_project comes from a hidden field that should contain the current id, and the level_of_want comes from the two submit button. When one is selected, that value is applied to the database. Below is how that looks in the form.
<input type="submit" name="Want[]" id="Want_0" value="Really Want" />
<input type="submit" name="Want[]" id="Want_1" value="Partially Want" />
</p>
<p>
<input name="Project_id" type="hidden" id="Project_id" value="<?php echo $row_Test['Project_id']; ?>" />
</p>
However when i execute this no information is applied to the database, nor is an error message shown when the button is selected. Does anyone have any possible clue to whats wrong?
Upvotes: 0
Views: 757
Reputation: 111
Nathan,
Saw on your submit input is an array
<input type="submit" name="Want[]" id="Want_0" value="Really Want" />
<input type="submit" name="Want[]" id="Want_1" value="Partially Want" />
so to getting value should be
GetSQLValueString($_POST['Want'][0], "text"));
Tomz
Upvotes: 0
Reputation: 391
I'm guessing because "SELECT id" is returning an empty resultset
try the following:
SELECT id FROM users WHERE Username = '".$_SESSION['MM_Username']."'
Notice the extra single quotes around the double quotes
Upvotes: 2