Unable to import ??? {Code...} Note: the import package is correct:
Unable to import ???
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'source D:\Server\three\public\export.sql' at line 1
function ImportDB($dbh) { $sql = 'source '.realpath('export.sql'); try { $stmt = $dbh->prepare($sql); var_dump($stmt->execute()); var_dump($stmt->errorInfo()); } catch (PDOException $e) { print $e->getMessage(); }}
Note: the import package is correct:
Reply content:
Unable to import ???
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'source D:\Server\three\public\export.sql' at line 1
function ImportDB($dbh) { $sql = 'source '.realpath('export.sql'); try { $stmt = $dbh->prepare($sql); var_dump($stmt->execute()); var_dump($stmt->errorInfo()); } catch (PDOException $e) { print $e->getMessage(); }}
Note: the import package is correct:
execute()Only SQL statements can be executed, whileSOURCEHowevermysqlclientBut it is not an SQL statement, so d will fail to execute. we recommend that you directly use phpexecCommand
Which database should I use before import? I need to change the slash of the path to the backslash in cmd. I hope it will help you.