Error message copying data from one database to another on the same server

I have wrote a script to copy client data over from our old system to the new system and it’s giving me the above error message.

I know the script is not very secure but it’s located on the internal network and is not open to the internet via firewall rules. I am monitoring use of the script very closely (When I get it working lol)

Full error message

Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘from cic_remus.contacts where (id=’127′)’ at line 1 in sender.php:16 Stack trace: #0 sender.php(16): mysqli_query() #1 {main} thrown in sender.php on line 16

I have gone through the code and everything appears to be correct and can’t seem to see what the problem is.

Both tables are the same and using the same version of PHP 8.2 and are located on the same server.

I know that I can just export and import but we are manually reviewing what information goes over and this is the easiest way for us to do it.

Code;

<?php

$databaseHost = 'localhost'; 
$databaseName = ''; 
$databaseUsername = ''; 
$databasePassword = '';

$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName); 
 
$id = $_GET['id'];



$sql="select from cic_remus.contacts where (id='$id');"; 

      $res=mysqli_query($mysqli,$sql);

      if (mysqli_num_rows($res) > 0) {
        // output data of each row
        $row = mysqli_fetch_assoc($res);
        if($id==$row['id'])
        {
echo "Already copied"; 
                
        }

       } else{

 
   
$query=mysqli_query($mysqli,"INSERT INTO cic_kenobi.contacts (status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext)

SELECT status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext

FROM cic_remus.contacts WHERE id =$id");

echo "Successfully copied"; 


       }
       
?>