jaxdevil Posted May 20, 2008 Share Posted May 20, 2008 This is a very small footprint of code but it just is not working. It displays the database insertion was successful but the database is not updated. The connection settings are pointing to the correct database. I have never posted to a 'date' database field before so maybe that is the issue. I posted a screenshot of the database below so you can see that, maybe I set the date field wrong or soemthing? <?php if ( $action== "Insert" ) { mysql_connect('localhost','xxx_xxx','xxx'); mysql_select_db('xxx_xxx') or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ()); $query = "INSERT INTO events(`id`,`date`,`day`,`name`,`description`,`active`) VALUES('$id','$date','$day','$name','$description','$active')" or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ()); print "<h1>Event Insertion Successful</h1><br>database<br /><br /><em>Updated!</em><br /><br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/106472-database-insertion-not-working-maybe-something-with-the-date-field/ Share on other sites More sharing options...
phpzone Posted May 20, 2008 Share Posted May 20, 2008 You're not actually running the query. You've setup the query string in $query but you should use mysql_query( $query ) or die ( mysql_error() ); Link to comment https://forums.phpfreaks.com/topic/106472-database-insertion-not-working-maybe-something-with-the-date-field/#findComment-545732 Share on other sites More sharing options...
rhodesa Posted May 20, 2008 Share Posted May 20, 2008 You're not actually running the query. You've setup the query string in $query but you should use mysql_query( $query ) or die ( mysql_error() ); Agreed. And where are these values coming from? If they are user supplied values or might have quotes/new lines/etc, you will want to run them through mysql_real_escape_string() Link to comment https://forums.phpfreaks.com/topic/106472-database-insertion-not-working-maybe-something-with-the-date-field/#findComment-545734 Share on other sites More sharing options...
jaxdevil Posted May 20, 2008 Author Share Posted May 20, 2008 Ahh yes, how did I miss that. Thank you very much! SK Link to comment https://forums.phpfreaks.com/topic/106472-database-insertion-not-working-maybe-something-with-the-date-field/#findComment-545744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.