jkkenzie Posted April 4, 2008 Share Posted April 4, 2008 This is the code that adds data to my table! The table code is below... When i try to add a user, am getting the error as 'Error, insert query failed' i.e is from mysql_query($query) or die('Error, insert query failed'); Any help? <?php if(isset($_POST['add'])) { $con=mysql_connect("localhost","root","superman"); if(!$con) { die('Could not connect:'.mysql_error()); } mysql_select_db("digitaldividemt",$con); $name = $_POST['name']; $username = $_POST['username']; $password = $_POST['password']; $query = "INSERT INTO tbluser (strname, strusername, strpassword) VALUES ('$name', '$username', PASSWORD('$password'))"; mysql_query($query) or die('Error, insert query failed'); $query = "FLUSH PRIVILEGES"; mysql_query($query) or die('Error, insert query failed'); mysql_close($con); echo "New user added"; } else { } ?> -- version 2.10.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Apr 04, 2008 at 12:56 PM -- Server version: 5.0.45 -- PHP Version: 5.2.5 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `digitaldevidemt` -- -- -------------------------------------------------------- -- -- Table structure for table `tbluser` -- CREATE TABLE `tbluser` ( `U_ID` varchar(50) NOT NULL default '', `strUsername` varchar(50) NOT NULL, `strPassword` varchar(100) NOT NULL, `GP_ID` int(50) default NULL, `strname` varchar(50) NOT NULL, PRIMARY KEY (`U_ID`), KEY `strUsername` (`strUsername`,`GP_ID`), KEY `strname` (`strname`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `tbluser` -- Link to comment https://forums.phpfreaks.com/topic/99510-add-data-to-table-help/ Share on other sites More sharing options...
Barand Posted April 4, 2008 Share Posted April 4, 2008 try using mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/99510-add-data-to-table-help/#findComment-509089 Share on other sites More sharing options...
jkkenzie Posted April 4, 2008 Author Share Posted April 4, 2008 am getting the same thing; Link to comment https://forums.phpfreaks.com/topic/99510-add-data-to-table-help/#findComment-509099 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.