开发者

pdo connection in php file executed in terminal does not work

I have a php file that if executed in the browser works just fine but when I execute it in the terminal,

php /opt/lampp/htdocs/xampp/site_name/update_db.php

the pdo include and connection do not seem to work because I get the error

could not find driverPHP Fatal error: Call to a member function prepare() on a non-object in /opt/lampp/htdocs/xampp/site_name/update_db.php on line 8

update_db.php

include("roc/include/connection.php");
$db = new PDOConnectionFactory();
$conn = $db->getConnection();

//prepare for utf8 characters
$sql = 'SET NAMES utf8';
$stmt = $conn->prepare($sql);
$result=$stmt->execute();

$sql = 'SET CHARACTER SET utf8';
$stmt = $conn-开发者_开发技巧>prepare($sql);
$result=$stmt->execute();
//**************************


 $sql = 'update video SET
status=? WHERE file_name=?';
$stmt6 = $conn->prepare($sql);
$result=$stmt6->execute(array('1','5cca985383047644f51c4f31d906c8f8'));

Anyone have any ideas?


This topic has been Solved. Read Comments.


Sounds like permission issue. When you execute script from the browser, executing user is usually your web server (i.e. Apache) when you execute it from the console - logged-in user is executing it.


Yep, on the command line you need to set a path or use absolute paths.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