surajkandukuri Posted October 8, 2009 Share Posted October 8, 2009 HI, I am using the below statement to insert values in to the database but i am not successful in doing so $insert_query="Insert into cat_completiondate(`EmployeeNumber`, `Cat_Num`, `CategoryJobPosition`, `Obj_Cat_Job`, `Cat_completiondate`, `First Review`, `Second Review`, `Third Review`, `Fourth Review`) values('$employeenumber',1,'$jobid',1-1-1,'$firstreviewdate[0]','$secondreviewdate[0]','$thirdreviewdate[0]','$fourthreviewdate[0]')"; $query=mysql_query($insert_query) or die("Error updating the database"); Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/ Share on other sites More sharing options...
Mark Baker Posted October 8, 2009 Share Posted October 8, 2009 Echo the query out so we can see what it actually looks like. Use mysql_error() to get any actual error message You're aware that 1-1-1 for the Obj_Cat_Job column will give a numeric value of -1 ?? Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933151 Share on other sites More sharing options...
surajkandukuri Posted October 8, 2009 Author Share Posted October 8, 2009 Hi Mark, Thank you for your reply, I have used the following query echo($insert_query); And I get the following Insert into cat_completiondate(`EmployeeNumber`, `Cat_Num`, `CategoryJobPosition`, `Obj_Cat_Job`, `Cat_completiondate`, `First Review`, `Second Review`, `Third Review`, `Fourth Review`) values(34550,'1',1,'1-1-1','1286254800',1317790800,1349413200,1380949200) And, I am not aware that it will insert only -1 for 1-1-1. IF so how to solve this ?? Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933158 Share on other sites More sharing options...
jamesxg1 Posted October 8, 2009 Share Posted October 8, 2009 $insert_query = "INSERT INTO `cat_completiondate` (`EmployeeNumber`, `Cat_Num`, `CategoryJobPosition`, `Obj_Cat_Job`, `Cat_completiondate`, `First Review`, `Second Review`, `Third Review`, `Fourth Review`) VALUES('$employeenumber', '1', '$jobid', '1-1-1', '$firstreviewdate[0]', '$secondreviewdate[0]', '$thirdreviewdate[0]', '$fourthreviewdate[0]')"; $query = mysql_query($insert_query) or die("Error updating the database"); And please use the [_code_] boxes. James. Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933167 Share on other sites More sharing options...
mrMarcus Posted October 8, 2009 Share Posted October 8, 2009 I am not aware that it will insert only -1 for 1-1-1. IF so how to solve this ??turn it into a string. right now, it's being read as an equation, one minus one minus one. Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933168 Share on other sites More sharing options...
Mark Baker Posted October 8, 2009 Share Posted October 8, 2009 What datatype are the First Review, Second Review, Third Review and Fourth Review columns in the database? Have you tried modifying or die("Error updating the database") to or die("Error updating the database: ".mysql_error()) to see what any error message might be Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933234 Share on other sites More sharing options...
mikesta707 Posted October 8, 2009 Share Posted October 8, 2009 try wrapping your arrays with {}, IE $sql = "INSERT stuff (stuff), values({$stuff[0]})"; Quote Link to comment https://forums.phpfreaks.com/topic/176986-unable-to-insert-values-into-database/#findComment-933243 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.