I am new to moodle. I am trying to query the moodle database using my own PHP scripts. I am using the data manipulation API but i can't seem to fetch anything. What are the steps i should take to accomplish this. I have seen a number of guidelines here and there that I should include the config.php file in moodle so as to access the $DB global variable and hence access the functions of the DML API. The following is my code:
<?php
require '../config.php';
global $DB;
$user= $DB->get_record_sql('SELECT * FROM {mdl_user} WHERE id=?', array(4));
echo mysql_num_rows($user);
?>
I get the following error when I try to run it on TextMate editor:
PHP Warning: require(../config.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/moodle24/sbs_android_app/database_manipulation.php on line 2
PHP Fatal error: require(): Failed opening required '../config.php' (include_path='.:') in /Applications/MAMP/htdocs/moodle24/sbs_android_app/database_manipulation.php on line 2
I will appreciate the help...Thanks.