$action =$_get[' action '];
if ($action = = "Insert")
{
$res = $BW->insert ("Xsd_markets", $_post);
if ($res ==1)
{
echo "";
}
Else
{
echo "";
}
}
?>
Configuration file
Connecting to a database
$host = "localhost";
$dbName = "xsdgoodcom";//Database name
$dbUser = "root";//username
$DBPWD = "changeme";//Password
$query = $BW->query ($sql);
Data insertion
/*
$tbName: Table Name
$post: Post commit data, or it may not be a form-submitted array data
return value TRUE or False
*/
function Insert ($tbName, $post)
{
$elem = Array ();
$val = Array ();
foreach ($post as $key = $value)
{
$elem [] = $key;
$val [] = Trim ($value);
}
$elemSum = count ($elem);
for ($i =0; $i < $elemSum; $i + +)
{
$elemStr. = $elem [$i];
$valStr. = "'". $val [$i]. "'";
if ($i < $elemSum-1)
{
$elemStr. = ', ';
$valStr. = ', ';
}
}
$INSERTSQL = "INSERT into {$tbName} (". $elemStr. ") VALUES (". $valStr.") ";
Die ($INSERTSQL);
$return = $this->query ($INSERTSQL);
if ($return)
{
return true;
}else{
return false;
}
End
}
Reply to discussion (solution)
How did you call that?
$res = $BW->insert ("Xsd_markets", $_post);
if ($res ==1)
{
echo "";
}
Else
{
echo "";
}
I would like to know, you this $BW variable, in other pages available?
Do you also call the database connection? Still is....
Did you include the database connection file in?
Are you sure the method can be called and the value of the variable is normal?