mikebyrne Posted March 21, 2008 Share Posted March 21, 2008 Im trying to get the info the user types into the testboxes to pass to the database but for some reason they wont!! My code is <form action="add.php" onsubmit="return valid()" method="post"> <?PHP require_once("adminconnect.php"); $ProductNo = mysql_real_escape_string(trim($_POST['ProductNo'])); $ProductName = mysql_real_escape_string(trim($_POST['ProductName'])); $Description = mysql_real_escape_string(trim($_POST['Description'])); $Price = mysql_real_escape_string(trim($_POST['Price'])); $tbl_name="product"; $sql="INSERT INTO $tbl_name (ProductNo, ProductName, Description,Price) VALUES ('$ProductNo', '$ProductName', '$Description', '$Price')"; echo $_POST['ProductNo']; echo $_POST['ProductName']; echo $_POST['Description']; echo $_POST['Price']; echo $sql; ?> <div class="editRightForm"> <input type="text" class="itemEditForm02" name="ProductNo" value="<?php echo $row['ProductNo'];?>"/> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data finish --> <div class="padTop3"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- dat start --> <div class="editRightBox"> <div class="editRightText">Product Name:</div> <div class="editRightForm"> <input type="text" class="itemEditForm02" name="ProductName" value="<?php echo $row['ProductName'];?>" /> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data finish --> <div class="padTop3"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- dat start --> <div class="editRightBox"> <div class="editRightText">Description:</div> <div class="editRightForm"> <textarea type="text" class="itemEditForm03" name="Description" ><?php echo $row['Description'];?></textarea> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data finish --> <div class="padTop3"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- dat start --> <div class="editRightBox"> <div class="editRightText">Remarks:</div> <div class="editRightForm"> <input type="text" class="itemEditForm02" name="0" value="" /> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data finish --> <div class="padTop3"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- dat start --> <div class="editRightBox"> <div class="editRightText">Price:</div> <div class="editRightForm"> <div class="editItemPrice1">€</div> <div class="editItemPrice2"> <input type="text" class="itemEditForm04" name="Price" value="<?php echo $row['Price'];?>" /> </div> <div class="clr"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data finish --> The output I get on screen from the echos is: 33hthrhfeeeeeeeeeeeeeeeeeeeeeeeeeeeee22INSERT INTO product (ProductNo, ProductName, Description,Price) VALUES ('33', 'hthrh', 'feeeeeeeeeeeeeeeeeeeeeeeeeeeee', '22') Which suggests to me that everything is being collected ok but when I check my database no details are being passed The sql for my db is : CREATE TABLE `product` ( `Producttype` varchar(4) collate latin1_general_ci default NULL, `ProductName` varchar(80) collate latin1_general_ci default NULL, `ProductNo` double(50,0) NOT NULL auto_increment, `Stockamount` decimal(5,0) default NULL, `Display` varchar(3) collate latin1_general_ci default NULL, `Description` varchar(1000) collate latin1_general_ci default NULL, `Price` decimal(6,2) default NULL, `Image` varchar(50) collate latin1_general_ci default NULL, `Image2` varchar(50) collate latin1_general_ci default NULL, PRIMARY KEY (`ProductNo`) ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; Link to comment https://forums.phpfreaks.com/topic/97260-details-wont-pass-to-database/ Share on other sites More sharing options...
Northern Flame Posted March 21, 2008 Share Posted March 21, 2008 replace echo $sql; with mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/97260-details-wont-pass-to-database/#findComment-497663 Share on other sites More sharing options...
mikebyrne Posted March 21, 2008 Author Share Posted March 21, 2008 Thanks that fixed it Link to comment https://forums.phpfreaks.com/topic/97260-details-wont-pass-to-database/#findComment-497707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.