therelelogo Posted June 25, 2010 Share Posted June 25, 2010 Hi, First off, heres my code: <?php //Start session session_start(); //Include database connection details require_once('emailconfig.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $email_from = clean($_POST['toname']); $email_subject = clean($_POST['subject']); $email_body = clean($_POST['main_email']); //If there are input validations, redirect back to the registration form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: standard_make_email_failed.php"); exit(); } //Create INSERT query $qry = ("UPDATE emails SET e_read='NO' WHERE e_read='YES' and e_body = '$main_subject'"); $result = @mysql_query($qry); //Check whether the query was successful or not if($result) { header("location: standard_make_email_posted.php"); exit(); }else { die("Query failed"); } ?> the values are taken from a submit form on the previous page. now my question is regarding $qry = ("UPDATE emails SET e_read='NO' WHERE e_read='YES' and e_body = '$main_subject'"); i want to search my column for the $main_subject' value (which is a label in the form on previous page, that gets data from the table). the code directs me to the location: standard_make_email_posted.php page so i know the code works, but the value in the table doesnt amend from NO to YES, is there any obvious mistakes in my code? thanks for reading, all comments welcomed Quote Link to comment https://forums.phpfreaks.com/topic/205858-can-i-search-a-mysql-from-the-text-in-a-drop-down-box/ Share on other sites More sharing options...
fenway Posted June 27, 2010 Share Posted June 27, 2010 Sorry, I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/205858-can-i-search-a-mysql-from-the-text-in-a-drop-down-box/#findComment-1077740 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.