Hello:
Okay, there has to be a simple answer that is beyond me on this. During an UPDATE, I would like to add a variable to a field. In example here, simply add the variable $varpepe101 to the contents of field pepe_99. Everything is and will be characters, this is not numeric in any way. Can someone show me where I am making my mistake please.
// Assign table to variable.
$varpepe101 = "P";
//
//
// Insert data from table where row that match this passkey.
$sql = mysql_query("UPDATE tblPepe SET pepe_99 = pepe_99.$varpepe101 WHERE tblPepe11 = 'ABC'");
mysql ... adding a field on update query ...
Moderator: General Moderators
-
pepe_lepew1962
- Forum Commoner
- Posts: 44
- Joined: Thu Nov 20, 2008 10:29 am
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: mysql ... adding a field on update query ...
Assuming that tblPepe11 is a field in the table and at least one row contains ABC:
Code: Select all
$sql = mysql_query("UPDATE tblPepe SET pepe_99 = '$varpepe101' WHERE tblPepe11 = 'ABC'");mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
pepe_lepew1962
- Forum Commoner
- Posts: 44
- Joined: Thu Nov 20, 2008 10:29 am
Re: mysql ... adding a field on update query ...
Actually, I want to combine or add the contents of the field. So if the field had HWTY in it, simple append or add the variable to the end of it, in this case, making it HWTYP.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: mysql ... adding a field on update query ...
Code: Select all
$sql = mysql_query("UPDATE `tblPepe` SET `pepe_99` = CONCAT(`pepe_99`, '$varpepe101') WHERE `tblPepe11` = 'ABC'");mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
pepe_lepew1962
- Forum Commoner
- Posts: 44
- Joined: Thu Nov 20, 2008 10:29 am
Re: mysql ... adding a field on update query ...
Yup, that did it, thank you.