Hi all, I'm having issues with PDO. I'm rather new at using it, I learned php in school and now I'm learning PDO in the work place. Not terribly difficult but I'm running into a looping issue.
I have things set up this way. We have events, documents and usergroups. Documents can be added on their own or uploaded with an event. And each document or event can be accessible by multiple usergroups. Events can have mulitple documents attached to them. And the trouble seems to occur with a for loop inside a for loop.
So the basic idea is it loops through the files array and adds each item to the database, the attachment can either be a file or a website link, if its a file it checks it to make sure that the name doesn't conflict, renames it and moves it from a temp directory (this is some old code not written by me).
The problem lies with $sqlstmt2, which is the part I've written. This part is supposed to loop throught the checkbox array and add each file to the groups table. But it only adds the first file. The loop works fine, when I print out my sql statment I get this:
insert into tblmultigroups(gid, newsid, fid) values ('1', '1', '1')
insert into tblmultigroups(gid, newsid, fid) values ('2', '1', '1')
insert into tblmultigroups(gid, newsid, fid) values ('1', '1', '2')
insert into tblmultigroups(gid, newsid, fid) values ('2', '1', '2')
but the only one that actually executes is the first one. I've been troublshooting this all morning and I just don't see the problem, and I've been trying to get it to output the error like with mysql_error() but the PDO equvilent of that is only giving me
Array (  => 00000 ) 1
Fatal error: Exception thrown without a stack frame in Unknown on line 0
9 Months Ago
Related Article:PDO error help
is a solved PHP discussion thread by rosse88 that has 15 replies, was last updated 3 months ago and has been tagged with the keywords: pdo, php, sql.
as it turns out I had made one of the variables in my table a unique id by accident and it was messing up the insert statement. Once I realized that everything started working. But thaks for the response.