An argument to be passed on the mktime built-in function in PHP. How to pass an argument in a mktime function - function

Actually, I was trying to run a PHP script on a local server, but unfortuantely i encountered this error
Fatal error: Uncaught ArgumentCountError: mktime() expects at least 1 argument, 0 given in C:\xampp\htdocs\SimplePharmacy-PHP\home.php:240 Stack trace: #0 C:\xampp\htdocs\SimplePharmacy-PHP\home.php(240): mktime() #1 {main} thrown in C:\xampp\htdocs\SimplePharmacy-PHP\home.php on line 240
Below is the PHP code that I was refereed to from my source code.
<?php
$Today = date('y:m:d',mktime()); // Line 238
$new = date('l, F d, Y', strtotime($Today));// Line 239
echo $new; // Line 240
?>
I am trying to disply the current date date and year

Related

Run Octave function form shell

It is possible to write a function directly in the octave shell?
A=147;
B=26.3;
C=5.4;
d=0.35*A;
function S=function_test(A,B,C,d)
S=2*A*B*C*d;
end
I tried this but if I wanted to know the value of "S", this error appears:
error: 'S' undefined near line 1, column 1
Yes it is possible. You does it correctly. But you missed indicating how you call the function. For me, no error occurs:
≫ function_test(1,2,3,4)
ans = 48
≫ res = function_test(1,2,3,4)
res = 48
≫ S = function_test(-1,3,5,7)
S = -210
≫

Octave error (error: max_recursion_depth exceeded) how to fix it?

I have run the following code in the Octave (Octave-6.2.0 (Local) (GUI)) and the output is shown. I have made an error intentionally, but when I fix it, it does not recognize it. Even when I have copied and pasted the following code which does not have an error it shows the same error message. By the way, it can be solved if I close Octave and open it again.
P=[1200 3000 4200 5500];
I=[10000];
function result = irrm(P,I)
result = 100*irr(P,I)
end
irrm(P,I);
Output:
>> rr
result = 11.798
The code with an error is:
P=[1200 3000 4200 5500];
I=[10000];
function result = irr(P,I)
result = 100*irr(P,I)
end
irrm(P,I);
The output of the code with an error is:
>> rr
error: max_recursion_depth exceeded
error: called from
irr
irr at line 5 column 10
irrm at line 5 column 10
rr at line 7 column 1

incremental search method script errors

I wrote my very first octave script which is a code for the incremental search method for root finding but I encountered numerous errors that I found hard to understand.
The following is the script:
clear
syms x;
fct=input('enter your function in standard form: ');
f=str2func(fct); % This built in octave function creates functions from strings
Xmax=input('X maximum= ');
Xinit=input('X initial= ');
dx=input('dx= ');
epsi=input('epsi= ');
N=10; % the amount by which dx is decreased in case a root was found.
while (x<=Xmax)
f1=f(Xinit);
x=x+dx
f2=f(x);
if (abs(f2)>(1/epsi))
disp('The function approches infinity at ', num2str(x));
x=x+epsi;
else
if ((f2*f1)>0)
x=x+dx;
elseif ((f2*f1)==0)
disp('a root at ', num2str );
x=x+epsi;
else
if (dx < epsi)
disp('a root at ', num2str);
x=x+epsi;
else
x=x-dx;
dx=dx/N;
x=x+dx;
end
end
end
end
when running it the following errors showed up:
>> Incremental
enter your function in standard form: 1+(5.25*x)-(sec(sqrt(0.68*x)))
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
error: wrong type argument 'class'
error: str2func: FCN_NAME must be a string
error: called from
Incremental at line 4 column 2
Below is the flowchart of the incremental search method:
The problem happens in this line:
fct=input('enter your function in standard form: ');
Here input takes the user input and evaluates it. It tries to convert it into a number. In the next line,
f=str2func(fct)
you assume fct is a string.
To fix the problems, tell input to just return the user's input unchanged as a string (see the docs):
fct=input('enter your function in standard form: ', 's');

Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Model_Design_Package::getPackageByUserAgent()

I was getting a 500 error once I moved my magento 1.9 install from an old server to a new server. The old server was running php5 and this one is on 7. I am now getting the following error and I know I have to change some of the code, but I am not sure what:
Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Model_Design_Package::getPackageByUserAgent() must be of the type array, object given, called in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php on line 576 and defined in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php:586 Stack trace: #0 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(576): Mage_Core_Model_Design_Package::getPackageByUserAgent(Object(Zend_Log), 'design/theme/te...') #1 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(262): Mage_Core_Model_Design_Package->_checkUserAgentAgainstRegexps('design/theme/te...') #2 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(287): Mage_Core_Model_Design_Package->getTheme('template') #3 /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(420): Mage_Core_Model_Design_Package->updateParamDefaults(Array) #4 /home1/acapps/flagstuff.com/app/code/core in /home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php on line 586
This is the code that starts on line 586 of Package.php
public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')
{
foreach ($rules as $rule) {
if (!empty(self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']])) {
self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];
return $rule['value'];
}
$regexp = '/' . trim($rule['regexp'], '/') . '/';
if (#preg_match($regexp, $_SERVER['HTTP_USER_AGENT'])) {
self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']] = true;
self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];
return $rule['value'];
}
}
return false;
}
Turns out I needed to change this:
public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')
to this
public static function getPackageByUserAgent($rules, $regexpsConfigPath = 'path_mock')
after that, it worked like a charm

Tumblr Oauth returning 401 on API v2

I'm trying to set up an automatic tumblr post every time I add something new to my website. I'm using the following code:
$conskey = "APIKEY";
$conssec = "APISECRET";
$tumblr_blog = "blogname.tumblr.com";
$to_be_posted = "This is the text to be posted";
$oauth = new OAuth($conskey,$conssec);
$oauth->fetch("http://api.tumblr.com/v2/blog/".$tumblr_blog."/post", array('type'=>'text', 'body'=>$to_be_posted), OAUTH_HTTP_METHOD_POST);
$result = json_decode($oauth->getLastResponse());
if($result->meta->status == 200){
echo 'Success!';
}
As far as I can tell this is all formatted correctly. However this is the first time I've tried to connect up to a JSON API using Oauth so I'm not totally confident in what I'm doing.
This is the exact error I'm receiving:
Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)' in /home/public_html/edge/tumblr.php:35 Stack trace: #0 /home/public_html/edge/tumblr.php(35): OAuth->fetch('http://api.tumb...', Array, 'POST') #1 /home/public_html/edge/index.php(95): include('/home/...') #2 {main} thrown in /home/public_html/edge/tumblr.php on line 35
Line 35 is the line beginning with $oauth->fetch.
Thanks for any help :-)
EDIT
I've solved the issue by substituting my previous code with the example on this page