Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Catchable fatal error: Argument 3 passed to Account::updateUser() must
be an instance of , string given, called in
/Applications/XAMPP/xamppfiles/htdocs/myPage/beta/Includes/includes.php
on line 27 and defined in
/Applications/XAMPP/xamppfiles/htdocs/myPage/beta/classes/Account.php
on line 214
Line 27:
$Account->updateUser($_SESSION["username"], $_POST["password_check"], $_POST["pw1"], $_POST["pw2"]);
Line 214:
public function updateUser($session, $password_check, $pw, $pw2){
How may I fix this? I've tried to rewrite the code multiple times, and tried to change everything on line 214 and below. Also tried to change some of line 27, cannot find the problem and have googled for a long time.
I think there is an invisible character (something like an unbreakable space, or some other invisible utf8 char) in your function declaration and php think it's type hint. You could delete the line and rewrite it. I thnik the probleme is here because must be an instance of , means php want a variable of type "".
Delete and rewrite the function declaration (no copy/paste)
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
So, on my website I'm getting this error:
Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /homepages/4/d661770438/htdocs/awptical/initdata.php:382 Stack trace: #0 /homepages/4/d661770438/htdocs/awptical/index.php(21): require_once() #1 {main} thrown in /homepages/4/d661770438/htdocs/awptical/initdata.php on line 382
Does anybody know what this means?
The function no longer exists in PHP 7, nor the setting it works with, so you will need to remove its usages. You will need to save the current state of your code and try to remove all the instances of this function call and see whether the site is working and if so, whether it is working as you expect it to work. Alternatively, you can implement a dummy version of the function and make it available everywhere:
if (!function_exists('set_magic_quotes_runtime')) {
function set_magic_quotes_runtime($new_setting) {
return true;
}
}
You are using PHP version 7.x.x, at which set_magic_quotes_runtime() was removed.
This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I edited my code with prepared statments(I didn't used them before). I get an error
"Call to a member function bind_param() on a non-object". I googled that error and I found cause - error is caused if query has syntax error. I'm looking last 10 minutes in query and I can't find syntax error. Can somebody help me? Thanks!
// QUERY BEFORE
$_hsync_statment->bind_param("sisssss", $_hsync_ime, $_hsync_id, $_hsync_nista, $_hsync_nista, $_hsync_mail, $_hsync_datum, $_hsync_vrijeme);
if(!$_hsync_statment->execute()) $_hsync_reg_status = -1;
// POVEČAVA BROJ REGISTRIRANIH RAČUNA
$_hsync_statment = $_hsync_konekcija->prepare("UPDATE $_hsync_srv SET Clanova = ?");
$_hsync_statment->bind_param("i", $_hsync_id + 1); // THIS LINE
if(!$_hsync_statment->execute()) $_hsync_reg_status = -1;
I tried to close every statment after it gets executed. That doesn't help.
So what's wrong with
$_hsync_statment->bind_param("i", $_hsync_id + 1); // THIS LINE
The fact that $_hsync_id is a variable that holds an int. when you add 1 to int. It produces an int that's not acceptable to bind_param. bind_param expects an object. Try this:
$_hsplus = $_hsync_id + 1;
$_hsync_statment->bind_param("i", $_hsplus); // THIS LINE
So now why did I get two downvotes when the manual clealy says:
Note that mysqli_stmt_bind_param() requires parameters to be passed by
reference, whereas
The error message Call to a member function bind_param() on a non-object... means that you haven't properly instantiated the object $_hsync_statment before calling bind_params() on it.
have intiated the db connection to the $_hsync_statment
$_hsync_statment = $db->stmt_init();
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have stumbled over the following error in PHP:
"Fatal error: Function name must be a string in
F:\Applications\xampp\htdocs\BTB_Sandbox\uploads.php on line 15"
and I don't know what the real problem is. Here is line 15 that the error is pointing at:
$error = $_FILES(['file_upload']['error']);
I hope you could help me, because I am kind of stuck now.
You are using $_FILES as a function because of ().
That way, PHP tries to call a function named as var $_FILES value, but this value it not a string (that's the error reported), it is an array.
Obviously, in your code line you are failing to use $_FILES, the right way is:
$error = $_FILES['file_upload']['error'];
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
My script is returning the following error...
Fatal error: Cannot redeclare connecttodatabase() (previously declared in /var/www/api/connecttodatabase.php:4) in /var/www/api/connecttodatabase.php on line 6
And the following is the connecttodatabase.php file...
<?php
function connecttodatabase()
{
$con = #mysqli_connect("localhost", "name", "password", "database");
return $con;
}
?>
I don't really understand this error because line 6 is just the closed curly bracket (})
I think the error means that it thinks I declared the function connecttodatabase() in to different spots but clearly I didn't.
As others have said in the comments, this is most likely because you have included connecttodatabase.php twice in your code, and you are certainly defining the function twice. Don't get hung up why it's line 6; line 2 would be more helpful, but line 6 is where the function definition ends, and so arguably is when the function is defined. You could have a "one a day" whole year calendar on the idiosyncrasies of PHP and have enough left over for a sequel. As others have also hinted, some basic debugging would confirm whether you are including the file more than once and also from where.
Make sure that your code uses include_once or require_once.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Update: I have fixed it!
This is a php script to ping a minecraft server.
You can find the code here: http://snippi.com/s/o2awm6x
I am getting the error:
Fatal error: Class 'MinecraftPing' not found in /var/www/html/multicraft/MinecraftServerPing.php on line 21
How do I resolve this issue? I have been trying to fix this, nothing seems to work!
In the beginning I was getting this:
Notice: Constant MQ_SERVER_ADDR already defined in /var/www/html/multicraft/MinecraftServerPing.php on line 3 Notice: Constant MQ_SERVER_PORT already defined in /var/www/html/multicraft/MinecraftServerPing.php on line 4 Notice: Constant MQ_TIMEOUT already defined in /var/www/html/multicraft/MinecraftServerPing.php on line 5 Notice: Constant MQ_SERVER_ADDR already defined in /var/www/html/multicraft/MinecraftServerPing.php on line 3 Notice: Constant MQ_SERVER_PORT already defined in /var/www/html/multicraft/MinecraftServerPing.php on line 4 Notice: Constant MQ_TIMEOUT
I fixed this by replacing the
require
with
require_once
Try using
include(__DIR__ . '/MinecraftServerPing.php');
instead of
require_once DIR . '/MinecraftServerPing.php';
13.
Either MinecraftPing does not exist (as a class), either you are including the wrong files.
It seems you have a inconsistency here. Let me try to explain in a simple way:
You have a file named MinecraftServerPing.php (the one you have posted here), but you also try to include a file with the same name on line 12:
require_once __DIR__ . '/MinecraftServerPing.php';
Either you have the class declared in another file or you have accidentally replaced the file named MinecraftServerPing.php in which MinecraftPing class was declared, with the code you posted.