Jump to content

[SOLVED] Help to save nothing!


Bullet

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

Archived

This topic is now archived and is closed to further replies.

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