Dracolas Posted January 15, 2010 Share Posted January 15, 2010 http://www.sourcepod.com/nuvxds02-2532 it says that it's adding it to the database (yes i know i made it do that) but the database is still empty.. what happened? Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/ Share on other sites More sharing options...
Ayon Posted January 15, 2010 Share Posted January 15, 2010 hard to say when you ain't showing any of you code Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995717 Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2010 Share Posted January 15, 2010 Without even seeing your code I can tell you that it does not have any logic in it for error checking, error reporting (and logging), and error recovery to get it to tell you why it did not insert anything into the database, so it will be a little hard for anyone in a forum to tell you why either. If you look at any of the existing threads at phpfreaks.com where queries fail to work, you will find that in almost every case, the suggestion is to add some logic to test for and display any errors that are occurring. Short-answer: If you are sure the query is actually being executed, echo mysql_error() right after the query to find out why the query failed. Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995719 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 umm the link is a link to the code...it's over 100 lines...so i posted on source..then linked Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995720 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 code is at the link he gave and yes you are right, it is his logical flow. because you are not running the mysql_query call through an if clause. if (isset($_POST['submit'])) { // now we insert it into the database $insert = "INSERT INTO wars (`username`, `date`, `opponent`, `osite`, `type`, `player1`, `player2`, `opponent1`, `opponent2`, `cshot`, `r1shot`, `r2shot`, `r3shot`, `result`, `comments`) VALUES ( $username, getdate(), '".$_POST['opponent']."' , '".$_POST['osite']."' , '".$_POST['type']."' , '".$_POST['player1']."' , '".$_POST['player2']."' , '".$_POST['opponent1']."' , '".$_POST['opponent2']."' , '".$_POST['cshot']."' , '".$_POST['r1shot']."' , '".$_POST['r2shot']."' , '".$_POST['r3shot']."' , '".$_POST['result']."' , '".$_POST['comments']."')"; if ($add_member = mysql_query($insert)) { ?> <h1>War Added</h1> <p>Thank you, War added.</p> <?php } else { ?> <h1><center>Add War Report</center></h1><p> // etc } // etc } Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995721 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 still not doing it Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995724 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 put a print('Error: '.mysql_error().'<br/>'); call in the else { } code block to see if there's an error being thrown. Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995729 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 probbably a stupid question but WHICH else...there are like 5..lol Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995731 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 the else to the if clause that checks that your mysql_query() call worked. if (mysql_query(...)) { // query worked } else { // query failed print('Error :'.mysql_error().'<br/>'); } Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995734 Share on other sites More sharing options...
Dracolas Posted January 15, 2010 Author Share Posted January 15, 2010 i'm a dumbnut cuz i'm not seeing it....do me a fav and code it for me...or say what line...srry Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995739 Share on other sites More sharing options...
Catfish Posted January 15, 2010 Share Posted January 15, 2010 else { print('Error: '.mysql_error().'<br/>'); ?> <h1><center>Add War Report</center></h1><p> [/php Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-995740 Share on other sites More sharing options...
Dracolas Posted January 26, 2010 Author Share Posted January 26, 2010 ok for some reason there is a delay on updating on the database...is that something that i can change or is that a host issue? Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-1002117 Share on other sites More sharing options...
Catfish Posted January 27, 2010 Share Posted January 27, 2010 no idea. is this on a webhost? if it is you might have to contact support and query them about it. Link to comment https://forums.phpfreaks.com/topic/188600-not-inserting-to-database/#findComment-1002284 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.