drayarms Posted May 20, 2011 Share Posted May 20, 2011 The form below is meant to retrieve the named attribute of a form input called "limitedtextfield" , along side the current date and store those values in a database. The form contains some javascript which can be disregarded for this particular problem. [code] <form name="mymind" style= "position:relative;left:40px;" action="insert_status.php" method="post"> <input name="limitedtextfield" type="text" onKeyDown="limitText(this.form.limitedtextfield,this.form.countdown,55);" onKeyUp="limitText(this.form.limitedtextfield,this.form.countdown,55);" maxlength="55"><br> <font size="1">(Maximum characters: 55)<br> You have <input readonly type="text" name="countdown" size="3" value="55"> characters left.</font> <input type="hidden" name="submitted" value="TRUE"/> <input style="position:relative;left:0px;bottom:0px;" type="submit" name="submit" value="Submit!" /> </form> Here is the php script that processes the form. What it is meant to do is search the database and if no record is found for the authenticated member, input the relevant values into the database. If a record is found, it should update the record. Well every time I hit the submit button, all I get is a blank page. Any clue as to what is going wrong? PS: I checked the database and no values got inserted. <?php //address error handling ini_set ('display_errors', 1); error_reporting (E_ALL & ~E_NOTICE); //authenticate user require('auth.php'); //Connect to database require ('config.php'); if (isset($_POST['submitted'])) { $query = "SELECT* FROM publications WHERE member_id ='".$_SESSION['id']."' AND cartegory='status'"; $result = @mysql_query($query); $num = @mysql_num_rows($result); if ($num> 0) { $update = mysql_query("UPDATE publications SET publication = '{$_POST['limitedtextfield']}' WHERE member_id = '".$_SESSION['id']."' AND cartegory = 'status'"); header("Location: member.php"); } else { $query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )"; header("Location: member.php"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/236950-insert-query-results-in-just-a-blank-page/ Share on other sites More sharing options...
Nodral Posted May 20, 2011 Share Posted May 20, 2011 Hi Could there be a typo in these 2 lines? $query = "SELECT * FROM publications WHERE member_id ='".$_SESSION['id']."' AND cartegory='status'"; $query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )"; Should it not be category? Obviously I'm not sure about your tables, but this would seem logical? Also you're missing concatenating full stops in the 2nd line. I'd guess at $query = "SELECT * FROM publications WHERE member_id ='".$_SESSION['id']."' AND category='status'"; And $query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( ' . {$_SESSION['id']} . ',' . {$_POST['limitedtextfield']} . ', 'status', NOW() )"; Quote Link to comment https://forums.phpfreaks.com/topic/236950-insert-query-results-in-just-a-blank-page/#findComment-1217972 Share on other sites More sharing options...
dragon_sa Posted May 20, 2011 Share Posted May 20, 2011 your update is not working because you dont have a mysql_query line for $update, try changing this $query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )"; ti this mysql_query( "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )"); or you can do it like this $query = "INSERT INTO publications ( member_id, publication, cartegory, pub_date) VALUES ( '{$_SESSION['id']}','{$_POST['limitedtextfield']}', 'status', NOW() )"; $res=mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/236950-insert-query-results-in-just-a-blank-page/#findComment-1217980 Share on other sites More sharing options...
Pikachu2000 Posted May 20, 2011 Share Posted May 20, 2011 Remove the error suppression @ operators, and forget that they exist. There's probably an error being generated that you aren't seeing. (While developing, make sure error reporting is enabled also) Unrelated to the current problem, but whenever you use header(), you need to immediately follow it with exit() to prevent further execution of the code in the script. Quote Link to comment https://forums.phpfreaks.com/topic/236950-insert-query-results-in-just-a-blank-page/#findComment-1218033 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.