Notice: Trying to get property of non-object [closed] - php

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
database.php
function insert($sql){
mysqli_query($this->objDbConn, $sql);
if(mysqli_errno($this->objDbConn)){
die("Failed Query: $sql".$this->objDBConn->error);
return false;
}else{
return true;
}
}
update.php
if(isset($_POST["submit"])){
$address= $_POST['address'];
$mail= $_POST['mail'];
$user= $_POST['user'];
$password= $_POST['password'];
$sql= "UPDATE Member(Address, Mail, UserName, Password)VALUES
('$address', '$mail', '$user', '$password')";
$objdatabase->insert($sql);
echo "Update successful";
echo "<META http-equiv='refresh' content='0;URL='>";
}
that show on the url:
Notice: Trying to get property of non-object
and
Notice: Undefined property: database::$objDBConn

There is a typo, property name is case sensitive, $this->objDBConn should be $this->objDbConn.

Related

Uncaught PDOException: SQLSTATE[HY093] [closed]

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 3 years ago.
Improve this question
I get this erro: Invalid parameter number: number of bound variables does not match number of tokens in C:\xampp\htdocs\PHP\tennis\ronde2-wijziging.php:59
// code van het knop wijzigen
if(isset($_POST['wijzig'])){
$id = $_POST['id'];
$speler1 = $_POST['speler1'];
$speler2 = $_POST['speler2'];
$uitslag1 = $_POST['uitslag1'];
$uitslag2 = $_POST['uitslag2'];
$datum = $_POST['datum'];
$veld = $_POST['veld'];
//UPDATE: gegevens in de form wijzigen.
$sql = "UPDATE ronde1 SET speler1 = :speler1, speler2 = :speler2, uitslag1 = :uitslag1,
uitslag2= :uitslag2, datum= :datum, veld= :veld WHERE id=:id";
$stmt = $pdoConnect->prepare($sql); //stuur naar mysql.
$stmt->bindParam(":id", $id );
$stmt->bindParam(":speler1", $speler1 );
$stmt->bindParam(":speler1", $speler1 );
$stmt->bindParam(":uitslag1", $uitslag1 );
$stmt->bindParam(":uitslag2", $uitslag2 );
$stmt->bindParam(":datum", $datum );
$stmt->bindParam(":veld", $veld );
$stmt->execute();
// $_SESSION['message'] = "Speler is gewijzigd";
// $_SESSION['msg_type'] = "warning";
header("location: #.php");
exit;
}
I want to update my data.strong text
My solution worked but didn't explain why it did go wrong in the first place. The user dpant explains in the comments why your code snippet was not working.
Credits go to him
dpant:
Most probably the problem with your original code was that you were binding the :speler1 parameter twice (the :speler2 parameter was never bound). This was just a typo in your code. Take a close look at it.

php code is not working,showing Fatal error: Call to undefined function mysq1i_query() [closed]

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 7 years ago.
Improve this question
php code is not working,showing
Fatal error: Call to undefined function mysq1i_query()
<?php
$dbhost='localhost';
$dbuser='root';
$dbpass='';
$conn=mysqli_connect($dbhost,$dbuser,$dbpass,"vishal");
$passkey=$_GET['passkey'];
$tblname="data";
$sql="SELECT * FROM $tblname WHERE confirmcode='$passkey'";
$result=mysq1i_query($sql);
if($result)
{
$count=mysqli_num_rows(($result));
if($count==1)
{
$rows=mysqli_fetch_array($result);
$name=$rows['name'];
$emailid=$rows['emailid'];
$password=$rows['password'];
$confirm=$rows['confirm'];
$country=$rows['country'];
$table2="data1";
$sql2="INSERT INTO $table2 (name,emailid,password,confirm,country)VALUES ('$name','$emailid','$password','$confirm','$country')"; $result1=mysqli_query($sql2);
}
else
{
echo"wrong cofirmation code";
}
if($result1)
{
echo"your account has been activated";
$sql3="DELETE FROM $tblname WHERE confirm_code='$passkey'";
$result2=mysqli_query($sql3);
}
}
?>
you have used on line no: 9
$result=mysq1i_query($sql);
instead of
$result=mysqli_query($sql);
You have an error in this line:
$result=mysq1i_query($sql);
Its l not 1 in (mysq1i)
Correct one is:
$result=mysqli_query($sql);
And when you get this error Undefined Function it means you do not define this function in your code.

Fetching a value from mysql database [closed]

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 7 years ago.
Improve this question
So I'm trying to fetch a value from a table in my database into a placeholder for an html input element. Code is as follows:
<input type="text" name="timesats" placeholder="
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
$result = mysqli_fetch_object($query);
echo($result);
?>
">
$dbc contains the values for connection.
I'm getting no errors so its really hard to debug. The value from the table is not null.
Try
<?php
include($_SERVER['DOCUMENT_ROOT'].'/paycheck/scripts/connect.php');
$user = $_SESSION['user'];
$sql = "SELECT timesats WHERE email='$user'";
$query= mysqli_query($dbc,$sql);
while ($obj = mysqli_fetch_object($query)) {
$ph = $obj->timesats;
}
?>
<input type="text" name="timesats" placeholder="<?php echo $ph; ?>"/>

Error in mysqli_num_rows [closed]

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
What's wrong with this code:
<?php
session_start();
if(!isset($_SESSION['username']) && isset($_COOKIE['username'], $_COOKIE['password']))
{
$checkQuery = "SELECT password, id FROM accounts WHERE username='".$db->real_escape_string($_COOKIE['username'])."'";
$checkResult = mysqli_query($db, $checkQuery);
$check = mysqli_fetch_array($checkResult);
if($check['password'] == $_COOKIE['password'] && mysqli_num_rows($checkQuery)>0)
{
$_SESSION['username'] = $_COOKIE['username'];
$_SESSION['userid'] = $check['id'];
}
}
?>
It shows this error:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result,
string given...
Looks like you should change
mysqli_num_rows($checkQuery)
to
mysqli_num_rows($checkResult)

Undefined variable: password [closed]

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 9 years ago.
Improve this question
Trying to signup with new username and password and get this output - "Undefined variable: password"
<?php
require_once "lib/user_class.php";
$user = User::getObject();
if (isset($_POST["reg"])) {
$login = $_POST["login"];
$login = $_POST["password"];
$reg_success = $user->regUser($login, $password);
}
?>
There's no password variable defined, that's why it says $password is undefined.
Perhaps you meant $login = $_POST["password"]; as $password = $_POST["password"];? I'm no mind-reader, but I don't think you wanted to create duplicate variables.
The variable password is not defined..
i have edited your code.
<?php
require_once "lib/user_class.php";
$user = User::getObject();
if (isset($_POST["reg"])) {
$login= $_POST["login"];
$password= $_POST["password"];
$reg_success = $user->regUser($login, $password);
}
?>

Categories