php – Laravel 8: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

I want to apply OneToMany Relationship between users and roles table and I have already some data in these two tables.

So in order to make this relationship, I made this Migration for adding role_id to users table:

public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            $table->unsignedBigInteger('role_id')->nullable()->unsigned();
            $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
        });
    }

But when I want to run this Migration, I get this error:

SQLSTATE(42S21): Column already exists: 1060 Duplicate column name
‘role_id’ (SQL: alter table users add role_id bigint unsigned
null)

So what is going wrong here ? How can I fix this issue ?

Here is also the Migration of roles table:

public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug');
            $table->timestamps();
        });
    }

magento2 – QLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

I am trying to upload product price with just two column “sku” and “price”.

when i am checking data , its successful but when i am trying to import i am getting this following issue

SQLSTATE(23000): Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`zest`.`catalog_category_product`, CONSTRAINT 
`CAT_CTGR_PRD_CTGR_ID_SEQUENCE_CAT_CTGR_SEQUENCE_VAL` FOREIGN KEY (`category_id`) REFERENCES `sequence_catalog_category` (`sequence_value`) ON DEL), query was: INSERT INTO `catalog_category_product`
(`product_id`,`category_id`,`position`) VALUES (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?) 
ON DUPLICATE KEY UPDATE `product_id` = VALUES(`product_id`), 
`category_id` = VALUES(`category_id`)

Please help me to fix this. Thanks in advance.

mysql – restriction recommendation and error 1452

Basically, I cannot have an order for a customer in the following script that is not in the customer table. How can I declare this in the "create table" scripts?

I also get an error 1452 for the last insert (the sixth) with the following insert script. Is there any way to correct this? I'm not sure I understand why it can't be updated …

Any help would be greatly appreciated and apologize for the probably fairly simple question!

Sincerely yours,
Shan

Enter the image description here

Enter the image description here

mysql – Error inserting values ​​into a table (error code: 1452)

I have created the following tables:

CREATE TABLE usuario(
    nroCuenta CHAR(12),
    nombreUsuario VARCHAR(45) NOT NULL,
    direccion VARCHAR(45),
    nroMovil VARCHAR(15),
    paisUsuario VARCHAR(45) NOT NULL,
    PRIMARY KEY(nroCuenta)
);

CREATE TABLE descarga(
    cuentaUsuario CHAR(12),
    codigoApp VARCHAR(45),
    fechaDescarga DATE NOT NULL,
    puntuacion TINYINT(1),
    comentario VARCHAR(255),
    PRIMARY KEY(cuentaUsuario, codigoApp),
    FOREIGN KEY(cuentaUsuario) REFERENCES usuario(nroCuenta) ON DELETE CASCADE,
    FOREIGN KEY(codigoApp) REFERENCES aplicacion(codigo) ON DELETE CASCADE,
    CHECK (puntuacion >= 0 AND puntuacion <= 5)
);

I'm trying to add values ​​to the download table:

INSERT INTO descarga VALUES ('UR-9CLSBAMWA', '5CCH5FGFZP', '2019-12-01', 4, 'S/C');

But it seems to me:

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`tiendaaplicaciones`.`descarga`, CONSTRAINT `descarga_ibfk_1` FOREIGN KEY (`cuentaUsuario`) REFERENCES `usuario` (`nroCuenta`) ON DELETE CASCADE)

Can anyone see a mistake in the definition of the foreign key?

: i 6p

BlackHatKings: Proxies and VPN area
Posted by: Jamesreimb
Post Time: June 24, 2019 at 05:02.

php – ERROR 1452 Can not add or update a child line: A foreign key constraint will fail

I'm new to this programming, but I'm very interested in the topic and started learning some things on websites. Little by little I got a website, but I was stuck in a problem I have and that is I am trying to enter comments into my database, but I have not

I get my code for this error


and in my repository I have the function

