Jump to content


Photo

Mysql no take Action !!!


  • Please log in to reply
3 replies to this topic

#1 balkan7

balkan7
  • Members
  • PipPipPip
  • Advanced Member
  • 234 posts

Posted 29 October 2006 - 09:46 PM

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

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

?>


#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 October 2006 - 11:22 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 balkan7

balkan7
  • Members
  • PipPipPip
  • Advanced Member
  • 234 posts

Posted 30 October 2006 - 11:46 AM

here is values :

<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>


#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 30 October 2006 - 05:15 PM

OK... still, echo the query that you're passing to mysql.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users