Jump to content

Mysql no take Action !!!


balkan7

Recommended Posts

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

[code]<?php

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']);

$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]
Link to comment
https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/
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.
Link to comment
https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/#findComment-116491
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>
        <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">&nbsp;&nbsp;&nbsp;&nbsp;
      <input type="reset" name="submit2" value="Clear"><br>[/code]
Link to comment
https://forums.phpfreaks.com/topic/25523-mysql-no-take-action/#findComment-116675
Share on other sites

Archived

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

×
×
  • Create New...

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.