Jump to content


This topic is now archived and is closed to further replies.


Mysql no take Action !!!

Recommended Posts

i have problem whit this code when i add product only mysql query KEY and Date for other values not take action ?


if($_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']);

$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.";}


Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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 size="1" name="category">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

        <form action="add.php" method="post">
      <input type="submit" name="submit" value="submit">&nbsp;&nbsp;&nbsp;&nbsp;
      <input type="reset" name="submit2" value="Clear"><br>[/code]

Share this post

Link to post
Share on other sites
OK... still, echo the query that you're passing to mysql.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.