The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Invalid parameter number - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Invalid parameter number (/showthread.php?tid=989) |
Invalid parameter number - WebAIFHS - 03-05-2018 May be a "newbie" being stupid but need help. I maintain the website for the "Anglo-Italian Family History Society" and am looking to change the access to the various pages to improve security. At the moment the site access is split between "open", "members only" & "committee only" and is controlled by the host on a protected directory basis with a single userid/password for all members and a different on for the committee. I have been asked to provide individual logins for each person etc and Userspice seems to be the solution. I am currently "playing" with it on my development system keeping the sites "page look & feel". The first thing I'm tackling is to link the Userspice "users" table with our "members" table which needs a mutual link "aifhs_id" in both tables. I have produced php code based on the Userspice code that is supposed to transfer the members details to the user table and add a default password. Hoewver I get the following error:- Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\AIFHS\Klamath\users\classes\DB.php on line 62. I have enable DEBUG in the query function in DB.php and get the following display:- DEBUG: query(sql=INSERT INTO Code: users Code: email Code: username Code: password Code: fname Code: lname Code: permissions Code: join_date Code: created Code: aifhs_id As far as I can see there are 9 table entries and 9 data items so don't understand the error. Can you more experienced people point me in the right direction? Nello Ostacchini Invalid parameter number - Brandin - 03-06-2018 There are definitely 9 parameters being passed (at least thats what it looks like), I am wondering how you have your DB query structured. Can you show us? This would be your $db->insert or $db->query statement. Thanks! Brandin. Invalid parameter number - WebAIFHS - 03-09-2018 Hi Brandin, Thanks for your reply. I've extracted the relevant lines of code from my script:- $sqlu = "INSERT INTO Code: users Code: email Code: username Code: password Code: fname Code: lname Code: permissions Code: join_date Code: created Code: aifhs_id $insert_memdat = array($paramsu['email'], $paramsu['username'], $paramsu['password'], $paramsu['fname'], $paramsu['lname'], $paramsu['permissions'], $paramsu['syear'], $paramsu['created'], $paramsu['aifhs_id']); if (!$db->query($sqlu,$insert_memdat)); { die('Error adding user: '.__LINE__); } Between the first & second line of code there is a chunk of code that populates the array $paramsu with the data from my "members" table and generates the password using the UserSpice code plus additional elements that I require elsewhere in the code. I did initially have the required elements listed in the db->query call but changed it to the above where I assign them to the array $insert_memdat. I get the same error whichever I adopt. May I ask another newbie question please? Is there an explanation of the fields in the "users" table available anywhere so that I can understand what each is used for? For example I want to allow the member to be able to change the "username" from the one that is automatically generated by my "enrolment" script following their payment via PayPal. Is there some "users" setting I need to change? Regards Nello Invalid parameter number - WebAIFHS - 03-10-2018 Hi Brandin, An update - I changed the $db->query to $db->insert("users",["email"=>$paramsu['email'], "username"=>$paramsu['username'], "password"=>$paramsu['password'], "fname"=>$paramsu['fname'], "lname"=>$paramsu['lname'], "permissions"=>$paramsu['permissions'], "join_date"=>$paramsu['syear'], "created"=>$paramsu['created'], "aifhs_id"=>$paramsu['aifhs_id']]) That worked so I'm happy with my work-around. REgards Nello Invalid parameter number - Brandin - 03-11-2018 Glad to hear this, sorry I haven't had much time to help, I will keep this on my radar to look into it deeper for you to hopefully provide a more elegant solution! |