RE: Update problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You might want to use single quotes

FirstName='$fname'

$sqlupdate="UPDATE UserInfo
     		SET ZNum='112763', FirstName='$fname', LastName='Short', TA='00',
		Building='1197', Room='112',  Div='FWO', Grp='IIM'
     		WHERE ZNum='112763'";

- Paul

-----Original Message-----
From: Peter Lovatt [mailto:pjln1@xxxxxxxxxxx]
Sent: Tuesday, January 20, 2004 5:17 PM
To: Kermit Short; php-db@xxxxxxxxxxxxx
Subject: RE:  Update problems


you need quotes around the name

FirstName="$fname"

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

HTH

Peter



-----Original Message-----
From: Kermit Short [mailto:k_short@xxxxxxxx]
Sent: 20 January 2004 22:28
To: php-db@xxxxxxxxxxxxx
Subject:  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
ideas?!
Thanks very much in advance!
-Kermit

<?php
$fname=$_POST['first'];
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");
  odbc_close($odbccon);
  echo "<p>Connection Closed.</p>";
 }
}
else {
 ?>
 <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"
name="test">
  First Name: <input type="text" name="first" /><br />
  <input type="submit" name="submit" />
 </form>
 <?php
}
?>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux