amitojduggal Posted November 17, 2006 Share Posted November 17, 2006 Hello everybody,The code is driving me nuts from couple of daysi just can't spot whats wrong in that.i am inserting data in the database, but its not working , please someone verify the code[code] $linkid=mysql_connect("localhost","root","")or die ('Couldnt Connect To database'); mysql_select_db("details"); $query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]')"; $result=mysql_query($query);[/code]someone please tell me whats wrong in that.I will be highly thankfulAmitoj Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 Can you please try the query like this:$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";Please post the error you get Quote Link to comment Share on other sites More sharing options...
nick89 Posted November 17, 2006 Share Posted November 17, 2006 Well firstly if you are going to define link resource objects you should use them by supplying them as parameters to your subsewuent mySQL functions. Secondly, the 'all' in your query is both incorrect and unnecessary, SQL assumes all unless you qualify your statement somehow with a WHERE. Quote Link to comment Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 i don't get any error but the code simply doesn't make data inserted in sql database, i still see 0 records there,please someone check my code, i really need help.and please tell me whats the difference between[code]$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";[/code]and this way[code]$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]');";[/code]isn't both same Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 I am not sure and sometime my idea might seem to be stupid:can you please try changing the tablename "all" to something else Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 Also please try giving $result=mysql_query($query) or die(mysql_error());so that we can know if some error is there Quote Link to comment Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 ya i wrote it earlier also, the values just r not getting inserted in the databaseShould i make table again??? Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 Did you try renaming the table Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 Are they inserting balnk values or no record is inserted Quote Link to comment Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 no recordi see 0 records in that table using phpmyadmini renamed the table to "describe". Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 can you please try renaming the table with out using any mysql keywords as table namesJust a thought Quote Link to comment Share on other sites More sharing options...
esukf Posted November 17, 2006 Share Posted November 17, 2006 Need space between all and ([code]$query ="INSERT INTO all (name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";[/code] Quote Link to comment Share on other sites More sharing options...
BlueOrbits Posted November 17, 2006 Share Posted November 17, 2006 some field names are reserved in MySQLtry to add ` before and after the field name.like :[code]$query ="INSERT INTO all(`name`,company_name,designation,response,ph_number,email,`review`) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]')";[/code]you may have trouble with the filed names (name,review) I said maybe.Also you should use mysql_real_escape_string to make your script safe. Quote Link to comment Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 ok now i remade the complete table, i think i did something wrong in it.Thanks for all your help fiddy. hope to see you around in the forumBye mateThanks alot again Quote Link to comment Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 thanks everyone Quote Link to comment Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 See you mate :) Quote Link to comment 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.