Jump to content

Adding columns to existing database table.


websmoken

Recommended Posts

Hi Ya'll Nice forum

Please don't hurt me too bad, I'm a newbie with a question.  I'm integrating UPS shipping into my shopping cart.  I want to add 2 more columns to the company info table.  Is it better to add at the end of the table or insert a column?  My existing columns (in order) are :comp_ID, comp_Name, comp_Address1, comp_Address2, comp_City, comp_State, comp_Zip, comp_Country, comp_Phone, comp_Fax, comp_Email, comp_ChargeBase, comp_ChargeWeight, comp_ChargeExtension, comp_enableshipping, comp_ShowUpSell, comp_AllowBackOrders.  The original query was:


if (isset($_POST["update"])){
$query_rsCW = sprintf("UPDATE tbl_companyinfo 
SET comp_ChargeBase = %s
, comp_ChargeWeight = %s
, comp_ChargeExtension = %s 
, comp_enableshipping = %s
WHERE comp_ID = %s"
,$_POST["comp_ChargeBase"]
,$_POST["comp_ChargeWeight"]
,$_POST["comp_ChargeExtension"]
,$_POST["comp_EnableShipping"]
,$_POST["comp_ID"]);
$rsCW = $cartweaver->db->executeQuery($query_rsCW);
/* Reset the application variables */
$_SESSION["ChargeShipBase"] = $_POST["comp_ChargeBase"];
$_SESSION["ChargeShipByWeight"] = $_POST["comp_ChargeWeight"];
$_SESSION["ChargeShipExtension"] = $_POST["comp_ChargeExtension"];
$_SESSION["EnableShipping"] = $_POST["comp_EnableShipping"];

header("Location: " . $cartweaver->thisLocation);
exit();
}

 

I added 1 column after comp_ChargeBase and named it comp_RemoteShipBase.  After comp_EnableShipping, I added comp_EnableRemoteShipping. I followed through with the session & post in the same order.

 


if (isset($_POST["update"])){  /* added , comp_ChargeRemoteBase = %s, comp_EnableRemoteShipping = %s */
$query_rsCW = sprintf("UPDATE tbl_companyinfo 
SET comp_ChargeBase = %s
, comp_RemoteShipBase = %s
, comp_ChargeWeight = %s
, comp_ChargeExtension = %s
, comp_EnableShipping = %s
, comp_EnableRemoteShipping = %s
WHERE comp_ID = %s"
,$_POST["comp_ChargeBase"]
,$_POST["comp_RemoteShipBase"]  /* added */
,$_POST["comp_ChargeWeight"]
,$_POST["comp_ChargeExtension"]
,$_POST["comp_EnableShipping"]
,$_POST["comp_EnableRemoteShipping"]/* THIS IS LINE 37 */
,$_POST["comp_ID"]);
$rsCW = $cartweaver->db->executeQuery($query_rsCW);
/* Reset the application variables */
$_SESSION["ChargeShipBase"] = $_POST["comp_ChargeBase"];
$_SESSION["RemoteShipBase"] = $_POST["comp_RemoteShipBase"];/* added */
$_SESSION["ChargeShipByWeight"] = $_POST["comp_ChargeWeight"];
$_SESSION["ChargeShipExtension"] = $_POST["comp_ChargeExtension"];
$_SESSION["EnableShipping"] = $_POST["comp_EnableShipping"];
$_SESSION["EnableRemoteShipping"] = $_POST["comp_EnableRemoteShipping"];/*LINE 46 */

header("Location: " . $cartweaver->thisLocation); /*LINE 48*/
exit();
}

 

I am getting error messages that reads.

 

"Notice: Undefined index: comp_enableremoteshipping in C:\wamp\www\cartweaversite\cw2\admin\ShipSettings.php on line 37

 

Notice: Undefined index: comp_enableremoteshipping in C:\wamp\www\cartweaversite\cw2\admin\ShipSettings.php on line 46

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\cartweaversite\cw2\admin\ShipSettings.php:37) in C:\wamp\www\cartweaversite\cw2\admin\ShipSettings.php on line 48

 

Can anybody tell what might be wrong?  Tell me if you need more info.

 

Thanks,

          Dave

 

http://www.websmoken.net/

Link to comment
Share on other sites

btherl

 

Are you refering to printf() ? If you are I added it and got:

 

UPDATE tbl_companyinfo SET comp_ChargeBase = 0 , comp_RemoteShipBase = 0 , comp_ChargeWeight = 0 , comp_ChargeExtension = 0 , comp_enableshipping = 1 , comp_enableremoteshipping = WHERE comp_ID = 1

 

The Only 2 that were enabled at the time was enableshipping & enableremoteshipping. I don't see where enableremoteshipping equals anything.  Shouldn't it be 1 as well? ???

 

Dave

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.