I ran into the same problem. The new node WAS storing in my database, but NOT updating the node name or node text. I ran Firebug.php and saw that the newly created node id (mysqli_insert_id) was not being passed to rename_node.
I solved it using session variables - setting a variable to indicate the rename function was accessed from create_node and also setting a 'last_id' session variable.
'CRN' is just a variable specific to my database and app, you can ignore it.
So, using the response.php example provided, I modified it as follows:
case 'create_node':
FB::info($_GET, "New Node attributes ");
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? (int)$_GET['id'] : 0;
$nodeText = isset($_GET['text']) && $_GET['text'] !== '' ? $_GET['text'] : '';
$CRN=$_SESSION['CRN'];
$sql ="INSERT INTO CourseLookup (name, text, parent_id, CRN) VALUES('$nodeText','$nodeText','$node','$CRN')";
FB::info($sql, "new node query ");
mysqli_query($conn, $sql);
$last_id = mysqli_insert_id($conn);
$_SESSION['create']=true;//passed to rename_node so it knows to use the $last_id for the node
$_SESSION['lastid']=$last_id;//used as the node in rename_node
$result = array('id' => $last_id);
print_r($result);die;
break;
case 'rename_node':
if($_SESSION['create']){//if a new node was just created
$node=$_SESSION['lastid'];//use the last insert id
}
else{
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? (int)$_GET['id'] : 0;//otherwise use the last menu item clicked
}
FB::info($_SESSION['create'],"create status");//debugging
FB::info($_SESSION['lastid'],"last id");//debuggig
//print_R($_GET);
$nodeText = isset($_GET['text']) && $_GET['text'] !== '' ? $_GET['text'] : '';
FB::info($nodeText, "node name ");
$sql ="UPDATE CourseLookup SET name='$nodeText', text='$nodeText' WHERE id=$node";
FB::info($sql, "rename node query ");
mysqli_query($conn, $sql);
$_SESSION['create']=false;
break;