Fatal error: Call to undefined function drupal_get_path() - php

After updating our server to PHP 5.4 and a Drupal site to Drupal 6.37 I keep getting this error message and I am not able to get past it
Fatal error: Call to undefined function drupal_get_path() in /home/mysite/public_html/includes/module.inc on line 285
this is the related function call
function module_load_include($type, $module, $name = NULL) {
if (empty($name)) {
$name = $module;
}
$file = './'. drupal_get_path('module', $module) ."/$name.$type";
if (is_file($file)) {
require_once $file;
}
else {
return FALSE;
}
}
Even when I try to run update.php I still get the same error
I am new to Drupal so any help will be greatly appreciated
Please let me know what additional info you may need since it is my first post here and as I said I don't know much about Drupal

Related

php 7.0 fatal error Call to undefined method Product::

I try to used to an old customized module in my Prestashop that runs with php 7.0.
I got an error and no idea...
Fatal error: Uncaught Error: Call to undefined method Product::getFrontFeaturesHiddenByNameStatic()
And here is the line of code.
$feature = Product::getFrontFeaturesHiddenByNameStatic((int)($params['cookie']->id_lang), $product['id_product'],'_Descriptif accueil');
And that function is defined in "override" folder.
public static function getFrontFeaturesHiddenByNameStatic($id_lang, $id_product, $featureName) {
self::getFrontFeaturesStatic($id_lang, $id_product);
if( isset(self::$_frontFeaturesCacheHidden[$id_product.'-'.$id_lang]) )
foreach(self::$_frontFeaturesCacheHidden[$id_product.'-'.$id_lang] as $feature) {
if( $featureName == $feature["name"] )
return $feature;
}
return null; // nothing has been found
}
Thanks in advance !
I think I found the solution.
Actually the override definition was not in the right folder.
It was in override/classes and failed, while set in modules/mymodule/override/classes, it seems to work fine...
Thank for your help!

Fatal error: Call to undefined function tep_session_name()

I am trying to update one of the sites I maintain to the latest PHP and during this, I have come across the following error:
Fatal error: Call to undefined function tep_session_name() in ... /includes/application_top.php on line 83
The code it is referring to is:
// set the session name and save path
tep_session_name('osCAdminID');
tep_session_save_path(SESSION_WRITE_DIRECTORY);
But I have looked at the sessions.php file are the function is defined in the below code:
function tep_session_name($name = '') {
if ($name != '') {
return session_name($name);
} else {
return session_name();
}
}
Any help in identifying the cause would be greatly appreciated.
Thanks, E.
I'm absolutely sure, that you call this function before you include file with function declaration

How to resolve Call to undefined method stdClass::save()

I am currently working on Yii. I want to check that if some value is exists into database then echo something otherwise save into database.
I am doing:
$model = Users::model()->findByAttributes(array('googleid'=>$google_id));
if($model)
{
echo "Good";
}
else
{
echo $model->googleid = $google_id;
$model->save();
}
But when I am running this code then I am getting error :
Fatal error: Call to undefined method stdClass::save() in E:\wamp\www\customers\protected\views\users\googlelogin.php on line 76
What may be the reason for this error, I am unable to figure out, please help me
Thanks in advance
I got the solution, I was making a mistake that $model was returning a NULL value and I was insterting the value in that model, the following solution made my work :
$model = Users::model()->findByAttributes(array('googleid'=>$google_id));
if($model)
{
echo "Good";
}
else
{
$model_new = new Users;
echo $model_new->googleid = $google_id;
$model_new->save();
}
Thanks for the responses

Issue in the Mapper Code in Zend Frame Work

