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.