hi all,

when my codes ran at localhost, it doesnt have any error, however when it runs in a server it gives
'Column 'member_id' cannot be null'

//retrieve form data
$start_date=$_POST['start_date'];
$end_date=$_POST['end_date'];
$project_name=$_POST['project_name'];
$project_description=$_POST['project_description'];



// open connection
$link = mysqli_connect($host, $user, $pass, $db);



$query = "INSERT INTO project(project_name,start_date,end_date,project_description,project_status)VALUES('$project_name','$start_date','$end_date','$project_description','available')";


$result = mysqli_query($link, $query) or die(mysqli_error($link));


foreach ($_POST['trainers'] as $trainer) {

$query2 = "INSERT INTO trainer_schedule(project_id,member_id,trainer_reply,date)VALUES((SELECT project_id FROM project WHERE project_name='$project_name'),(SELECT member_id FROM member WHERE email='$trainer'),'Pending',NOW())";
$result2 = mysqli_query($link, $query2) or die(mysqli_error($link));
}



mysqli_close($link);

if ($result && $result2) {
    $message = "<font size='3'>Project posted<font size='3' color='green'> Successfully</font></font><br />";
} else {
    $message = "Project post <font size='3' color='red'>failed</font><br />";
    $message .= "<a href='create_project.php'>try again</a>";
}

?>

Recommended Answers

All 5 Replies

That means your server database is different. Most likely you have data in your `member` table locally, but not on the server.

hmm, but i export the data from local and import to the server :(

Your sub-query will return null, when the trainer e-mail cannot be found. That's not allowed apparently.

O! okok, so i need another way to do it. Alright, i 'll try thank you.

Thank you again , i removed that subqeuery, and uses another way (: Thanks so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.