I'm following the SQLite tutorial on this page http://www.tutorialspoint.com/sqlite/sqlite_php.htm
But I'm getting an error when I run this code
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('test.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
?>
I get this error
Fatal error: Uncaught exception 'Exception' with message 'Unable to open
database: unable to open database file' in C:\inetpub\wwwroot\cdb.php:6
Stack trace:
#0 C:\inetpub\wwwroot\cdb.php(6): SQLite3->open('test.db')
#1 C:\inetpub\wwwroot\cdb.php(9): MyDB->__construct()
#2 {main} thrown in C:\inetpub\wwwroot\cdb.php on line 6
So the error is that the program is not able to create the database but I'm on the inetpub/wwwroot folder and IIS has permissions over it and the turorial doesn't mention anything about permission problems. Any idea why it happens?
Related
I am new to coding, trying to create a simple registration form using php and mysql ..but this error I dont know Why it says the table is read only can somebody help me fix it
This is the error
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1036 Table 'tablename' is read only in C:\xampp\htdocs\Laravel\Project\public\classes\DB.php:15 Stack trace: #0 C:\xampp\htdocs\Laravel\Project\public\classes\DB.php(15): PDOStatement->execute(Array) #1 C:\xampp\htdocs\Laravel\Project\public\create-account.php(14): DB::query('INSERT INTO sig...', Array) #2 {main} thrown in C:\xampp\htdocs\Laravel\Boss\public\classes\DB.php on line 15
and this the DB.php file
class DB{
private static function connect(){
$pdo=new pdo('mysql:host=127.0.0.1;dbname=boss;charset=utf8','root','');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
return $pdo;
}
public static function query($query,$params=array()){
$statement=self::connect()->prepare($query);
$statement->execute($params);
//$data = $statement->fetchAll();
//return data;
}
}
On my webpage I'm using PHP and I run it in Ubuntu 16.04.
It works well.
Then I try to run it on CentOS 5.11 (I know centOS 5.11 is out of date, but for many reasons I must I use it).
And the result is my webpage doesn't work.
I show this error:
Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Permission denied' in /var/www/html/IPU-GUI/website2/templates/sql_login.php:3 Stack trace: #0 /var/www/html/IPU-GUI/website2/templates/sql_login.php(3): mysqli_connect('127.0.0.1', 'root', '123456', 'ipu1') #1 /var/www/html/IPU-GUI/website2/sip.php(30): require_once('/var/www/html/I...') #2 {main} thrown in /var/www/html/IPU-GUI/website2/templates/sql_login.php on line 3
Here is my code:
<?php
require '../functions/server_info.php';
$conn = mysqli_connect($sql_login["host"], $sql_login["username"], $sql_login["password"], $sql_db);
if (!$conn) {
echo mysqli_connect_error();
}
?>
And server_info.php
$sql_login = array(
"host"=>"127.0.0.1",
"port"=>"3306",
"username"=>"root",
"password"=>"123456"
);
$sql_db = "ipu1";
UPDATE: I try to fix this error by change "host"=>"127.0.0.1" to "host"=>"localhost" it works.
But I don't know what wrong? What different from "127.0.0.1" and "localhost".
This is the first time I use parse.com php SDK and I try to execute the following code
<?php require '../autoload.php';
use Parse\ParseObject;
use Parse\ParseClient;
ParseClient::initialize( "Zsr...", "BzM..", "D..." );
$gameScore = new ParseObject("GameScore");
$gameScore->set("score", 1337);
$gameScore->set("playerName", "Sean Plott");
$gameScore->set("cheatMode", false);
try {
$gameScore->save();
echo 'New object created with objectId: ' . $gameScore->getObjectId();
} catch (ParseException $ex) {
// Execute any logic that should take place if the save fails.
// error is a ParseException object with an error code and message.
echo 'Failed to create new object, with error message: ' + $ex->getMessage();
}
?>
But I get that error
Fatal error: Uncaught exception 'Parse\ParseException' with message 'SSL certificate problem: unable to get local issuer certificate' in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php:250 Stack trace: #0 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(925): Parse\ParseClient::_request('POST', '/1/classes/Game...', NULL, '{"score":1337,"...', false) #1 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(836): Parse\ParseObject::deepSave(Object(Parse\ParseObject), false) #2 /opt/lampp/htdocs/parse/src/hola.php(11): Parse\ParseObject->save() #3 {main} thrown in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php on line 250
The code it's the tutorial code, iI haven't changed anything anyone knows what's the problem?
I am also getting same issue. Now I resolve using some other forums answer.
Open your ParseClient.php and find:
curl_init();
And after that add line add:
curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);
It will work.
who can help me i have this error when i want go to the file article.php:
Fatal error: Uncaught exception 'MongoException' with message 'Invalid object ID' in /Applications/XAMPP/xamppfiles/htdocs/www/Site/Test/article1.php:14 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/www/Site/Test/article1.php(14): MongoId->__construct('Notice...') #1 {main} thrown in
beginning of the file article1.php
<?php
$id = $_GET['id'];
try {
$connection = new MongoClient();
$database = $connection->selectDB('test');
$collection = $database->selectCollection('articles');
} catch(MongoConnectionException $e) {
die("Failed to connect to database ".$e->getMessage());
}
$article = $collection->findOne(array('_id' => new MongoId($id)));
?>
You are only catching an exception of the type "MongoConnectionException" while the code is throwing a more generic "MongoException"
Catch(MongoException $e)
I have a php script who inserts documents in gridfs.
in this DB i have 1346214 document.
when i run this script for adding 10500 document i have this error
PHP Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: 127.0.0.1:27017: Cannot assign requested address' in /root/upload.php:5
Stack trace:
#0 /root/upload.php(5): Mongo->__construct('127.0.0.1:27017')
#1 {main}
thrown in /root/upload.php on line 5
in mongod.log i have this message
2014-05-08T12:24:13.537+0200 [initandlisten] connection accepted from 127.0.0.1:57221 #93806 (63 connections now open)
2014-05-08T12:24:13.538+0200 [conn93806] authenticate db: uniform_server { authenticate: 1, user: "user", nonce: "xxx", key: "xxx" }
2014-05-08T12:24:13.538+0200 [conn93806] Failed to authenticate user#uniform_server with mechanism MONGODB-CR: AuthenticationFailed UserNotFound Could not find user user#uniform_server
2014-05-08T12:24:13.538+0200 [conn93806] end connection 127.0.0.1:57221 (62 connections now open)
have you any idea about this problem?
Thanks
This is the content of the php script and i run it 10500 via this command for i in {1..10500..1}; do php upload.php; done
<?php
$conn = new Mongo("127.0.0.1:27017"); // Connect
$db = $conn->uniform_server; // Select DB
$db->authenticate("user","passwd"); // Authenticate to MongoDB
$grid = $db->getGridFS(); // Initialize GridFS
$tab_pj = array("document0.pdf",
"document1.tif",
"document2.doc",
"document3.png",
"document4.JPG",
"document5.xls",
"document6.rar",
"document7.ppt",
"document8.rtf"
);
$pj_id = rand(0,8);
$name = $tab_pj[0]; // Get Uploaded file name
$id = $grid->storeFile($name); // Store uploaded file to GridFS
$conn->close(); // Close connection
exit(0);
?>