jeanke2 Posted November 18, 2006 Share Posted November 18, 2006 Hi,I'm receiving following error:Warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for integer: "Id nummer"In my code I'm getting a value with post from a drop down list, which gives me a groupname. Then I'm going to the table of this group to perform a query to get the groupID. This id should then be inserted into an other table. When I execute the form I always get the error above.Here's my code://here we get the group name from my form and get the groupid with the query$itemgroup = pg_escape_string($_POST['voorwerpgroep']);$querygroupid = "SELECT item_group_id FROM item_groups WHERE item_group_name= '" . $itemgroup . "'";$result1 = pg_query($querygroupid);while ($info = pg_fetch_array( $result1 )){ $itgroupid = $info['item_group_id']; settype($itgroupid, "int");}//now we insert the id in an another table:$query = "INSERT INTO item ( item_group_id) VALUES('" . $itgroupid . "')"; $result = pg_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/ Share on other sites More sharing options...
wildteen88 Posted November 18, 2006 Share Posted November 18, 2006 Umm. Please post what's wrong with the script. Whats the code supposed to do and what is it doing now. If you are getting any errors please post them in full here.Please don't just post the code. Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126588 Share on other sites More sharing options...
jeanke2 Posted November 18, 2006 Author Share Posted November 18, 2006 Sorry for that, already modified my original message. :) Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126589 Share on other sites More sharing options...
wildteen88 Posted November 18, 2006 Share Posted November 18, 2006 Are you using PostgreSQL database? I am not experienced with PostgreSQL. Also do you know which query is failing? Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126593 Share on other sites More sharing options...
jeanke2 Posted November 18, 2006 Author Share Posted November 18, 2006 I'm using a postgresql database, but I don't think that's causing the problem.The problem is in the last query. I use settype($vwgroepid, "int") to make sure it's an integer I insert (which should be), but the problem still stays. Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126596 Share on other sites More sharing options...
wildteen88 Posted November 18, 2006 Share Posted November 18, 2006 Ok. What data type does the item_group_id store? What happens if you comment out the settype($vwgroepid, "int"); line by adidng // infront of it? Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126601 Share on other sites More sharing options...
jeanke2 Posted November 18, 2006 Author Share Posted November 18, 2006 item_group_id stores an integer.(in first query: item_group_name is a varchar => therefore the typecasting to an integer.)When commenting settype nothing changes. Actually, I added this line when trying to find the problem. Quote Link to comment https://forums.phpfreaks.com/topic/27676-invalid-input-syntax-for-integer/#findComment-126604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.