0

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>";
}

?>
2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by qwertpink
0

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

0

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

0

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

Edited by pritaeas: n/a

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.