Bullet Posted August 20, 2008 Share Posted August 20, 2008 Well I'm trying to make a notepad & everytime I clear it and save it dosen't let me if there isn't a word or space there. Abit of the script: if (($_POST['change_notes']) && ($_POST['notes'])){ $notes=strip_tags($_POST['notes']); mysql_query("UPDATE members SET notes='$notes' WHERE username='$username'"); echo "Your notepad has been updated."; } ?> Any help? Please? Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/ Share on other sites More sharing options...
Fadion Posted August 20, 2008 Share Posted August 20, 2008 Are you getting any errors? Try this code to check if the query fails and what errors it shows: mysql_query("UPDATE members SET notes='$notes' WHERE username='$username'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-620952 Share on other sites More sharing options...
Bullet Posted August 20, 2008 Author Share Posted August 20, 2008 There is no error, it just refreshes Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-620964 Share on other sites More sharing options...
budimir Posted August 20, 2008 Share Posted August 20, 2008 Maybe, you could use: if (isset($_POST[])){ mysql_query("UPDATE members SET notes='$notes' WHERE username='$username'"); echo "Your notepad has been updated."; } else { do nothing } I'm not quite sure what you're problem is, but maybe this can help Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621001 Share on other sites More sharing options...
r-it Posted August 20, 2008 Share Posted August 20, 2008 if it has to do with your sql statement, change this: mysql_query("UPDATE members SET notes='$notes' WHERE username='$username'"); echo "Your notepad has been updated."; } ?> to mysql_query("UPDATE members SET notes='".$notes."' WHERE username='$username'"); echo "Your notepad has been updated."; } ?> and also check that the syntax is correct Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621024 Share on other sites More sharing options...
Bullet Posted August 20, 2008 Author Share Posted August 20, 2008 I changed to what budimir said it came up with a error saying: Fatal error: Cannot use [] for reading in /home/public_html/editnotepad.php on line 15 PHP: if (($_POST['change_notes']) && ($_POST['notes'])){ $notes=strip_tags($_POST['notes']); if (isset($_POST[])){ mysql_query("UPDATE users SET notes='$notes' WHERE username='$username'"); echo "Your notepad has been updated."; } else { do nothing } Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621034 Share on other sites More sharing options...
budimir Posted August 20, 2008 Share Posted August 20, 2008 That's right you need to do this: if (($_POST['change_notes']) && ($_POST['notes'])){ $notes=strip_tags($_POST['notes']); if (isset($_POST['notes'])) { mysql_query("UPDATE users SET notes='$notes' WHERE username='$username'"); echo "Your notepad has been updated."; } else { do nothing } I thought you are going to notice that! Sorry... Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621036 Share on other sites More sharing options...
PFMaBiSmAd Posted August 20, 2008 Share Posted August 20, 2008 The first line is back to the original logic and won't execute anything when $_POST['notes'] has been cleared. If you want your query to execute when you have cleared the 'notes' form field, just use - if ($_POST['change_notes']){ Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621041 Share on other sites More sharing options...
Bullet Posted August 20, 2008 Author Share Posted August 20, 2008 Thanks so much all! Quote Link to comment https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/#findComment-621082 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.