Sqlite

From: CHYRON (DSMITHHFX) 3 Sep 2014 21:44
To: ALL1 of 7
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 21:47 by DSMITHHFX
From: CHYRON (DSMITHHFX) 4 Sep 2014 16:33
To: ALL2 of 7
At last (& at least) I'm now getting a value out of a query:
 
Code: 
$stH = stPrep("SELECT * FROM schools ORDER BY ID DESC LIMIT 1");
stExec($stH,null);
$row = $stH->fetch(PDO::FETCH_NUM);
$newschool = $row[0];
echo '<pre>'; var_dump($newschool); echo '</pre>';
However var_dump returns
Code: 
string(2) "11"
-- but all I want is the last digit(s). I suppose I could clean it with a regex, but isn't there a way to just get the value of that column? WTF is "string(2)"?

Oh. It worked. [extraneous stuff is what var_dump does]
EDITED: 4 Sep 2014 16:45 by DSMITHHFX
From: 99% of gargoyles look like (MR_BASTARD) 4 Sep 2014 16:52
To: CHYRON (DSMITHHFX) 3 of 7
I'm glad we were able to help. Don't hesitate to come back if you have any further problems.
From: CHYRON (DSMITHHFX) 4 Sep 2014 17:02
To: 99% of gargoyles look like (MR_BASTARD) 4 of 7
You are a problem.
From: Ken (SHIELDSIT) 5 Sep 2014 01:34
To: CHYRON (DSMITHHFX) 5 of 7
Good luck getting help with that problem!   :-P
From: CHYRON (DSMITHHFX) 5 Sep 2014 01:45
To: Ken (SHIELDSIT) 6 of 7
I'm starting to get more of a handle on PDO, previously only fucked around wif MySQL stuffs, a loong time ago.
EDITED: 5 Sep 2014 01:46 by DSMITHHFX
From: 99% of gargoyles look like (MR_BASTARD) 5 Sep 2014 07:49
To: CHYRON (DSMITHHFX) 7 of 7
Well don't hesitate to come back if you need a problem then. Like I said, always happy to help!