RE: PHP MySQL Update database

by "Jan Morell" <jan_man(at)bellsouth.net>

 Date:  Sun, 3 Nov 2002 15:00:27 -0500
 To:  "John Nichel" <jnichel(at)by-tor.com>
 Cc:  <hwg-languages(at)hwg.org>
 In-Reply-To:  tor
  todo: View Thread, Original
Hi John,

Thank you VERY much. Your final code did the trick.

Jan

-----Original Message-----
From: owner-hwg-languages(at)hwg.org [mailto:owner-hwg-languages(at)hwg.org]On
Behalf Of John Nichel
Sent: Sunday, November 03, 2002 2:38 PM
To: Jan Morell
Cc: hwg-languages(at)hwg.org
Subject: Re: PHP MySQL Update database


Damnit...Not paying attention to detail....that's what I get.

$query = "UPDATE " . $dbname . ".auth2 SET log=log+1 WHERE username='" .
$username . "'";
$conn = mysql_connect( $dbhost, $dblogin, $dbpass );
mysql_query ( $query, $conn );

You forgot to single quote $username :)

John

On Sun, 2002-11-03 at 12:11, John Nichel wrote:

 > Minor correction....
 >
 > $query = "UPDATE " . $dbname . ".auth2 SET log=log+1 WHERE username=" .
$username;
 > $conn = mysql_connect( $dbhost, $dblogin, $dbpass );
 > mysql_query ( $query, $conn );

Jan Morell wrote:
> Hi Members,
>
> I have a database with a "log" column in one of the tables.  I am trying
to
> update the contents of that column when a person logs into the domain.
>
> I am able to update the database in phpMyAdmin with the following query:
>
> UPDATE auth2 SET log=log+1 WHERE username="username"
>
> This does exactly what I want it to do, but when I try to use that code in
> the PHP file as:
>
> mysql_connect("$dbhost", "$dblogin", "$dbpass");
> mysql_db_query ($dbname, 'UPDATE auth2 SET log=log+1 WHERE
> username="$username"');
>
> The database is not getting updated.  The database name variables are
stored
> in another file and included in the login php file. The $username variable
> is taken from the login form.
>
> What am I doing wrong?
>
> Jan
>
>
>
>
>
>

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA