954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Setting ENUM values from webform to database

Good day y'all..
I was never introduced properly to PHP so I come here a lot to seek for help. xd anyways, I have a problem at the moment.. I can't set my enum values properly..
This is how it was added to a table named "joke":

ALTER TABLE joke ADD COLUMN visible ENUM('NO', 'YES') NOT NULL;


jokes.html.php:

<?php foreach ($jokes as $joke): ?>
	<form action="?" method="post">
    <input type="hidden" name="id" value="<?php htmlout($joke['id']); ?>"/>
    <select name="visible" id="visible">
	<option value="">...</option>
	<option value="'YES'">Yes</option>
	<option value="'NO'">No</option>
	</select>
    <input type="submit" name="action" value="Set"/>
    </form>


index.php:

if (isset($_POST['action']) and $_POST['action'] == 'Set')
{
	$value = $_POST['visible'];
	include '../includes/db.inc.php';
	$id = mysql_real_escape_string($_POST['id']);
	
	// Change visibility
	$sql = "UPDATE joke SET VALUES visible='$value' WHERE id='$id'";
	if (!mysql_query($sql))
	{
		$error = 'Unable to set visibility.';
		include 'error.html.php';
		exit();
	}
	header('Location: .');
	exit();
}


So each time I try to update the visibility, I get the error message... I can't figure out what's wrong.. Thanks in advance...

kira_
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

problem solved.
changed

$sql = "UPDATE joke SET VALUES visible='$value' WHERE id='$id'";

to

$sql = mysql_query("UPDATE joke SET visible='$value' WHERE id=$id");


however, the error message still displays..

kira_
Newbie Poster
9 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: