Making a delete DAO -> Uncaught exception 'PDOException' - sql

I'm trying to make a dao which can delete a specific item once you click on the X
How did I try this? I'll begin with showing you the DAO:
public function delete($iddelete){
$sql = "DELETE FROM `wanthave`.`wanthave_items` WHERE `wanthave_items`.`id` = `iddelete` = :iddelete LIMIT 1";
$stmt = $this->pdo->prepare($sql);
$stmt->bindValue(':iddelete', $iddelete);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}
This is how I setup my if structure in a controller:
if(isset($_GET['iddelete'])){
$this->itemDAO->delete($_GET['iddelete']);
}
Once I click on the X near the item I want to delete it goes to a page with in the end "&iddelete=(id of the item)". So actually when iddelete is set it's going to delete it.
But unfortunately I get this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'iddelete' in 'where clause'' in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php:56 Stack trace:
#0 /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php(56): PDO->prepare('DELETE FROM `wa...')
#1 /Applications/MAMP/htdocs/wanthave/controller/ItemController.php(198): ItemDAO->delete('89')
#2 [internal function]: ItemController->delete()
#3 /Applications/MAMP/htdocs/wanthave/controller/Controller.php(9): call_user_func(Array) #4 /Applications/MAMP/htdocs/wanthave/index.php(69): Controller->filter()
#5 {main} thrown in /Applications/MAMP/htdocs/wanthave/dao/ItemDAO.php on line 56
Line 56 = $stmt = $this->pdo->prepare($sql);
Any help?

public function delete($id){
$stmt = $this->pdo->prepare("DELETE FROM wanthave_items WHERE id = ?");
return $stmt->execute([$id]);
}

Related

How to make if else checkbox enabled/disabled in sql query and asp.net?

I want to make my checkbox is enabled and disable when user login from my data
My syntaks in asp.net:
if (Session["Berhasil"] != null)
{
Label1.Visible = true;
Label1.Text = "Berhasil..";
if(Label1 = "select * from cs100020 where countno=2 and status=3");
{
cbxinven.Enabled=true
cbxfinadmin.Enabled=true
cbxkaskecil.Enabled=true
cbxemail.Enabled=false
cbxsap.Enabled=false
cbxpc.Enabled=false
cbxuserad.Enabled=false
}
else (Label1="select * from cs100020 where countno=3 and status=3);
{
cbxinven.Enabled=false
cbxfinadmin.Enabled=false
cbxkaskecil.Enabled=false
cbxemail.Enabled=true
cbxsap.Enabled=true
cbxpc.Enabled=true
cbxuserad.Enabled=true
}
}
and i got error :
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1010: Newline in constant
Source Error:
Line 137: cbxuserad.Enabled=false
Line 138: }
Line 139: else (Label1="select * from cs100020 where countno=3 and status=3);
Line 140: {
Line 141: cbxinven.Enabled=false
Source File: d:\Sharing\Budiman\IAPHRM BACKUP 08022019\IapHRM_180119_Backup\ViewCS.aspx.cs Line: 139
Show Detailed Compiler Output:
Show Complete Compilation Source:
The closing double quote on the SQL statement for the ELSE branch (i.e. else (Label1 = .... line) is missing.

Uncaught PodioBadRequestError: "Must specify either 'embed' or 'url'"

I need to set value for an embed field in Podio, and this is my code:
$field_id='pdf-property-information';
$options=$item->fields[$field_id]->values;
if(empty($options))
$item->fields[$field_id] = new PodioEmbedItemField($field_id);
// Create embed
$embed = PodioEmbed::create(array('url' => $pdf_property_information));
// Set using object
$item->fields[$field_id]->values = $embed;
// Set using associative array
$item->fields[$field_id]->values = array('embed_id' => $embed->embed_id);
And this is the error I get:
Fatal error: Uncaught PodioBadRequestError: "Must specify either
'embed' or 'url'" Request URL: http://api.podio.com/item/826141668
Stack Trace: #0
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/lib/Podio.php(355):
Podio::request('PUT', '/item/826141668', Array) #1
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(183):
Podio::put('/item/826141668', Array) #2
/home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(66):
PodioItem::update(826141668, Array, Array) #3
/home/apibind/public_html/sourcingplatform/trunk/add.php(403):
PodioItem->save() #4 {main} thrown in /podio-php-4.3.0/lib/Podio.php
on line 289
You have to pass the embed_id with array key "embed". Here your final line will be like,
// Set using associative array
$item->fields[$field_id]->values = array('embed' => $embed->embed_id);

Fatal error showing

Fatal error: Uncaught Error: Call to undefined function mysqli_result() in /home/prasanth/projects/ishen1/index.php:49 Stack trace: #0 {main} thrown
how to slove this
according to this answer https://stackoverflow.com/a/17707384/8284461 that function is inefficient, you can use mysqli_fetch_assoc() instead. for example:
while($row = mysqli_fetch_assoc($result)) {
$id = $row['ID'];
$name = $row['name'];
etc..
}

Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]:

<?php
include('connect.php');
$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];
// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
I get the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens' in
C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0
C:\xampp\htdocs\recordmanagement\main\reg.php(15):
PDOStatement->execute(Array) #1 {main} thrown in
C:\xampp\htdocs\recordmanagement\main\reg.php on line 15
In the code I am also unsure about the meaning of these values:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
I downloaded it from sourcecode, so it was not written by me.
There seems to be a field to much in the query. This:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
should probably be:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd)";
as there is no matching value for the :ft field.
Whether this is because your missing an item in the values or if it's not needed I can't say.

