Jeg har siddet og stirret på den her meget simple kode og kan simpelthen se fejlen og det irritere mig
<?
If (isset($_POST['kodeord']))
{
$brugernavn = $_POST['brugernavn'];
$kodeord = $_POST['kodeord'];
$dato = date('d/m/Y H:i:s');
$rang = $_POST['rang'];
$md5 = md5($kodeord);
$navn = $_POST['navn'];
$alder = $_POST['alder'];
$email = $_POST['email'];
$by = $_POST['by'];
$land = $_POST['land'];
include("db_connection.php");
mysql_query("INSERT INTO login(brugernavn,kodeord,dato,rang,navn,alder,email,by,land ) VALUES('$brugernavn' , '$md5' , '$dato' , '$rang' , '$navn' , '$alder' , '$email' , '$by' , '$land')" ) or die(mysql_error());
echo"<head>
<meta http-equiv='Refresh' content='3;URL=index.php?id=forside'>
</head>
<center><b>Din bruger er blevet tilføjet, vent venligst.</b></center>";
}
else
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-image: url();
}
.style10 {font-size: 12px}
.styleoverskrift {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
color: #8080FF;
text-decoration: none;
}
-->
</style></head>
<body>
<br>
<table width="705" height="379" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="20" height="20" align="center" valign="top" bgcolor="#FFFFFF"><img src="images/corner%20right%20nede.gif" width="20" height="20"></td>
<td height="20" align="left" valign="top" bgcolor="#F0F0EE"><p align="center"><span class="styleoverskrift">>> Tilføj ny Bruger </span></p></td>
<td height="20" width="20" align="center" valign="top" bgcolor="#FFFFFF"><img src="images/corner%20left%20nede.gif" width="20" height="20"></td>
</tr>
<tr>
<td height="337" align="left" valign="top" bgcolor="#F0F0EE"><p align="center" class="style7"><br>
<br>
</td>
<td height="337" align="left" valign="top" bgcolor="#F0F0EE"><br>
<center>
<form method=post action="ny_bruger.php?insert">
<table width="80%" height="194" border="0" cellpadding="0" cellspacing="0">
<tr align="left" bgcolor="#EBEBE9">
<td height="19" valign="bottom"><span class="style10">Navn:</span></td>
<td><input type=text name=navn></td>
</tr>
<tr align="left">
<td height="22" valign="bottom"><span class="style10">Alder:</span></td>
<td><input type=text name=alder></td>
</tr>
<tr align="left" bgcolor="#EBEBE9">
<td height="19" valign="bottom"><span class="style10">E-mail:</span></td>
<td><input type=text name=email></td>
</tr>
<tr align="left">
<td height="22" valign="bottom"><span class="style10">By:</span></td>
<td><input type=text name=by></td>
</tr>
<tr align="left" bgcolor="#EBEBE9">
<td height="22" valign="bottom"><span class="style10">Land:</span></td>
<td><input type=text name=land></td>
</tr>
<tr align="left">
<td height="22" valign="bottom"><span class="style10">Brugernavn</span></td>
<td><input type=text name=brugernavn></td>
</tr>
<tr align="left" bgcolor="#EBEBE9">
<td height="22" valign="bottom"><span class="style10">Kodeord:</span></td>
<td><input type=password name=kodeord><input name=rang type=hidden value="bruger"></td>
</tr>
<tr align="left">
<td height="40" valign="bottom"><input type=submit value=Tilføj></td>
<td> </td>
</tr>
</table>
</form></center></td>
<td height="337" align="left" valign="top" bgcolor="#F0F0EE"> </td>
</tr>
<tr>
<td height="20" align="left" valign="top"><img src="images/corner%20right.gif" width="20" height="20"></td>
<td height="20" align="center" valign="top" bgcolor="#F0F0EE"> </td>
<td height="20" align="left" valign="top"><img src="images/corner%20left.gif" width="20" height="20"></td>
</tr>
</table>
</center>
<?
}
?>
</body>
</html>
Den siger følgende fejl når jeg tilføjer en bruger:
You have an error in your SQL syntax near 'by,land ) VALUES('12' , 'c20ad4d76fe97759aa27a0c99bff6710' , '06/12/2005 20:57:3' at line 1
Og der har jeg bare indtastet 12 i alle felterne. Jeg kan se at den fucker uret lidt op ved kun at vise denne med 1 cifre istedet for 2 som den plejer. Hvad er problemet?