Jump to content
Sign in to follow this  
pascalbianca

Problems deleting rows from 2 databases

Recommended Posts

Hello everyone,

I have 2 different datatables.

If i fill in my form, data will be saved in 2 different tables both have 1 same value and that is column NC_ref.

i have on a different page a button that give you the option to delete in both tables the row that contains in column NC-ref the same name.

So i use the next code.:

  // Create connection
        $conn = mysqli_connect($servername, $username, $password, $dbname);
        // Check connection
        if (!$conn) {
            die("Connection failed: " . mysqli_connect_error());
            }
        // sql to delete a record, deze doet niets schijnbaar
        $sql = "DELETE FROM QCP_NC WHERE NC_ref=".$ref;

        if (mysqli_query($conn, $sql)) {
            echo "Record deleted successfully";
            } else {
                echo "Error deleting record: " . mysqli_error($conn);
                }

        mysqli_close($conn);

  // Create connection
        $conn1 = mysqli_connect($servername, $username, $password, $dbname);
        // Check connection
        if (!$conn1) {
            die("Connection failed: " . mysqli_connect_error());
            }

        // sql to delete a record  , deze werkt gewoon
        $sql1 = "DELETE FROM QCP_NCstart WHERE NC_ref=".$ref;

        if (mysqli_query($conn1, $sql1)) {
            echo "Record deleted successfully";
            } else {
                echo "Error deleting record: " . mysqli_error($conn1);
                }

        mysqli_close($conn1);

 

The problem is that Conn1 connection works but the Conn not , i tryed also first conn1 then conn and that gifs no difference.

Why dos'nt works conn not? can't see the difference it should in my eyes work, but it dos'nt.

 

Share this post


Link to post
Share on other sites

Little update.

If i place the delete code only in a new test.php file it works great.

So something else is i think the problem.

SOLVED😣

 

My fold.

I did a wrong action in my form.

Edited by pascalbianca

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...