Jump to content

Recommended Posts

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?  :)

Link to comment
https://forums.phpfreaks.com/topic/120500-solved-help-to-save-nothing/
Share on other sites

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

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

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 }

 

 

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...

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']){

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.