Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
Hi, I am following this guide and copying exactly what is posted (except the author forgot some curly brackets, and I changed passwords etc). My problem is in the register.inc.php file.
Here is the following error I receive when a user tries to register
Call to a member function prepare() on a non-object in /home/ / /includes/register.inc.php on line 48
Line 48 of the file is
$stmt = $members_mysqli->prepare($prep_stmt);
Here is the entire register.inc.php file:
http://pastebin.com/YcQ7unb0 (It's not being properly formatted on this site)
$members_mysqli is probably a typo. It was never created. You use another variable named $mysqli. Maybe that's the one you meant to use. Check your include files and make sure you actually instantiated $members_mysqli.
The "call to member function on non-object" error is thrown when you try to use an uncreated/uninstantiated variable as an object.
For example:
// create an object
$blah = new Blah();
// call a function on it
$blah->doSomething();
// no error, because $blah exists. however, if my next line is:
$blue->doSomething();
// I'd get an error because $blue was never created
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
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.
Closed 6 years ago.
Improve this question
I receive the following error message when I attempt to call a function which I need to push an object into an array:
array_push() expects parameter 1 to be array, null given
Any clues why this is happening? Thank you in advance :)
<?php
$programming = array();
//some unrelated lines of code here inbetween
function createProgramming($data){
global $programming;
$prog = new Programming($data);
array_push($programming, $prog);
}
?>
//random HTML here
<php?
createProgramming("str");
?>
//more html
$programming is only referenced in the code at those three locations present in my extract above.
That code works fine. There are few things that could make it break:
$programming is redefined / unset before createProgramming() is called
$programming is not defined in the global scope
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
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.
Closed 6 years ago.
Improve this question
I'm getting this error and I can't make head or tail of it.
The exact error message is:
function kdrusha_theme_create_page() {
require_once(get_template_directory().= '/inc/pages/kdrusha-settings.php');
}
add_menu_page("KD Rusha Options", 'KD Rusha', 'manage_options', 'kdrusha-options', 'kdrusha_theme_create_page','',99);
The problem is that you're using .=.
something .= something_else
is shorthand for
something = something . something_else
But your something is a function call, and it generally doesn't make sense to assign to a function call (the exception is when it returns a reference).
You should just use ., which concatenates its parameters and returns the result without assigning it anywhere.
require_once(get_template_directory() . '/inc/pages/kdrusha-settings.php');
You need to put your function return in some variable:
function kdrusha_theme_create_page() {
$template = get_template_directory();
require_once($template.'/inc/pages/kdrusha-settings.php');
}
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 is not reproducible or was caused by typos. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
I have the following PHP code:
private $settings;
private function __construct($settings) {
$this->$settings = $settings;
print "Created compiler";
}
Where the received $settings is an associative array loaded from a JSON file, the thing is a keep getting this error (Note is implementing a singleton pattern):
Catchable fatal error: Object of class stdClass could not be converted to string
I'm sure this is a silly question, but I'm completely stuck at this moment...
The variable is defined as
private $settings;
Now inside the constructor or within the same class you can access the member variable as
$this->variable_name ;
Note that you do not need to have a $ before the variable name.
So in your case you should do as
$this->settings ;
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.