Saturday, 15 September 2012

update enum value from 1 to 0 mysql? -



update enum value from 1 to 0 mysql? -

i'm trying script update enum column 'read_message' in 'ptb_messages' table doesn't anything. rest of script works fine it's ignoring request update 'read_message 1 0.

can please show me im going wrong? thanks

<?php session_start(); include 'includes/_config/connection.php'; $subject = $_post['subject']; $message_id=$_get['to']; $textarea = $_post['textarea']; $query = mysql_query("select content ptb_messages id='".$message_id."'"); $results=mysql_fetch_array($query); $result=$results['0']; if($result && $textarea) { $sql = mysql_query("update ptb_messages set content ='".addslashes($textarea)."' id='".$message_id."'"); $sql = mysql_query("update ptb_messages set date_sent = localtime id='".$message_id."'"); $query = mysql_query("select suibject ptb_messages id='".$message_id."'"); $sql = mysql_query("update ptb_messages set subject = if(subject '%:reply', subject, concat(subject, ':reply')) id='".$message_id."'"); $sql = mysql_query("update ptb_messages set read_message = '0' id=".$message_id.""); $_session['message_sent']="<div class=\"message_sent\"></div>"; header("location: {$_server['http_referer']}#confirm"); } ?>

you're hitting border case in mysql. enum fields can have values referred actual value, or index in list of allowable values. you're trying utilize 0, mysql interpreting index 0 of list, internally empty string.

e.g.

myfield enum('one', 'two', 'three') myfield = 'two' => 'two' myfield = 1 => 'one' myfield = 0 => '', not in list, ignore...

if need 0/1 value field, why not utilize actual bit field, 0/1/null-only? using enums purely numeric values runs value-v.s.-index problem.

mysql

No comments:

Post a Comment