public static function insert_comment ($ connection, $ comment) {
$ comment_inserted = false;

if (isset ($ connection)) {
tries {
$ sql = "INSERT INTO comments (author_id, entry_id, title, text, date) VALUES (: author_id,: input_id,: title,: text, NOW ())";

$ statement = $ connection -> prepare ($ sql);

$ statement -> bindParam (& # 39 ;: author_id & # 39 ;, $ comment -> get_author_id (), PDO :: PARAM_STR);
$ statement -> bindParam (& # 39 ;: input_id & # 39 ;, $ comment -> get_input_id (), PDO :: PARAM_STR);
$ statement -> bindParam (& # 39 ;: title & # 39 ;, $ comment -> get_title (), PDO :: PARAM_STR);
$ statement -> bindParam (& # 39 ;: text & # 39 ;, $ comment -> get_text (), PDO :: PARAM_STR);

$ comment_inserted = $ statement -> execute ();
} catch (PDOException $ ex) {
& # 39; ERROR & # 39; print $ ex-> getMessage ();
}
}

return $ comment_inserted;
}

I would be very happy to help you

: 2019 ie

: 2019 ie[IMG]https: //i106.fastpic****big/2019/0611/63/d4a8f7df565fa0de31e0b4ad1e3ee063.jpg[/IMG] : : : Online Instagram3 19, 11: 496 :. 5 ,? .9: 17 18 2019. 133 ,. : 6 2019. 39. 00P0KE 2019 HD. , , 4. 02:38: (2019) 3 2019. 39 (Case 39, 2009) 2012 … 2009 2006 ,, -, ::, :: (2D, 16+) ,: 2 11 2019; 3 12 2019; 4, -,:. , , App Store Google Play. , , , 9.8. April 2019 – 3 min. (2019) – 3. 2:53. (2019, 72-2019) :::: X-Men: Dark Phoenix .: +0. -1. Sitro47 :. : smile13: ,, 33 33 (7). Instagram telegram:.:, HD 720.:., .200.) ,. () 6 2019. ,, – ::. 27 You Tube-20th, 6 2019.94. , (). Comic genre Fox, -: Fox, Marvel Marvel, -: Marvel Fox ,. fantastic four wonders. 94. Facebook TwitterGoogle + ReddItWhatsAppPinterestEmail. , 20, -, – ,. ,, (),:, .darkphoenixsophieturnerdailysophieturner. 2.X-Men: Dark Phoenix :: 14 2019: ,, :: ,,,,,,,,, – ,. : (2019). . 0 0 … HD (2019). – X-Men "-:". , 49 X-Men – 3, 38 ": 2 -". 75. 578 76 … :. X-Men: Dark Phoenix, 2019 (16+). . , , , , 14:52. , 20:00. , 8: (2019). 8: (2019). TS. 0, 8 :, HD 1080, HD 720 … , 9 :. 7 :. 6 :. 5 :. 3:. 2nd, ":" – 8,1, ":" – 8,2. , "" – 35 ,,. Fox 2000: 49.:. . -: 3-14 4 :. To view this video, please enable JavaScript and consider upgrading to a web browser that supports HTML5 video, Fox Kids Jetix, Nickelodeon Cartoon Network, and Disney. "Disney Channel, Nickelodeon Cartoon Network. : 6 2019: – ":" ,. , 0: 0002: 03.. :. , 0. 0 ,,,,. , , : -. : ,, :: 2019: 2019: 2019 :: 2019 :: 2019 ::::: hd: http: //thecorner.ning.com/profiles/b…na19v3de3noatb.

Davidbendy
Reviewed by Davidbendy on
,
: 2019 ie
: 2019 iehttps: //i106.fastpic ***** big / 2019/0611/63 / d4a8f7df565fa0de31e0b4ad1e3ee063.jpg ::: Online Instagram3 19, 11: 496 :. 5 ,? .9: 17 18 2019. 133 ,. : 6 2019. 39. 00P0KE 2019 HD. , , 4. 02:38: (2019) 3 2019. 39 (Case 39, 2009) 2012 … 2009 2006 ,, -, ::, :: (2D, 16+) ,: 2 11 2019; 3 12 2019; 4, -,:. , , App Store Google Play. , , From 9.8., 2019 – 3
Rating: 5

,

I xj

BlackHatKings: Proxies and VPN area
Posted by: Quintondum
Post Time: June 3, 2019 at 16:57.

magento 1.9 – PDOException: SQLSTATE[23000]: Violation of constraint: 1452 Can not add or update a child line

After creating a shopping cart rule for grouped products, I got them

catalog_product_attribute indexer

must be re-indexed.
When I tried reindexing from the console, I got:

Unknown error in product attribute process:
PDOException: SQLSTATE[23000]No information for the content. This can cause a crash that could violate the constraint: 1452 A constraint violation can not be raised: 1452 Can not modify or update a child row: A foreign key constraint fails ("wallshoplive") C) in / home / wpaper / public_html / lib / Zend / Db / statement / Pdo.php: 228
Stack trace:
# 0 /home/wpaper/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement-> Run (Array)
# 1 /home/wpaper/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo -> _ execute (Array)
# 2 /home/wpaper/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql -> _ Run (Array)
# 3 /home/wpaper/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement-> Run (Array)
# 4 /home/wpaper/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract-> query (& # 39; INSERT INTO ca ... & # 39 ;, Array)
# 5 /home/wpaper/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract-> Query (& # 39; INSERT INTO Ca ... & # 39 ;, Array)
# 6 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(179): Varien_Db_Adapter_Pdo_Mysql-> query (& # 39; INSERT INTO `ca ... & # 39; )
# 7 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Helper/Mysql4.php(49): Mage_Index_Model_Resource_Abstract-> insertFromSelect (object (Varien_Db_Select) & # 39 ;, & # 39; catalog_product # wrong)
# 8 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(153): Mage_Index_Model_Resource_Helper_Mysql4-> insert (Object (Mana_Filters_Resource_Indexer_Source), Object (Varien_Db_Select),, catalog_product ... & # 39 ;, array, false)
# 9 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(113): Mage_Index_Model_Resource_Abstract-> insertFromTable (& # 39; catalog_product ... & # 39 ;, & # 39; catalog_product ... & # 39 ;, false)
# 10 /home/wpaper/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Abstract.php (54): Mage_Index_Model_Resource_Abstract-> syncData ()
# 11 /home/wpaper/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav.php(185): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract-> reindexAll ()
# 12 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Eav-> reindexAll ()
# 13 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract-> reindexAll ()
# 14 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process-> reindexAll ()
# 15 /home/wpaper/public_html/shell/indexer.php(168): Mage_Index_Model_Process-> reindexEverything ()
# 16 /home/wpaper/public_html/shell/indexer.php(216): Mage_Shell_Compiler-> run ()
# 17 {main}

Next Zend_Db_Statement_Exception: SQLSTATE[23000]No information for the content. This can cause a crash that could violate the constraint: 1452 A constraint violation can not be raised: 1452 Can not modify or update a child row: A foreign key constraint fails ("wallshoplive") C) Query was: INSERT INTO_Catalog_product_index_eav` (`entity_id`,` attribut_id`, `store_id`,` value & # 39;). SELECT & # 39; catalog_product_index_eav_idx`.`entity_id`, `catalog_product_index_eav_idx`.`attribute_id`,` catalog_id & # 39; store_id`, `catalog_product_index_eav_idx`.`value` FROM` catalog_product_index_eav_idx` ON DUPLICATE KEY UPDATE` entity_id` = VALUES (`entity_id`),` attribute_id` = VALUES (`attribut_id`),` store_id`), `value` = VALUES (`value`) in /home/wpaper/public_html/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
# 0 /home/wpaper/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo -> _ execute (Array)
# 1 /home/wpaper/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql -> _ Run (Array)
# 2 /home/wpaper/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement-> Run (Array)
# 3 /home/wpaper/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract-> query (& # 39; INSERT INTO ca ... & # 39 ;, Array)
# 4 /home/wpaper/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract-> Query (& # 39; INSERT INTO Ca ... & # 39 ;, Array)
# 5 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(179): Varien_Db_Adapter_Pdo_Mysql-> query (& # 39; INSERT INTO `ca ... & # 39; )
# 6 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Helper/Mysql4.php(49): Mage_Index_Model_Resource_Abstract-> insertFromSelect (object (Varien_Db_Select) & # 39 ;, & # 39; catalog_product # wrong)
# 7 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(153): Mage_Index_Model_Resource_Helper_Mysql4-> insert (Object (Mana_Filters_Resource_Indexer_Source), Object (Varien_Db_Select),, catalog_product ... & # 39 ;, array, false)
# 8 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Resource/Abstract.php(113): Mage_Index_Model_Resource_Abstract-> insertFromTable (& # 39; catalog_product ... & # 39 ;, & # 39; catalog_product ... & # 39 ;, false)
# 9 /home/wpaper/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav/Abstract.php (54): Mage_Index_Model_Resource_Abstract-> syncData ()
# 10 /home/wpaper/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Indexer/Eav.php(185): Mage_Catalog_Model_Resource_Product_Indexer_Eav_Abstract-> reindexAll ()
# 11 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Product_Indexer_Eav-> reindexAll ()
# 12 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract-> reindexAll ()
# 13 /home/wpaper/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process-> reindexAll ()
# 14 /home/wpaper/public_html/shell/indexer.php(168): Mage_Index_Model_Process-> reindexEverything ()
# 15 /home/wpaper/public_html/shell/indexer.php(216): Mage_Shell_Compiler-> run ()
# 16 {main}

I am using Magento 1.9.3.8

All other indexers work. Site works too.

Could anyone help me, please?

mysql workbench – When I try to insert a line, I get the error code: 1452

CREATE TABLE IF NOT EXISTS game_review,Remarks (
comment_id INT NOT NULL AUTO_INCREMENT,
iduser INT NOT NULL,
Release Date DATETIME NOT NULL,
Remarks LONGTEXT NOT NULL,
Idgame INT NOT NULL,
PRIMARY KEY (comment_id)
UNIQUE INDEX comments_id_UNIQUE (comment_id)
INDEX comment_user_id_idx (iduser)
INDEX comment_game_id_idx (Idgame)
FORCE comment_user_id
UNKNOWN KEY (iduser)
REFERENCES game_review,user (user identification)
ON DELETE CASCADE
ON UPDATE NO ACTION,
FORCE comment_game_id
UNKNOWN KEY (Idgame)
REFERENCES game_review,games (game_id)
ON DELETE NO ACTION
UPDATE NO ACTION)
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS game_review,user (
user identification INT NOT NULL AUTO_INCREMENT,
Email-address VARCHAR (45) NOT NULL,
password VARCHAR (6) NOT NULL,
username VARCHAR (20) NOT NULL,
PRIMARY KEY (user identification)
UNIQUE INDEX user_id_UNIQUE (user identification))
ENGINE = InnoDB;

This is the action: INSERT INTO game_review.comments (iduser, datePosted, comments, idgame) VALUES (1, NOW (), "dsds", 1)

This is the answer: Error code: 1452. A child line can not be added or updated: A foreign key constraint fails (game_review,RemarksCONSTRAINT comment_game_id UNKNOWN KEY (Idgame) REFERENCES games (game_id) ON DELETE CASCADE UPDATE CASCADE)