PHP MySQL PDO connects to the database, cannot manipulate the database, cannot read the data. Kneel and beg for answers.

Source: Internet
Author: User
PHP MySQL PDO connects to the database, cannot manipulate the database, and cannot read data. Kneel and beg for answers.

try{
$votePDO = new PDO ("Mysql:host=127.0.0.1;dbname=legou", ' Root ', ' 2sinilei. ', array (pdo::attr_persistent = true));
$votePDO = new PDO ();
$pdoconn->setattribute (pdo::attr_persistent,true);
echo "Success
";
}
catch (Pdoexception $e) {
echo $e->getmessage ();
}

$result = $votePDO->query ("SELECT * from Uz_types");
Var_dump ($result);
$votePDO->query ("INSERT into uz_types (TypeName) VALUES (' Ah ah ')");
echo "count=". $count. "
";
$result->setfetchmode (PDO::FETCH_ASSOC);
Print_r ($result);
if (empty ($result))
{
echo "NULL";

}else
{
echo "has". Count ($result). " Datas ";
}
echo count ($result);
foreach ($result as $k = $v)
{
echo $v [' TypeName '];

};
?>



Here is the result of the page output

Success
BOOL (FALSE) count=
Null1

//
PHP.ini has been configured well.
There is no link on the error note, but why is this output?
Solve the solution Ah ~ PDO MySQL

Share to:


------Solution--------------------
Var_dump ($result);
$arr = $votePDO->errorinfo ();
Print_r ($arr);Post this result and see
------Solution--------------------
$votePDO = new PDO ("Mysql:host=127.0.0.1;dbname=legou", ' Root ', ' 2sinilei. ', array (pdo::attr_persistent = True,pdo :: Mysql_attr_init_command = ' SET NAMES \ ' utf8\ '));

Let's try this.
  • 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.