Jump to content

$title is 0?


3raser

Recommended Posts

I've tried mysql_error(), yet nothing is displayed, but I'm pretty sure it may be something wrong with my query. After someone inputs their new information, site title in the database is changed to 0, and description isn't updated at all.., but it's still the same data as before and isn't changed.

 

if(!$_POST['title'] || !$_POST['description'])
		{
			echo "
			<table><form action='account.php' method='POST'>
			<input type='hidden' name='edit' value='1'>
			<tr><td>Site Name</td><td><input type='text' name='title' value='". $grab['title'] ."'></td></tr>
			<tr><td>Site Description</td><td><textarea name='description' rows='18' cols='40' maxlength='550'>". $grab['description'] ."</textarea></td></tr>
			<tr><td>Finished?</td><td><input type='submit' value='Update Information'></td></tr>
			</form></table>";
		}
		else
		{
			$title = mysql_real_escape_string(strip_tags($_POST['title']));
			$description = mysql_real_escape_string($_POST['description']);

			$to_censor = array("fag", "ass", "asshole", "douchebag", "dumbass");
			$new = str_replace($to_censor, "****", $description);
			$description = strip_tags($new, "<b><i><a>");

			mysql_query("UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'") or die(mysql_error());

			echo "Updated information successfully. <a href='account.php'>Back to My Account</a>";

		}

Link to comment
Share on other sites

Separate the query string from the query execution, and echo the query string so you can make sure it's properly formed.

 

$query = "UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'";
$result = mysql_query( $query );
echo $query;

Link to comment
Share on other sites

Your UPDATE query is AND'ing the contents of your `description` field with the value in '$title' and storing that in the `title` column -

 

SET title = '$title' AND description = '$description'

 

The SET term is a comma separate list of column = value pairs. AND is a logical operator.

Link to comment
Share on other sites

Your UPDATE query is AND'ing the contents of your `description` field with the value in '$title' and storing that in the `title` column -

 

SET title = '$title' AND description = '$description'

 

The SET term is a comma separate list of column = value pairs. AND is a logical operator.

 

Thank you for that!

Link to comment
Share on other sites

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.