leest Posted July 21, 2008 Share Posted July 21, 2008 I have some info i am trying to add to my database but it just keeps returning the following error: Error insert query failed. I have tried writing this query many different ways but fet the same answer, any suggestions would be appreciated. Thanks $query = "INSERT INTO dashboard_component (dashboard_component_id, module_name, module_parameters, site_id, column_number, position) VALUES (13, 'text', 'Welcome', '((USERNAME))!\r\nDate: ((DATE))\r\nTime: ((TIME))', '$site_id', 0, 1)"; mysql_query($query) or die('Error, insert query failed'); Quote Link to comment Share on other sites More sharing options...
Xurion Posted July 21, 2008 Share Posted July 21, 2008 Replace mysql_query($query) or die('Error, insert query failed'); with mysql_query($query) or die(mysql_error()); to see the real error. Quote Link to comment Share on other sites More sharing options...
leest Posted July 21, 2008 Author Share Posted July 21, 2008 Cheers i'll give it a try Quote Link to comment Share on other sites More sharing options...
leest Posted July 21, 2008 Author Share Posted July 21, 2008 ok, Thanks for that, another stupid mistake, i had a mismatch in column numbers all fixed now thanks, but now i have another problem i need this part of the insert script to have " " around it like so: $query = "INSERT INTO dashboard_component (dashboard_component_id, module_name, module_parameters, site_id, column_number, position) VALUES (13, 'text', 'Welcome', '"((USERNAME))!\r\nDate: ((DATE))\r\nTime: ((TIME))"', '$site_id', 0, 1)"; mysql_query($query) or die('Error, insert query failed'); however when i write it like this it just gets binned and shows a blank page, when i take them out it works fine. I need to add the "" so the info is formated for when it is read from the database table and then displays the username. Does any body have any ideas or suggestions Quote Link to comment Share on other sites More sharing options...
Xurion Posted July 21, 2008 Share Posted July 21, 2008 If I write a string like so: "This is "my" string." it breaks at the second " You can fix it using backslashes like this: "This is \"my\" string." 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.