i have json data that i send with postman it looks like this:
` "username": "myUser",
"permissions": {
"editProfile": false,
"deleteProfile": false,
}
`
i try to update this post data in my MySql database:
`
$data = json_decode(file_get_contents("php://input"));
$username = trim($data->username);
$query = "UPDATE users SET permissions=? WHERE username=?";
$stmt = $conn->prepare($query);
$stmt->bindParam($data->permissions, $username);
$stmt->execute();`
but i only get an error message back, does anyone know what i am doing wrong here?
<br /> <b>Fatal error</b>: Uncaught TypeError: PDOStatement: :bindParam(): Argument #1 ($param) must be of type string|int, stdClass given in C:\xampp\htdocs\SocialManager\Backend\updatePermissions.php: 42 Stack trace: #0 C:\xampp\htdocs\SocialManager\Backend\updatePermissions.php(42): PDOStatement->bindParam(Object(stdClass), 'userdname') #1 {main } thrown in <b>C:\xampp\htdocs\SocialManager\Backend\updatePermissions.php</b> on line <b>42</b><br />
Related
I am learning php. I am getting this error
Fatal error: Uncaught Error: Call to undefined method mysqli::execute() in C:\xampp\htdocs\search\index.php:58 Stack trace: #0 {main} thrown in C:\xampp\htdocs\search\index.php on line 58
Here the line 58 is
<?php
include'config.php';
$stmt=$conn->prepare("SELECT * FROM info");
$conn->execute(); // This line
$result=$stmt->get_result();
?>
I am trying to create a simple live search.
Call the method execute() on $stmt object instead.
include 'config.php';
$stmt = $conn->prepare("SELECT * FROM info");
$stmt->execute(); // you are executing connection here
$result = $stmt->get_result();
I am getting an error code and I really can't tell what the problem is here:
public static function createRecord($mysql, $id, $username) {
$login = new login;
$delete_from_sessions = $mysql->prepare("DELETE FROM com_sessions WHERE uid = ?");
if(!$delete_from_sessions) {
printf("Some error occured: %s\n", $mysql->error);
} else {
$delete_from_sessions->bind_param('s', $id);
$delete_from_sessions->execute();
}
// CALL FUNCTIONS IN CLASS login
$token = $login->createString(64);
$serial = $login->createString(64);
$login->createCookie($id, $username, $token, $serial);
$login->createSession($id, $username, $token, $serial);
$create_session = $mysql->prepare("INSERT INTO com_sessions (uid,token,serial,timestamp) VALUES (?,?,?,?)");
$create_session->bind_param('ssss', $id, $token, $serial, $posted_on);
$create_session->execute();
}
So what basically is happening here is, that whenever a user fills out the login-form at index.php and their userdata is correct, the function createRecord gets called and the variables from the index's inputs are passed as arguments $id for the user's id (gotten through a query within the login-script) and $username obvously as the user's name. The query is giving me the error:
Some error occured: Commands out of sync; you can't run this command now
Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:\xampp\htdocs\session\new.session.php:101 Stack trace: #0 C:\xampp\htdocs\index.php(28): login::createRecord(Object(mysqli), 11, 'Kevin') #1 {main} thrown in C:\xampp\htdocs\session\new.session.php on line 101
I've tried to take out the query and just let the functions below fire off and those ironically worked, so the variables are passed over correctly. The table name and the database connection are both correct, I've checked that multiple times. Also I've tried to free the results of my connection through $mysql->free();.
I have been working at a code that used to work. However, suddenly, this message pops up.
Fatal error: Uncaught exception 'Exception' with message 'Email is incorrect!' in C:\xampp\htdocs\Prototype\classes\User.php:23
Stack trace: #0 C:\xampp\htdocs\Prototype\index.php(14): User->setEmail(true) #1 {main} thrown in C:\xampp\htdocs\Prototype\classes\User.php on line 23
But I just don't understand what this means. I tried using try and catch, but it keeps popping up.
This is the code where the error occurs
public function setEmail($p_email)
{
if (empty($p_email)) {
throw new Exception('Email kan niet leeg zijn!');
}
$this->email = $p_email;
if (!filter_var($p_email, FILTER_VALIDATE_EMAIL)) {
throw new Exception('Email is incorrect!'); //here is the error (line 23)
}
}
this is the code where it is summoned
$user = new User();
$user->setEmail($_SESSION['login']); //line 14
$currentUser = $user->getProfile();
$userEmail = $user->getEmail();
$userName = $user->getUserName();
$userID = $currentUser['userID'];
Your error is that you are passing a boolean instead of a valid string email...
Stack trace: #0 C:\xampp\htdocs\Prototype\index.php(14): User->setEmail(true) #1 {main} thrown in C:\xampp\htdocs\Prototype\classes\User.php on line 23
So, this line is incorrect:
$user->setEmail($_SESSION['login']); //line 14
I am trying to implement the whatsAPI but I always get this error
"There was a problem trying to request the code".
Here is the full error that is showing in my console:
####start of error notice#####
[12-Mar-2013 22:44:59] PHP Notice: Undefined property: stdClass::$reason in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php on line 1268
[12-Mar-2013 22:44:59] PHP Fatal error: Uncaught exception 'Exception' with message 'There was a problem trying to request the code.' in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php:1269
Stack trace:
#0 /Applications/MAMP/htdocs/whatsapp/test/test.php(36): WhatsProt->checkCredentials()
#1 {main}
thrown in /Applications/MAMP/htdocs/whatsapp/test/whatsprot.class.php on line 1269
####end of error notice#####
these are my credentials for initializing the class
$userPhone = '8801770648732';
$userIdentity = '352264050503669';
$userName = 'shishir';
$destinationPhone = '8801713206053';
$debug = TRUE;
$whatsapp = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
and for the requesting a requestCode
$service_type = "sms";
$country_code = "BD";
$language_code = "en";
$request_code = $whatsapp->requestCode($service_type, $country_code, $language_code);
Every time it stuck at the $whatsapp->requestCode with that error. I'm not sure what i am doing wrong . Can anyone help me on this?
It's look like you don't have curl extension.
This Exception is thrown by checkCredentials method.
Check if your phpinfo shows curl.
$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?