我的代码有一个烦人的问题,即拒绝插入 MySQL 表。谁能告诉我我做错了什么?
这是SQL代码..
<?php
if (isset($_POST['submitpraes']))
{
$praesTitel = $row['kontypeBeskriv'];
$praesStr = $_POST['praesidag'];
$konID = $row['konID'];
$sql=("INSERT INTO `mah1233411190550`.`praestationer` (
`praesID` ,
`praesTitel` ,
`praesStr` ,
`brugerID` ,
`holdID`,
`konID`
)
VALUES (NULL , '$praesTitel', '$praesStr', '$brugerID', '$holdID', '$konID');");
mysql_query($sql);
echo $sql;
}
?>
和PHP代码...
<?php
$virksomhedsID = $_SESSION['virkID'];
$sql = "SELECT *
FROM konkurrence
INNER JOIN konkurrenceType ON konkurrenceType.kontypeID = konkurrence.kontypeID
WHERE konkurrence.virkID = '$virksomhedsID'
AND (CURDATE() BETWEEN `konStart` AND `konSlut`)";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
echo '<td width="12%" height="45">';
echo 'konID' . $row['konID'];
echo '<img src="' . $row['kontypeFilename'] . '" width="38px" alt="' . $row['kontypeBeskriv'] . '"/>';
echo '</td>';
echo '<td width="25%">Jeg har i dag ' . $row['kontypeBeskriv'] . 't</td>';
echo '<td>';
echo '<input class="textboxReport" type="text" name="praesidag" size="3"/> km ';
echo '<input type="submit" name="submitpraes" id="submitpraes" value="GEM" />';
echo '</td>';
?>
sql看起来像这样:
INSERT INTO `mah1233411190550`.`praestationer` ( `praesID` , `praesTitel` , `praesStr` , `brugerID` , `holdID`, `konID` ) VALUES (NULL , '', '2', '39', '23', '');
并表明以下内容不起作用,但我不明白为什么......
$praesTitel = $row['kontypeBeskriv'];
$konID = $row['konID'];