I'm trying to add new user with a school name, schoolID and regionID into users and schools tables all at one go (PHP).
The user is created in users, new school in schools, and both get regionIDs, but my code isn't posting the new schoolID to the new user's row (col stays blank). The problem seems to be down to choking on variables ($newschool and $newuser). If I hard code the values into the UPDATE statement, it writes them fine.
Anyone spot any glaring syntax issues?
:-Y
Code:
if ( $user['grpID'] == 8 ) {
$schname = $user['schname'];
$schreg = $user['regID'];
$stH = stPrep("INSERT INTO schools (name, region, status) VALUES (?,?,?)");
$result = stExec($stH,array($schname,$schreg,0));
$stH = stPrep("SELECT last_insert_rowid()");
$row = $stH->fetch(PDO::FETCH_NUM);
$stH = null;
$newschool = $row[0];
$newuser = $user['id'];
$stH = stPrep("UPDATE users SET schoolID = ? WHERE ID = ?");
$result = stExec($stH,array($newschool,$newuser));
}
EDITED: 3 Sep 2014 20:47 by DSMITHHFX