Thursday, 15 March 2012

mysql - php my sql insert command didn't add the first column -



mysql - php my sql insert command didn't add the first column -

i have script mysql insert section have problem script didn't insert first column "dns" in sql table did insert sec , 3rd one. error reason first column escaped.

<?php if ($_server['request_method'] == 'post') { $all = implode(",",$_post); $all = explode(",",$all); $insert = "insert cname values ("; ($x=0;$x<3;$x++) { $all[$x] = clean($all[$x]); if ($all[$x] == "" || strlen($all[$x]) > 300) die("<p>incorect info entry, please check again! column - " . $x); $insert .= "'" . $all[$x] . "',"; } $insert .= "'')"; $res = mysql_query($insert) or die(mysql_error()); if($res) die("<p>succesfully added! <a href='index.php'>back view page</a></p>"); } else { ?> <title>add cname.</title> </head> <body> <?php include("nav.php");?> <div class="red"><p><h5>all fields required.</h5></p></div> <table id="box-table-a"> <tbody> <form action="" method="post"> <tr> <td>dns</td> <!-- allow word cname --> <td><input type="text" name="dns" placeholder="enter word 'cname" required pattern="cname" title="enter word 'cname' on field"></td> </tr> <tr> <td>name</td> <td><input type="text" name="name" placeholder="host total domain name" required pattern="^[a-za-z0-9\-]*$" title="host total domain name"></td> </tr> <tr> <td>alias</td> <td><input type="text" name="alias" placeholder="only 3-15 digit allowed" required pattern="^[a-za-z0-9-_\-]{3,15}*$" title="only 3-15 digit allowed"></td> </tr> <tr> <td><input type="submit" value="add cname"></td> <td><input type="reset"></td> </tr> </tbody> </table> <?php } ?>

php mysql sql-insert

No comments:

Post a Comment