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
https://forums.phpfreaks.com/topic/233022-title-is-0/
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
https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198474
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
https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198478
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
https://forums.phpfreaks.com/topic/233022-title-is-0/#findComment-1198488
Share on other sites

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.