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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/ 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126088 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. Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126090 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126092 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126094 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126095 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??? Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126097 Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 Did you try renaming the table Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126098 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126099 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". Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126100 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126104 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] Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126105 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. Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126106 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 Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126107 Share on other sites More sharing options...
amitojduggal Posted November 17, 2006 Author Share Posted November 17, 2006 thanks everyone Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126108 Share on other sites More sharing options...
fiddy Posted November 17, 2006 Share Posted November 17, 2006 See you mate :) Link to comment https://forums.phpfreaks.com/topic/27572-whats-wrong-with-my-code/#findComment-126109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.