PHP Add data in this page can not other pages, please help to see AH thank you

Source: Internet
Author: User
$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?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.