Re: UPDATE and redirect

From: Date: Wed, 11 Apr 2007 14:49:35 +0000
Subject: Re: UPDATE and redirect
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-252585@lists.php.net to get a copy of this message
marcelo Wolfgang wrote:
Hi all, I'm new to this list and new to php programming so sorry if I do something wrong here :) Ok, now to my problem. I've created a query to update a mysql db, and it isn't working, and it's not throwing me any errors, so I need some help to figure out what's wrong here. My code follows : <? if($_GET['act'] = 'a'){
    $action = 1;
} else if ($_GET['act'] = 'd'){
    $action = 0;
} $id = $_GET['id']; mysql_connect("localhost","XXXX","XXXX") or die (mysql_error()); mysql_select_db ("taiomara_emailList"); $email_Query = mysql_query("UPDATE 'tb_emails' SET 'bol_active' = $action WHERE auto_id = $id"); I think you want to use back ticks for the table and column names, not single quotes. (On my keyboard this is to the left of the '1' key)
Another good idea when having query problems is to put the query into its own variable and echo it out.. like: $sql = "UPDATE tb_emails SET bol_active = $action WHERE auto_id = $id"; echo "$sql<br/>\n";
mysql_close(); ?> The page is executed, but it don't update the table ... I've tried with the '' and without it ( the phpmyadmin page is where I got the idea of using the '' ). Any clues ? Also, how can I make a redirect after the query has run ? TIA Marcelo Wolfgang


« previous php.general (#252585) next »