Table 'mdl_sessions' doesn't exist in Moodle - php

my moodle site display 'error reading from database'
after activating debugging in config.php error showed that table with name 'mdl_session'
not exist in database
the error message is:
Debug info: Table 'mniknami_edu.mdl_sessions' doesn't exist
SELECT id, sid, state, userid, lastip, timecreated, timemodified FROM mdl_sessions WHERE sid = ?
[array (
0 => 'lhdasq4iscedtqhvbs5j1lq833',
)]
Error code: dmlreadexception
Stack trace:
line 441 of /lib/dml/moodle_database.php: dml_read_exception thrown
line 996 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1415 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
line 1387 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
line 1366 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 268 of /lib/classes/session/manager.php: call to moodle_database->get_record()
line 79 of /lib/classes/session/manager.php: call to core\session\manager::initialise_user_session()
line 806 of /lib/setup.php: call to core\session\manager::start()
line 35 of /config.php: call to require_once()
line 27 of /login/index.php: call to require()
my moodle work correctly 2 days ago and Since then, I did not make any changes or update to it
why this problem arise and how i can fixed it?
my moodle version is 2.6.1+

Moodle sessions can be stored in differents places : database, files, memcached. According to https://docs.moodle.org/en/Session_handling the "[files] driver is used by default in new installation".
Perhaps that was the case, but something was recently changed in config.php and Moodle is now trying to use the database for sessions?
On a sidenote, using memcached for session makes a huge difference in performance (as said on Moodle's wiki), but the configuration needs to be done in config.php. If you have memcached available, this could fix the problem and make your site faster.

I ran into the same issue. Check if you are running out of free space in your partitions. If so give it some more space or clean up unused files etc. Turn off binary logs in mysql if you can, those can get really big.

Related

PHP mysqli functions fatal ERROR when using the query function

I am programming a website and my current task is to save the text on a mysql server so I can login as admin and then edit the displayed text online.
I already got so far that everything works but I have done it using mysql functions. Now changed all those functions to mysqli ones, since I heard those are way better.
Here is my mysql_connect.php which I created so I could include this in the other scripts wherever I need to connect to the server:
mysql_connect.php
This is my block1_aboutme.php file, where I connect to the server and request all the text from it so I can display it on my "about me" page. This also works as intended and it properly displays the text on my page.
block1_aboutme.php
The problem is when I login as an admin a part of the login verification is this code below in my class.login.php script. As soon as I am logged in and go to my aboutme page an error occurs:
Fatal error: Uncaught Error: Call to a member function query() on unknown in C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php:84 Stack trace: #0 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(73): Login->verifyDatabase() #1 C:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php(36): Login->verifySession() #2 C:\xampp\htdocs\mywebsites\LuPaw\aboutme.php(42): Login->isLoggedIn() #3 {main} thrown inC:\xampp\htdocs\mywebsites\LuPaw\admin\class.login.php on line 84
This error refers to line 84 which is the $data = $db-> query("select stuff") function.
Somehow this does not work here, while the nearly exact same code line does work in the block1_aboutme script.
I would place the link of my 3rd script here but I can't since I don't have reputation pints yet to place 3 links in one post. Will post 3rd picture in the comments.
I already tried out a few things. If I for example echo out the "$path" it shows the correct path which means $db should be a viable variavble.
Does anyone see the problem here?
Try not to use include_once in your class method as the file will not be included if anywhere during the script execution has been already included: use include instead.
Anyway this is not the best solution you can achieve, I can suggest you to implement a DB class as a singleton and then retrieve the database instance in order to execute your queries.

how to see which line caused warning in PHP

I am using a code where code is in code.php and the user defined functions are stored in function.php.
The functions are called multiple times.
While executing the code in code.php - I got the following error message.
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\SanskritVerb\function.php on line 1177
the line 1177 of function.php falls inside a user defined function 'ends'.
How can I know which line of code.php called this function 'ends' ?
I think some languages show error like - Error in line X of function.php called in line Y of code.php
If something of this sort exists for PHP - it would save my debug time.
For such a task you need to assign an error handler and call
Exception::getTrace()
to get trace of Exception. see the documentation set_error_handler.
Using xdebug extension for PHP can give you higher tracing capabilities even without error. If you choose xdebug you should enable tracing by adding lines to php.ini
xdebug.auto_trace=On
xdebug.trace_output_dir=c:\path
Anyway this is up to you.

Moodle 2.4.2 Coding Error detected when using Course Bulk upload

I tried course bulk upload plugin for creating courses using CSV in moodle 2.4.2.
But the course created shows error in debugging mode. Is there any solution for this issue.
Coding error detected, it must be fixed by a programmer:
Invalid string compontent. Please check your string definition More information
about this error
Debug info:
Error code:
codingerror Stack trace:
•line 11176 of \lib\moodlelib.php: coding_exception thrown
•line 812 of \lib\outputrequirementslib.php: call to lang_string->__construct()
•line 848 of \lib\outputrequirementslib.php: call to page_requirements_manager->string_for_js()
•line 4575 of \course\lib.php: call to page_requirements_manager->strings_for_js()
•line 282 of \course\view.php: call to include_course_ajax()
Thanks in Advance
Vinoth
The Error may be due to the theme section i used. I tried to use the different form of CSV only with Category, shortname, desscription, format etc. And now the courses are created successfully with no error.
It solved my problem.
Thanks
Vinoth

PHP MySQL Session

we moved our website to a new server that came with a new IP address. What puzzles me; the website login sessions do not work on the new server but when I change the database IP to the old server they are working.
MySQL Version
Old server = 5.1.58- Community
New server = 5.1.68 - Community
At first I thought it was a PHP error but I now believe it's not and suspect its MySQL related. Anyone who knows what might have caused this conflict?
Debugging Error
Notice: A session had already been started - ignoring session_start() in C:\inetpub\wwwroot\gtest\libs\products.php on line 2
Notice: Undefined index: uUserTypeID in C:\inetpub\wwwroot\gtest\admin\index.php on line 50
Notice: Undefined offset: 0 in C:\inetpub\wwwroot\gtest\admin\index.php on line 52
Notice: Undefined offset: 0 in C:\inetpub\wwwroot\gtest\admin\index.php on line 52
Line 50
GetUserType($_SESSION['uUserTypeID'], $UserTypeID, $UserTypeDescr, $Active_Tag);
Line 52
if (($UserTypeDescr[0] == 'Admin') || ($UserTypeDescr[0] == 'Report'))
Let's go through the notices in order:
session_start() was already called before. No need to call it again.
There's no such variable as $_SESSION["uUserTypeID"]. It's not set.
The array at $UserTypeDescr doesn't have a 0 index. It's probably empty. If you got it from a database query, it either failed or returned an empty resultset.
Same as 3.
Notice: A session had already been started - ignoring session_start() in C:\inetpub\wwwroot\gtest\libs\products.php on line 2
At a guess session.auto_start is enabled hence the session is being enabled before the session handler is overridden (or the new session handler is failing).
The most safest method of preventing such error (i.e. Session already started) is by always checking if session has already been started before starting a session.
You can do this by simply including
if (!isset($_SESSION))session_start();
I hope this solve the problem? upon trying it, you can simply add your comment or observations to further improve the answer and above all, solve the probelm. I hope this helps?

Modx: Catchable fatal error: Argument 2 passed to modParser::collectElementTags() must be of the type array, null given

Just started with new project and want to try ModX to use it for the project but get stuck on this error (it won't disappear) :
**Catchable fatal error: Argument 2 passed to modParser::collectElementTags() must be of the type array, null given, called in D:\Personal\illumation\modx\core\model\modx\modstaticresource.class.php on line 57 and defined in D:\Personal\illumation\modx\core\model\modx\modparser.class.php on line 101**
It went wrong at the moment I want to try to write a plugin so i created a new plugin in the Manager in an external file called webit-core-plugin.php. Add one event to it and save it. After this, the error described above appear.
Tried to remove it, do it again etc, nothing helps. Does anybody know what is going on?
I use the latest XAMPP, latest SQL/PHP and lastest ModX running on localhost (windows 7) with adminstrator privileges.
Clear Cache folder manually by deleting it through file browser
Open your SQL client, check your elements (templates - *modx_site_templates*, chunks - *modx_site_htmlsnippets*, snippets - *modx_site_snippets*, and plugins - *modx_site_plugins*) that have "static" field = 1, but have "static_file" empty.

Categories