~error,insert query failed....AND undefined index~ [message #34033] |
Mon, 02 October 2006 07:03 |
tyngtyng
Messages: 1 Registered: October 2006 Location: MALAYSIA
Karma: 0
|
Junior Member |
|
|
hi...
i'm new to the php and now i'm getting an error to insert my data inside the form..and also undefined index in latest_updated......
Now,i'm having trouble catching what i'm doing wrong.... Here's my code to the query entry...
<?php
include 'config.php';
$pili_id=$_POST['pili_id'];
$branch=$_POST['branch'];
$zone=$_POST['zone'];
$location=$_POST['location'];
$type=$_POST['type'];
$subtype=$_POST['subtype'];
$alamat=$_POST['alamat'];
$latest_updated=$_POST['latest_updated'];
$query = "INSECT INTO pili VALUES (pili_id, branch, zone, location, type, subtype, alamat, latest_updated)
('$pili_id', '$branch', '$zone', '$location', '$type', '$subtype', '$alamat', '$latest_updated')";
mysql_query($query) or die('Error, insert query failed');
echo " '$pili_id' <b> '$branch' </b> ,'$zone', '$location', '$type', '$subtype', '$alamat','$latest_updated'";
?>
Can anyone give me a clue..?
thanks...!!!!
|
|
|
Re: ~error,insert query failed....AND undefined index~ [message #34134 is a reply to message #34033] |
Sat, 07 October 2006 12:44 |
|
Hi,
First create the connect to database and then try, your code should be some thing like that:
<?
include 'config.php';
$name=$_POST['name'];
$emailadd=$_POST['emailadd'];
$company_name=$_POST['company_name'];
$designation=$_POST['designation'];
$address=$_POST['address'];
$address1=$_POST['address1'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip_code=$_POST['zip_code'];
$country=$_POST['country'];
$phone=$_POST[phone];
$mobile=$_POST[mobile];
$email=$_POST[email];
$password=$_POST[password];
$password1=$_POST['password1'];
$payment=$_POST['payment'];
$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(DB_NAME, $con);
$sql="INSERT INTO oemp_members
(`Email`,`password`,`name`,`emailadd`,`company_name`,`designation`,`address `,`address1`,`city`,`state`,`zip_code`,`country`,`phone`,`mobile`,`payment` )
VALUES
('$email','$password','$name','$emailadd','$company_name','$designation','$ address','$address1','$city','$state','$zip_code','$country','$phone','$mob ile','$payment') ";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Information Entered"; //message you want to Show
?>
Happy Coding
-Manish Kumar
Manish Kumar
Team Leader
Aone Innvovation (P) Ltd
|
|
|