Error in Reset password joomla 3.0

I am facing a problem in joomla 3.0 when i go to reset page after verify code url is ../index.php/registration?view=reset&layout=complete.
The scenario is: fill different values in password and conform password. Then submit form, the error is:
Notice
Completing reset password failed: exception 'UnexpectedValueException' with message 'The passwords you entered do
not match. Please enter your desired password in the password field
and confirm your entry by entering it in the confirm password field.'
in
/home/fiable/public_html/projects/canvasfast/libraries/joomla/form/form.php:1872
Stack trace: #0
/home/fiable/public_html/projects/canvasfast/libraries/joomla/form/form.php(1105):
JForm->validateField(Object(SimpleXMLElement), '', 'dfdefsdfdfdfdf',
Object(JRegistry)) #1
/home/fiable/public_html/projects/canvasfast/components/com_users/models/reset.php(122):
JForm->validate(Array) #2
/home/fiable/public_html/projects/canvasfast/components/com_users/controllers/reset.php(156):
UsersModelReset->processResetComplete(Array) #3
/home/fiable/public_html/projects/canvasfast/libraries/legacy/controller/legacy.php(722): UsersControllerReset->complete() #4
/home/fiable/public_html/projects/canvasfast/components/com_users/users.php(15):
JControllerLegacy->execute('complete') #5
/home/fiable/public_html/projects/canvasfast/libraries/legacy/component/helper.php(359):
require_once('/home/fiable/pu...') #6
/home/fiable/public_html/projects/canvasfast/libraries/legacy/component/helper.php(339):
JComponentHelper::executeComponent('/home/fiable/pu...') #7
/home/fiable/public_html/projects/canvasfast/includes/application.php(205):
JComponentHelper::renderComponent('com_users') #8
/home/fiable/public_html/projects/canvasfast/index.php(52):
JSite->dispatch() #9 {main}
tested in joomla 3.0 go to the line 130 components\com_users\models\reset.php
replace bellow code:
// Check the validation results.
if ($return === false) {
// Get the validation messages from the form.
foreach ($form->getErrors() as $message) {
$this->setError($message);
}
return false;
}
to:
// Check the validation results.
if ($return === false) {
$errors = $form->getErrors();
for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
if ($errors[$i] instanceof Exception) {
$this->setError($errors[$i]->getMessage());
} else {
$this->setError($errors[$i]);
}
}
return false;
}