mistake call to a member function query() on a non-object
there is the mistake call to a member function query() on a non-object
$resut = $mysqli->query("SELECT users FROM $gid WHERE $gid.id != 1 ");
$myro = mysqli_fetch_assoc($resut);
function insertLogin($myro)
{
while ($myro == true) {
$myroq = $myro['users'];
$result = mysqli_query($mysqli, "SELECT * FROM users WHERE users.login='$myroq'");
$myros = mysqli_fetch_assoc($result);
$orgroupcountnew = $myros['orgoup'] + 1;
$gncountnew = $myros['gn'] + 1;
$rest = $mysqli->query("UPDATE users SET balance ='$balance', gn = '$gncountnew', orgroup = '$orgroupcountnew' WHERE users.login= '$myroq'");
}
}
The $ mysqli variable is declared at the very beginning of the document.
$mysqli = new mysqli ("127.0.0.1:3306", "root", "", "mybase");
$mysqli->query("SET NAMES 'utf8'");
and when calling this function, insertLogin ($ myro); shows that the error in this line
$rest = $mysqli ->query("UPDATEusersSETbalance='$balance',gn= '$gncountnew',orgroup= '$orgroupcountnew' WHEREusers.login= '$myroq'");
although a similar request is being called before, but by a slightly different method (moreover, if $ result = mysqli_query is rewritten to $ mysqli -> query, it will generate an error in this line, but if you remake $ rest = $ mysqli -> query to mysqli_query, nothing will not work at all, the page freezes on reboot and that's it.
I read what needs to be done through the global variable and so on, but it does not work because I insert global $ mysqli into the function, the page hangs again. The problem is that this is not all code and the connection cannot be closed and reopened, the rest does not work. Help and explain what needs to be done.
i tried by another way but it still doesn't work
function insertLogin ($resut) {
while (($myroq = $resut-> fetch_assoc()) != false) {
$myroq = $resut['users'];
$resut = $mysqli->query("SELECT `users` FROM `$gid` WHERE `$gid`.`id` != 1 " );
insertLogin ($resut);
and like this
function insertLogin($myro, $mysqli)
but the page is freezed again. Please help.
php mysqli
|
show 4 more comments
there is the mistake call to a member function query() on a non-object
$resut = $mysqli->query("SELECT users FROM $gid WHERE $gid.id != 1 ");
$myro = mysqli_fetch_assoc($resut);
function insertLogin($myro)
{
while ($myro == true) {
$myroq = $myro['users'];
$result = mysqli_query($mysqli, "SELECT * FROM users WHERE users.login='$myroq'");
$myros = mysqli_fetch_assoc($result);
$orgroupcountnew = $myros['orgoup'] + 1;
$gncountnew = $myros['gn'] + 1;
$rest = $mysqli->query("UPDATE users SET balance ='$balance', gn = '$gncountnew', orgroup = '$orgroupcountnew' WHERE users.login= '$myroq'");
}
}
The $ mysqli variable is declared at the very beginning of the document.
$mysqli = new mysqli ("127.0.0.1:3306", "root", "", "mybase");
$mysqli->query("SET NAMES 'utf8'");
and when calling this function, insertLogin ($ myro); shows that the error in this line
$rest = $mysqli ->query("UPDATEusersSETbalance='$balance',gn= '$gncountnew',orgroup= '$orgroupcountnew' WHEREusers.login= '$myroq'");
although a similar request is being called before, but by a slightly different method (moreover, if $ result = mysqli_query is rewritten to $ mysqli -> query, it will generate an error in this line, but if you remake $ rest = $ mysqli -> query to mysqli_query, nothing will not work at all, the page freezes on reboot and that's it.
I read what needs to be done through the global variable and so on, but it does not work because I insert global $ mysqli into the function, the page hangs again. The problem is that this is not all code and the connection cannot be closed and reopened, the rest does not work. Help and explain what needs to be done.
i tried by another way but it still doesn't work
function insertLogin ($resut) {
while (($myroq = $resut-> fetch_assoc()) != false) {
$myroq = $resut['users'];
$resut = $mysqli->query("SELECT `users` FROM `$gid` WHERE `$gid`.`id` != 1 " );
insertLogin ($resut);
and like this
function insertLogin($myro, $mysqli)
but the page is freezed again. Please help.
php mysqli
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
1
Also,$mysqlidoes not exist within thefunction insertLoginscope. More information on variable scopes can be found at variable scope.
– aynber
Nov 21 '18 at 15:28
1
$myroNEVER changes it's value.
– u_mulder
Nov 21 '18 at 15:30
1
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
1
$myronever changes causing infinity loop,$balanceis not defined anywhere,$mysqliis not defined in function's scope. So many errors.
– u_mulder
Nov 21 '18 at 15:38
|
show 4 more comments
there is the mistake call to a member function query() on a non-object
$resut = $mysqli->query("SELECT users FROM $gid WHERE $gid.id != 1 ");
$myro = mysqli_fetch_assoc($resut);
function insertLogin($myro)
{
while ($myro == true) {
$myroq = $myro['users'];
$result = mysqli_query($mysqli, "SELECT * FROM users WHERE users.login='$myroq'");
$myros = mysqli_fetch_assoc($result);
$orgroupcountnew = $myros['orgoup'] + 1;
$gncountnew = $myros['gn'] + 1;
$rest = $mysqli->query("UPDATE users SET balance ='$balance', gn = '$gncountnew', orgroup = '$orgroupcountnew' WHERE users.login= '$myroq'");
}
}
The $ mysqli variable is declared at the very beginning of the document.
$mysqli = new mysqli ("127.0.0.1:3306", "root", "", "mybase");
$mysqli->query("SET NAMES 'utf8'");
and when calling this function, insertLogin ($ myro); shows that the error in this line
$rest = $mysqli ->query("UPDATEusersSETbalance='$balance',gn= '$gncountnew',orgroup= '$orgroupcountnew' WHEREusers.login= '$myroq'");
although a similar request is being called before, but by a slightly different method (moreover, if $ result = mysqli_query is rewritten to $ mysqli -> query, it will generate an error in this line, but if you remake $ rest = $ mysqli -> query to mysqli_query, nothing will not work at all, the page freezes on reboot and that's it.
I read what needs to be done through the global variable and so on, but it does not work because I insert global $ mysqli into the function, the page hangs again. The problem is that this is not all code and the connection cannot be closed and reopened, the rest does not work. Help and explain what needs to be done.
i tried by another way but it still doesn't work
function insertLogin ($resut) {
while (($myroq = $resut-> fetch_assoc()) != false) {
$myroq = $resut['users'];
$resut = $mysqli->query("SELECT `users` FROM `$gid` WHERE `$gid`.`id` != 1 " );
insertLogin ($resut);
and like this
function insertLogin($myro, $mysqli)
but the page is freezed again. Please help.
php mysqli
there is the mistake call to a member function query() on a non-object
$resut = $mysqli->query("SELECT users FROM $gid WHERE $gid.id != 1 ");
$myro = mysqli_fetch_assoc($resut);
function insertLogin($myro)
{
while ($myro == true) {
$myroq = $myro['users'];
$result = mysqli_query($mysqli, "SELECT * FROM users WHERE users.login='$myroq'");
$myros = mysqli_fetch_assoc($result);
$orgroupcountnew = $myros['orgoup'] + 1;
$gncountnew = $myros['gn'] + 1;
$rest = $mysqli->query("UPDATE users SET balance ='$balance', gn = '$gncountnew', orgroup = '$orgroupcountnew' WHERE users.login= '$myroq'");
}
}
The $ mysqli variable is declared at the very beginning of the document.
$mysqli = new mysqli ("127.0.0.1:3306", "root", "", "mybase");
$mysqli->query("SET NAMES 'utf8'");
and when calling this function, insertLogin ($ myro); shows that the error in this line
$rest = $mysqli ->query("UPDATEusersSETbalance='$balance',gn= '$gncountnew',orgroup= '$orgroupcountnew' WHEREusers.login= '$myroq'");
although a similar request is being called before, but by a slightly different method (moreover, if $ result = mysqli_query is rewritten to $ mysqli -> query, it will generate an error in this line, but if you remake $ rest = $ mysqli -> query to mysqli_query, nothing will not work at all, the page freezes on reboot and that's it.
I read what needs to be done through the global variable and so on, but it does not work because I insert global $ mysqli into the function, the page hangs again. The problem is that this is not all code and the connection cannot be closed and reopened, the rest does not work. Help and explain what needs to be done.
i tried by another way but it still doesn't work
function insertLogin ($resut) {
while (($myroq = $resut-> fetch_assoc()) != false) {
$myroq = $resut['users'];
$resut = $mysqli->query("SELECT `users` FROM `$gid` WHERE `$gid`.`id` != 1 " );
insertLogin ($resut);
and like this
function insertLogin($myro, $mysqli)
but the page is freezed again. Please help.
php mysqli
php mysqli
asked Nov 21 '18 at 15:23
Андрей Юрин
11
11
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
1
Also,$mysqlidoes not exist within thefunction insertLoginscope. More information on variable scopes can be found at variable scope.
– aynber
Nov 21 '18 at 15:28
1
$myroNEVER changes it's value.
– u_mulder
Nov 21 '18 at 15:30
1
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
1
$myronever changes causing infinity loop,$balanceis not defined anywhere,$mysqliis not defined in function's scope. So many errors.
– u_mulder
Nov 21 '18 at 15:38
|
show 4 more comments
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
1
Also,$mysqlidoes not exist within thefunction insertLoginscope. More information on variable scopes can be found at variable scope.
– aynber
Nov 21 '18 at 15:28
1
$myroNEVER changes it's value.
– u_mulder
Nov 21 '18 at 15:30
1
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
1
$myronever changes causing infinity loop,$balanceis not defined anywhere,$mysqliis not defined in function's scope. So many errors.
– u_mulder
Nov 21 '18 at 15:38
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
1
1
Also,
$mysqli does not exist within the function insertLogin scope. More information on variable scopes can be found at variable scope.– aynber
Nov 21 '18 at 15:28
Also,
$mysqli does not exist within the function insertLogin scope. More information on variable scopes can be found at variable scope.– aynber
Nov 21 '18 at 15:28
1
1
$myro NEVER changes it's value.– u_mulder
Nov 21 '18 at 15:30
$myro NEVER changes it's value.– u_mulder
Nov 21 '18 at 15:30
1
1
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
1
1
$myro never changes causing infinity loop, $balance is not defined anywhere, $mysqli is not defined in function's scope. So many errors.– u_mulder
Nov 21 '18 at 15:38
$myro never changes causing infinity loop, $balance is not defined anywhere, $mysqli is not defined in function's scope. So many errors.– u_mulder
Nov 21 '18 at 15:38
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415261%2fmistake-call-to-a-member-function-query-on-a-non-object%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53415261%2fmistake-call-to-a-member-function-query-on-a-non-object%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Remove the port from your connection string. 3306 is default and does not need to be specified, and if added, would be another argument. Check for mysqli errors after you try to connect for more information.
– aynber
Nov 21 '18 at 15:27
1
Also,
$mysqlidoes not exist within thefunction insertLoginscope. More information on variable scopes can be found at variable scope.– aynber
Nov 21 '18 at 15:28
1
$myroNEVER changes it's value.– u_mulder
Nov 21 '18 at 15:30
1
Use procedural approach or object oriented, don't mix (preferably OO). You should parameterize the queries. You also should be able to do this with less queries. Mysql can do math.
– user3783243
Nov 21 '18 at 15:32
1
$myronever changes causing infinity loop,$balanceis not defined anywhere,$mysqliis not defined in function's scope. So many errors.– u_mulder
Nov 21 '18 at 15:38