balkan7 Posted October 29, 2006 Share Posted October 29, 2006 i have problem whit this code when i add product only mysql query KEY and Date for other values not take action ?[code]<?phpif($_POST['submit']) { $db = mysql_connect("$dbhost", "$dbuser", "$dbpassword")or die("cannot connect server "); mysql_select_db("$dbname")or die("cannot select DB"); $product = addslashes($_POST['program']);$desc = addslashes($_POST['desc']);$select = addslashes($_POST['select']);$date = date("d/m/y h:i:s"); $new = addslashes($_POST['new']);$category = addslashes($_POST['category']);$string = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $key = ""; for($i=0; $i<5; $i++){ $y = rand(0,strlen($string)-1); $key .= $string[$y]; } $sql = "INSERT INTO `products` (`id`, `key`, `product`, `desc`, `select`, `date`, `new`, `category`) VALUES ('', '$key', '$product', '$desc', '$select', '$date', '$new', '$category')" or die('insert into is wrong'); $result = mysql_query($sql,$db); print "Product Added Successfull.";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/ Share on other sites More sharing options...
fenway Posted October 29, 2006 Share Posted October 29, 2006 Hard to say why that would be the case, assuming your variables aren't empty. It doesn't look the insert is failing, why not echo the query and check? Also, you shouldn't explicitly include the auto-increment field, and your date format seems incorrect. Quote Link to comment https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/#findComment-116491 Share on other sites More sharing options...
balkan7 Posted October 30, 2006 Author Share Posted October 30, 2006 here is values :[code]<input type="hidden" name="key" size="53" /> <input type="text" name="product" size="53" /> <textarea rows="4" cols="45" name="desc"></textarea> <input type="checkbox" name="new" value="new"> <select size="1" name="select"> <option value="A1">1</option> <option value="A2">2</option> <option value="A3">3</option> </select> <select size="1" name="category"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <form action="add.php" method="post"> <input type="submit" name="submit" value="submit"> <input type="reset" name="submit2" value="Clear"><br>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/#findComment-116675 Share on other sites More sharing options...
fenway Posted October 30, 2006 Share Posted October 30, 2006 OK... still, echo the query that you're passing to mysql. Quote Link to comment https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/#findComment-116835 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.