php - MySQL Syntax Error at long entered text -


i trying build php form mysql. problem error every time if try add long text field.

the error

you have error in sql syntax; check manual corresponds mysql server version right syntax use near.....at line 1

the php code generating query this:

<?php if ( $_get['aktion'] == "speichern" ) { $title = $_get['title']; $description = $_get['description']; $applepart = $_get['applepart']; $partnumber = $_get['partnumber']; $productcode = $_get['productcode']; $compatibility = $_get['compatibility']; $url_bild = $_get['url_bild']; $price = $_get['price']; $sql = "insert adressbuch "; $sql .= " set "; $sql .= " title = '$title', "; $sql .= " description = '$description', "; $sql .= " applepart = '$applepart', "; $sql .= " partnumber = '$partnumber', "; $sql .= " productcode = '$productcode', "; $sql .= " compatibility = '$compatibility', "; $sql .= " url_bild = '$url_bild', "; $sql .= " price = '$price' "; require_once ('konfiguration.php'); $db_erg = mysql_query($sql) or die("anfrage fehlgeschlagen: " . mysql_error()); echo '<h1>adresse wurde speichert</h1>'; echo '<a href="auflistung.php">auflistung anzeigen</a>'; exit; } ?> <form name="" action="" method="get" enctype="text/html"> <p>title:<br /> <input type="text" name="title" value="" size="60" /> </p> <p>description:<br /> <input type="text" name="description" value="" size="60" /> </p> <p>applepart:<br /> <input type="text" name="applepart" value="" size="60" /> </p> <p>partnumber:<br /> <input type="text" name="partnumber" value="" size="60" /> </p> <p>productcode:<br /> <input type="text" name="productcode" value="" size="60" /> </p> <p>compatibility:<br /> <input type="text" name="compatibility" value="" size="60" /> </p> <p>bild:<br /> <input type="text" name="url_bild" value="" size="60" /> </p> <p>price:<br /> <input type="text" name="price" value="" size="60" /> </p> <input type="hidden" name="aktion" value="speichern" /> <input type="submit" name="" value="speichern" /> </form> 

thanks help

your code susceptible sql injection, , problem hint why.

the rule use is: "never trust data user-agent" (i.e. consider in $_get or $_post potentially problematic or worse). @ minimum, should escape these values using mysqli_real_escape_string or else more robust db framework.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -