Re: [PHP-DB] Not updating certain fields in same row

[email protected] ("Daniel Brown")
Newsgroups php.db
Message-ID <[email protected]>
On Tue, Mar 25, 2008 at 12:59 PM, Jason Pruim <[email protected]> wrote:
> Hi everyone,
>
>  I am attempting to update a record for a login system while leaving
>  certain fields untouched if they arn't changed, and am running into
>  issues.
[snip!]
>
>  I have tried this code:
>                 $tab = "\t";
>         if (!isset($_POST['txtLoginName']) || empty($_POST['txtLoginName'])) {
>
>                         $loginName = mysqli_real_escape_string($chpwpostlink,
>  $_POST['txtLoginName']);
>                 }
>                 else
>                 {
>                         $loginName = $tab;
>                 }

    Mmm-hmm.... and exactly how do that work to update the database?
The SQL query you're probably looking for would be like this:

    $sql = "UPDATE users SET
Field1='".mysql_real_escape_string($field1)."',Field3='".mysql_real_escape_string($field3)."'
WHERE id='".mysql_real_escape_string($id)."' LIMIT 1";

-- 
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.