Jump to content

Recommended Posts

I must be using the wrong search terms in google cause I cant find out how to update a field to a blank spot.

 

trying to make name blank. I thought it was just " "

hope someone can please help me with this

 

mysql_query("UPDATE users SET name = '".mysql_real_escape_string "."' WHERE id = '".mysql_real_escape_string($_SESSION['user_id']))."'";

Link to comment
https://forums.phpfreaks.com/topic/252965-updating-a-field-to-a-blank/
Share on other sites

' ', is correct, it must be the ID that it's not locating. Have you tried echo'ing $_SESSION['user_id']?

 

Or perhaps try printing the query.

 

$query = "UPDATE users SET name = '".mysql_real_escape_string ."' WHERE id = '".mysql_real_escape_string($_SESSION['user_id']))."'";
$run = mysql_query($query);

 

 

EDIT:

Actually, I've just noticed there's a few errors in your line of code, try this:

mysql_query("UPDATE users SET name = '' WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'");

thanks alot Karl that works!!!

I really appreciate the help

 

now i need to figure out why it only echos "you need to check the box" when I hit toture but not surrender

any ideas?

 

if (isset($_POST['surrender']) || (isset($_POST['toture']))) {


	if(!isset($_POST['agree'])){
			echo "You need to check the box";

} else {

	mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']));

this the entire code.

really appreciate you taking time out to help me

 

<?php
if (isset($_POST['surrender']) || (isset($_POST['toture']))) {


	if(!isset($_POST['agree'])){
			echo "You need to check the box";

} else {

	mysql_query("DELETE FROM `users` WHERE `id`= ".(int)($_SESSION['user_id']));

	// logs you out and destroys the session and redirects you to signup page
header("Location: signup.php");
session_start();
session_destroy();
exit();


}

}
?>

 

I dont dont know why i have such huge problems understanding these "'"

 

I really thought this below would work but it keeps giving me unexpected T_STRING error

 

mysql_query("UPDATE users SET password='"$password"' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")

On your first post, where is $_POST['agree'] defined?

 

Also, change:

mysql_query("UPDATE users SET password='"$password"' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")

 

 

To:

 mysql_query("UPDATE users SET password='".$password."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")

ahh I always wonder why some times my code boxes were huge and other time small didnt realize it was cause of the php tags. sorry about that.

 

 

<?php
if (isset($_POST['change'])) {

				// checks if password matches confirm password
	if ($_POST['new'] != $_POST['confirm']) { 
			echo 'Your confirm password does not match your password';

} else {

				// updates the passowrd for password recovery
	mysql_query("UPDATE users SET forgotpd='".mysql_real_escape_string($_POST['confirm'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")


		$password = md5($_POST['new']);	

				// Updates password with Md5
	mysql_query("UPDATE users SET password='".$password."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")			

	echo "Your password has been changed";

}

}
?>

 

 

im getting a error first on this line unexpected T_STRING

 

<?php $password = md5($_POST['new']); ?>

Alright decided to get rid of some stuff to help problem solve

 

I'm getting a } error for some reason with this. if I delete the mysq1_query there is no errors

 

<?php
if (isset($_POST['change'])) {

				// checks if password matches confirm password
	if ($_POST['new'] != $_POST['confirm']) { 
			echo 'Your confirm password does not match your password';

			} else {	
                                                                                  //updates the passowrd for password recovery	
			mysql_query("UPDATE users SET forgotpd='".mysql_real_escape_string($_POST['confirm'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'"}
	}
}
?>

I haven't exactly read every reply in here, but wouldn't it be easier to set name to NULL instead of a white-space?

This way you could simply SET name = NULL

 

You could also query for null values with WHERE name IS NULL

I found out what was wrong

 

there has to be a ; at the end

 

<?php mysql_query("UPDATE users SET forgotpd='".mysql_real_escape_string($_POST['confirm'])."' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'"); ?>

 

 

yah i was reading about null

 

i never had any scripts when learning that messed with null so i guess fear leads me ha

 

I"ll mess around with the NULL though thanks for that

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.