Send submissions to a PHP script running on version 7.3.6 to store data in MySql

  • Profile Image
    skenney
    Asked on July 22, 2020 at 01:09 AM

    Hi, This is exactly what I've been looking for .... my problem is that I am not a programmer, just a novice with a little project that I import 25 entries quarterly in my database. It sure would be much better to have it update with each submission rather imported all at once... And apparently since I have PHP version: 7.3.6 , some of the code must be updated, especially related to mysql to mysqli , and some others... Has this already been done somewhere ? If not I haven't been able to find it ... or could someone do it for me. Thanks in Advance, Steve

    https://i.imgur.com/skXK78f.jpg



    This is a re-post of a comment on How to send Submissions to Your MySQL Database Using PHP

  • Profile Image
    ashwin_d
    Answered on July 22, 2020 at 05:19 AM

    Unfortunately we do not have any updated PHP code. Please note that the code you see in our guide is a sample code and it should work in PHP 7.3.6 as the sample code is only to read the POST data and save it to MySQL database. 

    I do not have knowledge to mysqli but you should be able to figure out the insert and update query format. You may like to take a look at the following guide which should help you: https://phppot.com/php/mysql-vs-mysqli-in-php/ 

    Hope this helps.

    Do get back to us if you have any questions. 

  • Profile Image
    skenney
    Answered on July 22, 2020 at 05:40 AM

    Thanks, I think I scraped my way through the syntax issues ... but now I'm getting this message

    'Cannot add or update a child row: a foreign key constraint fails (`ualamsec_MRL`.`user_picks`, CONSTRAINT `user_picks_ibfk_2` FOREIGN KEY (`teamName`) REFERENCES `user_teams` (`teamName`) ON DELETE CASCADE ON UPDATE CASCADE)'

    So now I have another challenge ahead of me.

  • Profile Image
    Jed_C
    Answered on July 22, 2020 at 07:57 AM

    We can help you with form issues, but debugging with database error, you may try online and see if you are able to get help from stackoverflow.

    Try this link https://stackoverflow.com/questions/5005388/cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails.

  • Profile Image
    skenney
    Answered on July 22, 2020 at 08:48 AM

    Thanks ! Actually I had already been to the page, and found the solution I want to use. Just remember, this is just a project for me, and it's only for fun and I'm not trying to be a programmer... actually I'm retired, and just killing some time !  So in order to just get it to work, I have chosen this method from the link...

    --------------------------------

    A simple hack can be to disable foreign key checks before performing any operation on the table. Simply query

    SET FOREIGN_KEY_CHECKS=0

    This will disable foreign key matching against any other tables. After you are done with the table enable it again


    SET FOREIGN_KEY_CHECKS=1
    --------------------------

    The only thing is, I don't know where I need to put these 

    Thanks, Steve




  • Profile Image
    ashwin_d
    Answered on July 22, 2020 at 10:11 AM

    This you need to set in your database. You can access your database using the UI. For example if you are using MySQL DB, you can access it using phpmyadmin or any other compatible DB client like mysql workbench.

  • Profile Image
    Patrick_R
    Answered on July 22, 2020 at 02:09 PM

    Hello Steve! These MySql configs usually go into the my.cnf file bu those would apply to all MySql operations.

    You can also set these temporarily by running these commands as a MySql query. Please have a look at the following page: https://stackoverflow.com/questions/4268801/ignore-mysql-foreign-key-constraints-in-php

    Following is the answer that I am referring to:

    1595441360chrome-capture (52).jpg

    I hope this information helps. if you have any further queries, feel free to write back to us.

    Thank you!