you need quotes around the name


otherwise it takes the value of $fname to be  aa field name



-----Original Message-----
From: Kermit Short [mailto:[EMAIL PROTECTED]
Sent: 20 January 2004 22:28
Subject: [PHP-DB] Update problems

I'm trying to update a record in a MSSQL database.  When I execute the
following code on an IIS5 webserver, I get an error message that says:

PHP Warning: odbc_do(): SQL error: [Microsoft][ODBC SQL Server Driver][SQL
Server]Invalid column name 'Tom'., SQL state S0022 in SQLExecDirect in
E:\web\phptest\dbtest.php on line 31

This is after I've submitted the name Tom in the form.  Does anyone have any
Thanks very much in advance!

if (!(is_null($fname))) {
 if (!($odbccon = odbc_connect("******", "******", "******"))) {
    die("<p>Could not Connect.</p>");
 else {
  echo"<p>Connected to Database.</p>";
  $sqlupdate="UPDATE UserInfo
     SET ZNum='112763', FirstName=$fname, LastName='Short', TA='00',
Building='1197', Room='112',  Div='FWO', Grp='IIM'
     WHERE ZNum='112763'";
  $sqlupdresults=odbc_do($odbccon, $sqlupdate);
  $query="SELECT * FROM UserInfo WHERE ZNum=112763";
  $qresults=odbc_do($odbccon, $query);
  odbc_result_all($qresults, "border=1");
  echo "<p>Connection Closed.</p>";
else {
 <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"
  First Name: <input type="text" name="first" /><br />
  <input type="submit" name="submit" />

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to