Jump to content

Add data to table help


jkkenzie

Recommended Posts

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

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.