Hey.. i used the code above n for a start.. it really succeeds in storing data, but it got the 'cardinality problems' (ive posted before..)..
and now im having the same problem(inserting data) but i changed the codes..
this is the code:
$host= 'localhost';
$username= 'root';
$password= '';
$connect =mysql_connect($host, $username, $password) or
die ("could not connect to MySQL sever in localhost");
$db="care_pair";
mysql_select_db($db, $connect) or
die ("could not select database");
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']))
{
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1"))
{
$insertSQL = sprintf("INSERT INTO Report(Report_No, Name_of_Vessel, Report_Time,
Date_of_Accident, Time_of_Accident, IP_Name, IP_Surname, IP_DOB,
IP_Nationality, IP_Sex, IP_Address, IP_Passport) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",
GetSQLValueString($_POST['Report_No'], "text"),
GetSQLValueString($_POST['Name_of_Vessel'], "text"),
GetSQLValueString($_POST['Report_Time'], "text"),
GetSQLValueString($_POST['Date_of_Accident'], "text"),
GetSQLValueString($_POST['Time_of_Accident'], "text"),
GetSQLValueString($_POST['IP_Name'], "text"),
GetSQLValueString($_POST['IP_Surname'], "text"),
GetSQLValueString($_POST['IP_DOB'], "text"),
GetSQLValueString($_POST['IP_Nationality'], "text"),
GetSQLValueString($_POST['IP_Sex'], "text"),
GetSQLValueString($_POST['IP_Address'], "text"),
GetSQLValueString($_POST['IP_Passport'], "text"));
$Result1 = mysql_query($insertSQL) or die( "There was an error running '$query' " . mysql_error());
}
but still, no data were inserted.
Surprisingly, i used the same code for other database, it worked!(the data were stored)
$host= 'localhost';
$username= 'root';
$password= '';
$connect =mysql_connect($host, $username, $password) or
die ("could not connect to MySQL sever in localhost");
$db="Idora_Laundry_System";
mysql_select_db($db, $connect) or
die ("could not select database");
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO Supplier (Supp_Id, Supp_Name, Supp_Add, Supp_Phone) VALUES (%s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['Supp_Id'], "text"),
GetSQLValueString($HTTP_POST_VARS['Supp_Name'], "text"),
GetSQLValueString($HTTP_POST_VARS['Supp_Add'], "text"),
GetSQLValueString($HTTP_POST_VARS['Supp_Phone'], "text"));
$Result1 = mysql_query($insertSQL) or die(mysql_error());
}
What would be the problem with care_pair database?