beginann Posted November 2, 2006 Share Posted November 2, 2006 Probably I am blind, but I can´t see what´s wrong with my code...I have databaseconnection, but I can´t insert any new posts in my database from my form.Please help!Many thanks!BeginannThis is my code:phpinclude_once("dbmanager.php");?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Växtdatabas, blomform</title><link href="vaxter_css.css" rel="stylesheet" type="text/css" /></head><body><?php if(isset($save)){ if(isset($blomform) && $blomform != "" && strlen($blomform) <= 30) { $query = "INSERT INTO blomform (blomform) VALUES ('$blomform')"; $resultat = mysql_query($query,$connection); if(!$resultat){ echo "<div class=tabell4><table><tr><td>The flower couldn´t be put into the database! MySQL rapporterar: " .mysql_error() ."</td> </tr>"; echo "</table></div>"; } else echo "Blomformen $blomform är inlagd."; } } // Close connection to database mysql_close($connection);?> <form method="post" action="<?=$PHP_SELF?>"><span class="rubrik">Lägg till blomform</span><table width="33%" border="0" cellspacing="0" cellpadding="0"> <tr> <td>Blomform</td> <td> <input type="text" name="blomform" size="30" /></td></tr> <tr><td> </td><td colspan="2"></tr> <tr><td> </td> <td colspan="2"><input class="skicka_knapp3_gul" type="submit" name="save" value="Save" /> </tr></table></form></body></html> Link to comment https://forums.phpfreaks.com/topic/25911-insert-doesn%C2%B4t-work/ Share on other sites More sharing options...
Perad Posted November 2, 2006 Share Posted November 2, 2006 You haven't defined $blomform$blomform = $_POST['blomform'] Link to comment https://forums.phpfreaks.com/topic/25911-insert-doesn%C2%B4t-work/#findComment-118322 Share on other sites More sharing options...
fiddy Posted November 2, 2006 Share Posted November 2, 2006 Pls try like this:$query = "INSERT INTO blomform (blomform) VALUES ('".$_POST['blomform']."')"; Link to comment https://forums.phpfreaks.com/topic/25911-insert-doesn%C2%B4t-work/#findComment-118330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.