1

i've problem while i make an insert function using php. i dont know how to give a validation while inserting data to database. my insert function using of the other data table from the database (copying data from other table to another).

somebody know how to give a validation with that data. not from a textbox value or input value from the form. but validation from the data in the database. please help me out my trouble. im very appreciated when you give me an example.

this is my code for insert data (copying data from the other table to another).

<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "silo");


// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}


// Attempt insert query execution
$sql="Insert into termocouple 
        Select * from temp1";
if(mysqli_query($link, $sql)){
    echo "Records inserted successfully.";
} else{
    echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// Close connection
mysqli_close($link);
?>
Jack Henaldy
  • 69
  • 1
  • 10
  • "validate data from database" you copying from one table to other table then why you need this.... – Naincy Feb 25 '17 at 06:14
  • what kind of validation you are trying to ! do you want to match condition to retrive data from that table ? – M. Alim Feb 25 '17 at 06:16
  • check this question for your help to write subquery http://stackoverflow.com/questions/9692319/how-can-i-insert-values-into-a-table-using-a-subquery-with-more-than-one-result – M. Alim Feb 25 '17 at 06:24
  • i want to check while the table termocouple not contain the same data from data in temp1 – Jack Henaldy Feb 25 '17 at 06:31
  • or just checking the table temp1 has value of data and then insert. but when doesnt have value then failed to inser – Jack Henaldy Feb 25 '17 at 06:39

0 Answers0