beginann Posted September 24, 2007 Share Posted September 24, 2007 Hi, In my MySQL-table I have four fields: nr, namn, link and byt. Nr and name are no problems. I the linkfield I want a link to a picture and in the byt-field I want a standardvalue, which means that if I click there I will go to a form, where I can change the link to the picture if I want to. This is my code: <?php if(isset($spara)){ if(isset($nr) && $nr != "" && strlen($nr) <= 4 && isset($link) && $link !=""){ $query="INSERT INTO lista_1 nr, link VALUES ('$nr', '$link') WHERE nr='$nr'"; $result = mysql_query($query); if(!$resultat){ echo "<div class=tabell4><table><tr><td>Länken kunde inte läggas till. MySQL rapporterar: " . mysql_error() . "</td></tr>"; echo "</table></div>"; } else { echo "<table><tr><td>Länken är inlagd</td></tr>"; echo "</table>"; } } } // Stänger anslutningen till vår databas mysql_close($connection); ?> <div id="Layer1"> <form id="form1" name="form1" method="post" action="<?=$PHP_SELF?>"> <table width="80%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><span class="rubrik_14_bold_italic">Fyll i nedanstående och klicka på sänd!</span><br /> <br /> <span class="text_12">För att se ändringen behöver Du klicka på "Uppdatera"-symbolen i verktygsraden.</span></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td class="text_12">Växtens nr </td> <td><input name="nr" type="text" id="nr" size="10" value="<?=$s_nr?>"></td> </tr> <tr> <td class="text_12">Bildlänk</td> <td><input name="link" type="text" id="link" size="40" maxlength="60" value="<?=$s_link?>"></td> </tr> <tr> <td class="text_12"> </td> <td> </td> </tr> <tr> <td class="text_12"> </td> <td><input type="submit" name="spara" value="Skicka" /> <input type="submit" name="drop" value="Rensa" /></td> </tr> <tr> <td class="text_12"> </td> <td> </td> </tr> </table> </form> </div> In the byt-field I have succeeded to get a standardvalue by coding like this: <a href="byt1.php" target="_blank">Ny bild</a> I have also added: <?php include_once("dbmanager.php"); ?> and that works because I have got information from the database by using SELECT in another file. My problem is that I can´t put in new links in my database, something seems to be wrong, but I can´t find out what it is. Please help! A-B Quote Link to comment https://forums.phpfreaks.com/topic/70531-insert-problems/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.