Call to undefined function XML_unserialize() - php

I'm making search engine in php for ranking my site by Yahoo API key.
I have just got an error like this:
Fatal error: Call to undefined function XML_unserialize() in E:\wamp\www\Yahoo\search.php on line 113
What should I do?

It sounds like an XML library you're including was not properly included, so this function was not found when it was called.
Try running your code with
error_reporting(E_ALL);
at the top of the script, and it will show all warnings. This should tell you if there were any failures to find include files.

Few things:
Maybe you haven't included the file, where the XML_unserialize() function is.
You have a typo in the function name.

Related

Why im getting function redeclared fatal error when i have declared it only once?

function createStudentMarks($key)
{ echo "key".$key;exit; }
This is my function.
$StudentMarks=createStudentMarks($key);
And i have called function in same file like this n im getting fatal error. Y is it so can anyone please help me
Cannot redeclare createStudentMarks() (previously declared in /var/www/html/2016/S/Mcd_BuildStudentsMarks.php:85) in /var/www/html/2016/S/Mcd_BuildStudentsMarks.php on line 85 This is the error wat im getting exactly
Most of the times, this is caused by accidentally requireing or includeing a file more than once.
This generally shows bad coding behavior, so first try to find if this is the case or not. Try to eliminate the second and so on requires or includes.
In any case, you can work around it but using include_once or require_once, which will not include the file on second or next calls.

ModX Evo: PHP error in document.parser.class.inc.php

So my Evo site stopped working the other day - just got a 500 error. I got my host to check the logs and found this:
[error] PHP Fatal error: Cannot redeclare insert_metka() (previously declared in
/home/mysite/public_html/manager/includes/document.parser.class.inc.php(790) : eval()'d code:2)
in /home/mysite/public_html/manager/includes/document.parser.class.inc.php(790) : eval()'d code on line 12
I have tired commenting out the offending line and removing the entire file to no avail. Does anyone know what this means and how to fix it?
EDIT: the code at line 790:
eval ($pluginCode);
Looks like a bad plugin has broken your site. Disable all your plugins and reinstate them one at a time until it breaks again, then you know which one is the culprit.
Once you've done that, post the plugin code here and we can help you debug it further. You shouldn't ever need to modify the MODX source code.
The problem is likely to be solved by wrapping the insert_metka() declaration like this:
if(!function_exists('insert_metka')) {
function insert_metka() {
// function code
}
}
http://wiki.modxcms.com/index.php/Creating_Snippets#Wrap_functions_inside_.21function_exists_conditional_if_the_resource_is_needed_to_run_more_than_once_on_a_page
That appears like a very simple problem. You are declaring insert_metka() two times. Remove it from one of the mentioned files. Once it is declared in saved file and apparently second time you are trying to declare it with the help of eval()
Cannot redeclare insert_metka() says that you are declaring a function twice (may be with your evals).
You should check on your included files.
To be sure to not include more than one time, you can use include_once or requiere_once instead of include and requiere
Accoring to document.parser.class.inc.php this line i guess you are using OOP.
So what you can do is create instantiation class for above class and then overwrite it.
There are other things too. you might declaring same function inside of same class.

function to convert string to integer -- call to undefined function

I am creating a function that converts a users initials (STRING) to their userid (INT)
problem is when I call the function I get a call to undefined func error because the below declared function is no where to be found in the Source!
// connect to database -- this works, I checked it
function convertRadInitToRadID($radInits){
$sqlGetRadID="SELECT id FROM sched_roster WHERE radInitials == '".$radInits."'";
$resultGetRadID=mysql_query($sqlGetRadID);
$radID=mysql_result($resultGetRadID,0);
return $radID;
}
...I then create and array ($radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter) of user initials, it works with no errors I tested it independently
$randKey=rand(0,(count($radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter)-1));
$randRad=$radNotOnVacay_and_NonMRNotonVacayWeekBeforeAndAfter[$randKey];
$randAssignedRadID=convertRadInitToRadID($randRad); // call to undefined function error here
when I view source the function definition code (where I define the function) is nowhere to be seen in the source. Very strange. I tried placing it around different areas of the script, same error. The function definition is declared appropriately and is wrapped in .
Very strange. The function just doesn't appear. Quotations, syntax, semi-colons, etc are all spot on.
No syntax errors. Advice?
I Strongly agree with Answer #1.
In addition a usual problems occur in php if you are defining function after calling it. i.e. your calling code is before function defination then it will not run and will give an error of undefined function.
You can create a class then define this function in that class and on the time of calling you can call that function with help of $this->function(args)
I think this will resolve your problem in mean while i am trying to run your code on my machine, lets see what happen
May be your function is a method of some class. So, if it is, you should use it in another way:
MyClass::convertRadInitToRadID($radInits) // if static method
or like this
$class = new MyClass();
$class ->convertRadInitToRadID($radInits)
Trying to make sense of your question... Are you trying to call the function using JavaScript? If so, remember that JavaScript is run on the browser, and PHP is run on the server (and this is why when you "view source" you don't see the function anywhere). To send data back from JavaScript to PHP you should use AJAX.
I found the answer: I was using Jquery UI tabs.... there must be a conflict with tabs. When I run the code without tabs there is no issue.
Thanks for the '==' fix.. appreciate it. my bad
thanks for reminding me about the 80 char varname code limit

Getting PHP Fatal error

I am getting the following error: PHP Fatal error: Call to undefined function updateRecord()
I know that means that PHP is unable to locate the function I am calling.
I double checked the spelling of the function name and the include file at the top of the page, and both are correct. I am not sure why PHP isn't recognizing the function in the included file.
Here is the code:
include_once('../lib/updatesEngine_lib.php');//include the file with the function
The function call:
updateRecord($jobid);
In updatesEngine_lib.php:
function updateRecord($jobid){//Code//}
I'm at a loss for why this isn't working. Especially since there are other functions in the updateEngine_lib.php file that are structured similarly that are working.
HELP!
Check your spelling for the third time or until you get it work.
There is no magic.
If it says "Call to undefined function" - so it is.
BTW, what if you call this function from updatesEngine_lib.php - does it work?

PHP-Yii: Using Yiis logger when a request is not completed due to php level error

This is probably a yii specific question, even though I wouldn't surprised if experienced non-Yii we developers will be also able to contribute.
I often encounter the following situation:
My application fails due to a fatal error on the php level. Something like $var->property when $var==null
I want to understand how $var came to be ==null.
I'd use logs for this, however, problem is that no logs are left when a request is ended due to php error.
edit: this only happens for fatal errors. For other php errors I have my logs back
An example:
For
$nonExistingVar->someProperty;
I do have my logs recorded, as it yields PHP Error Undefined variable: nonExistingVar
However, if I do define the variable and set it to null,
$tmp = null;
$tmp->prop;
Then I loose the logs, as it results in "Fatal error: Call to a member function hasErrors() on a non-object"
Does anybody understand why does it happen? And how can the logger be anyway used in this situations? I tried setting autoFlush=1, doesn't help
Thanks
Gidi
The below allowed me to have my logs even on fatal errors:
function yiiCorrectShutdown()
{
Yii::app()->end();
//the following line will work as well
//Yii::app()->log->processLogs(null);
}
register_shutdown_function('yiiCorrectShutdown');
I wrote an extension class that logs in real-time thus avoiding any need to modify flow paths. I posted it here on the Yii Wiki

Categories