driz Posted April 24, 2009 Share Posted April 24, 2009 Hi, I have created a simple form that looks like this: <form action=\"admin/new_press_process.php\" method=\"post\"> <fieldset> <legend>New Press Release</legend> <ul> <li> <label><strong>Title:</strong></label> <input type=\"text\" name=\"title\" /> </li> <li> <label><strong>Body:</strong></label> <textarea name=\"body\"></textarea> </li> <li> <label><strong>Excerpt:</strong></label> <textarea name=\"excerpt\"></textarea> </li> <li> <input type=\"submit\" value=\"Submit\" /> </li> <ul> </fieldset> </form> and the new_press_process.php it submits to, looks like this: <?php $title=$_POST['title']; $date=date("Y-m-d"); $body=$_POST['body']; $excerpt=$_POST['excerpt']; $host='localhost'; $username='u0558234'; $pass='26jun87'; mysql_connect($host,$username,$pass); mysql_select_db($username); $query="INSERT INTO news VALUES (NULL,'".$title."','".$date."','".$body."','".$excerpt."')"; $result=mysql_query($query); if(mysql_affected_rows()==1) { echo '<p>Details were successfully added</p>'; } else { echo '<p>There was a problem</p>'; } ?> However it isn't submitting the contents to my database, it just displays the "There was a problem"Any ideas what the problem could be? Thanks. Link to comment Share on other sites More sharing options...
jeffman Posted April 24, 2009 Share Posted April 24, 2009 Do some basic error handling and debugging, at least.var_dump($_POST) to see what's actually arriving.use isset() to test the values of your POST variables before you go assigning them.check the return values of mysql_connect() and mysql_select_db()Echo your query string to make sure it's formatted correctly.check mysql_error() after you call mysql_query()You've gone through this before. You should know what to look for. If you do all this, and you're still stuck, come back for more ideas. Link to comment Share on other sites More sharing options...
driz Posted April 24, 2009 Author Share Posted April 24, 2009 Apparently it was because I had an image field in my database that I forgot to remove. Sorted, thanks anyways. x Link to comment Share on other sites More sharing options...
jlhaslip Posted April 24, 2009 Share Posted April 24, 2009 DD could also mention the error-reporting should be set to on for the server.Also, display-errors should be on, too. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.