I think you need to install the PHP Mongo drivers on that server that's trying to access MongoHQ or MongoLab. http://php.net/manual/en/mongo.installation.php
accessing mongodb remotely? unable to do so
-
04-10-2022 - |
質問
I am slightly new to the mongodb scene. what i am trying to do is accessing to my database hosted on MONGOHQ. the page to access it is hosted on a different server and i get the following message every time i visit the web page:
> Fatal error: Class 'Mongo' not found in [location] on line 3
The question is i tried installing the mongo extension on my php.ini file, is there anything else i should be doing?
The code goes as follows:
<?php
$m = new Mongo("mongodb://myusername:mypassword@location.mongolab.com:27419/");
$dbname = "mydata";
// Connect to database
$db = $m->$dbname;
if (isset($_POST['amount'])){
$mydata->insert(array(
"name" => $_POST['name'],
"job" => $_POST['job']
));
}
?>
<form method="POST">
<p>Name: <input type="text" name="name"></p>
<p>Job: <input type="text" name="job"></p>
<p><button>ADD</button></p>
</form>
解決
所属していません StackOverflow