Notice: Undefined variable: entryMessage in /var/www/Employee/application/models/EmployeeMapper.php on line 34 Fatal error: Call to a member function setEmployeeId() on a non-object in /var/www/Employee/application/models/EmployeeMapper.php on line 34
This is the error i am getting i try to display the entered fields , I checked the database and the fields are getting saved , I am posting the Employee Mapper .Please check the code and tell a solution , thanks in advance
class Application_Model_EmployeeMapper
{
protected $_dbTable;
public function setDbTable($dbTable)
{
if (is_string($dbTable)) {
$dbTable = new $dbTable();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid table data gateway provided');
}
$this->_dbTable = $dbTable;
return $this;
}
public function getDbTable()
{
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_Employee');
}
return $this->_dbTable;
}
public function fetchAll()
{
$table = $this->getDbTable();
$resultSet = $table->fetchAll($table->select()->order('EMPLOYEE_ID'));
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_Employee();
$entryMessage->setEmployeeId($this->$row->EMPLOYEE_ID)
->setFirstName($row->FIRST_NAME)
->setLastName($row->LAST_NAME)
->setEmail($row->EMAIL)
->setPhoneNumber($row->PHONE_NUMBER)
->setHireDate($row->HIRE_DATE)
->setJobId($row->JOB_ID)
->setSalary($row->SALARY);
$entries[] = $entry;
}
return $entries;
}
public function save(Application_Model_Employee $employee)
{
$data = array(
'EMAIL' => $employee->getEmail(),
'FIRST_NAME' => $employee->getFirstName(),
'LAST_NAME' => $employee->getLastName(),
'PHONE_NUMBER' => $employee->getPhoneNumber(),
'HIRE_DATE' => $employee->getHireDate(),
'JOB_ID' => $employee->getJobId(),
'SALARY' => $employee->getSalary(),
);
Error you're getting is very clear, you should always read and try to understand the error message that you get, it gives you solution to most of the common problems. So always make a habit of reading and understanding the error message you get. Here,
Notice: Undefined variable: entryMessage in /var/www/Employee/application/models/EmployeeMapper.php on line 34
Notice says, undefined variable; which means that your variable $entryMessage is not defined. And the second part of the error that you are getting:
Fatal error: Call to a member function setEmployeeId() on a non-object in /var/www/Employee/application/models/EmployeeMapper.php on line 34
is very obvious since you are trying to call setEmployeeId() function from $entryMessage which has not been defined, yet you are assuming it to be an object and using it as an object.
I am assuming that $entryMessage you are using should have been $entry
These are quite simple and are not suitable to be asked in SO actually.
Once again, my suggestion to you are,
Always read what the error message says, it is what you are supposed to be using for debugging any bugs in the code
If you are new to programming you should perhaps use IDE's (netbeans,
eclipse, etc..) which actually shows the usage of variables and
function and syntax error in your code.
Always do your part of research and ask question only if not found or successful, and always show what you attempted. Others are there to help you but not to solve everything for you. :)

php Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION on construct

hey guys was hoping you could help me out..
just to let u know in advance, im a relatively new php coder, doing a practice project, and came across this problem and ive spent like an hour of rechecking and googling but just cant figure out whats causing it
error: Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\wamp\www\forum\classes\ClassUser.php on line 7
the segment of the code causing the problem:
include $_SERVER["DOCUMENT_ROOT"]."forum/classes/general.inc";
Class User{
__construct($u,$p){ //this is line 7
$user=$u;
if(strlen($p)>30|| empty($p) || !preg_match('/[^a-zA-Z0-9]/i',$p)){
$password=0;
}
else{
$password=hash_hmac('md5',$p,KEY);
}
}
oh and since im new to php, incase im doing something which i should not be, please to recommend.. thanks in advance.
note:ive removed the php tags since they seemed to be messing with the formatting of this post :/
note2: im also getting another notice
Notice: Use of undefined constant KEY - assumed 'KEY' in C:\wamp\www\forum\classes\general.inc on line 20
but im assuming thats more of a warning than an error... but just adding incase it has something to do with the error
general.inc:
//error definations
define("ERROR_FIELD_EMPTY","Error! All required fields not filled");
define("ERROR_INVALID_SIGNIN","Error! Username/password do not match!");
define("ERROR_GENERAL_INPUT", "Error! Invalid input given");
define("ERROR_SQL_CONNECT","Error! Could not connect to sql database");
//field sizes
define("PASSWORD_LENGTH",12);
define("USERNAME_LENGTH",30);
//sql server details
define("SQL_SERVER_NAME","localhost");
define("SQL_SERVER_USERNAME","root");
define("SQL_SERVER_PASSWORD","");
define("SQL_SERVER_DATABASE","forums");
define(KEY,"key");
function __autoload($className){
require_once($_SERVER["DOCUMENT_ROOT"]."forum/classes/Class$className.php");
}
ClassUser.php
include $_SERVER["DOCUMENT_ROOT"]."forum/classes/general.inc";
Class User{
__construct($u,$p){
$user=$u;
if(strlen($p)>30|| empty($p) || !preg_match('/[^a-zA-Z0-9]/i',$p)){
$password=0;
}
else{
$password=hash_hmac('md5',$p,KEY);
}
}
public function validate(){
if(strlen($user)>30|| empty($user) || preg_match('/[^a-zA-Z0-9]/i',$password==0 )){
throw new Exception(ERROR_GENERAL_INPUT);
}
$user=mysql_real_escape_string($user);
return true;
}
public function insert(){
// this->validate();
$conn= mysqli_connect(SQL_SERVER_NAME,SQL_SERVER_USERNAME,SQL_SERVER_PASSWORD,SQL_SERVER_DATABASE);
if(empty($conn)){
throw new Exception(ERROR_SQL_CONNECT);
}
$query="INSERT into USERS VALUES ($user,$password)";
$conn->query($query);
}
private $user;
private $password;
};
NewUser.php
include $_SERVER["DOCUMENT_ROOT"]."forum/classes/general.inc";
try{
$user = new User($_POST['UserName'],$_POST['Password']);
$user->insert();
}
catch(Exception $Error){
echo $Error->getMessage();
}
Your __construct needs to have the word function in front of it, or better yet public function, in the same way as the other methods in the class (ie validate and insert in your case).
ie you need the following:
public function __construct($u,$p){ //this is line 7
Change the line to:
public function __construct($u, $p) {

Categories