close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Updating Discount Code Table Error

Thread began 2/29/2016 12:41 pm by mrobben375515 | Last modified 2/29/2016 6:00 pm by Ray Borduin | 260 views | 3 replies |

mrobben375515

Updating Discount Code Table Error

I have the attached confirm.php page. See the PM for the error I am getting. I added two server behaviors to this page that is likely causing the error. First, I want to locate the recordset "discounts" based on the session variable "PromoCode". Next, I want to update that recordset field "discountStatus" with the number 1 if the order submission is successful. The errors I am getting are:

Warning: mysql_select_db() expects parameter 2 to be resource, null given in /home/content/05/11651305/html/(my domain folder)/confirm.php on line 44

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/05/11651305/html/1to1-silpada/confirm.php on line 16

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/05/11651305/html/(my domain folder)/confirm.php on line 16

Warning: mysql_query() expects parameter 2 to be resource, null given in /home/content/05/11651305/html/(my domain folder)/confirm.php on line 46
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Sign in to reply to this post

Ray BorduinWebAssist

Some code, including your database connection, got placed too low on the page. It also looks like there is some garbage on line 1. Try moving lines 58-60 to the top and remove line 1.

Sign in to reply to this post

mrobben375515

Thank you Ray. I was able to submit an order now. However, the update I was intending to do did not work. I added the following code to accomplish adding "1" to discountStatus with the rule "Successful update". Do you know why this might not be working also?

<?php
// WA DataAssist Update
if (WA_Auth_RulePasses("Successful update")) // Trigger
{
$WA_connection = $PowerStoreConnection;
$WA_table = "discounts";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "discountCode";
$WA_fieldNamesStr = "discountStatus";
$WA_fieldValuesStr = "1";
$WA_columnTypesStr = "none,none,NULL";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".$_SESSION['PromoCode'] ."";
$WA_where_columnTypesStr = "',none,''";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode($WA_AB_Split, $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_PowerStoreConnection;
mysql_select_db($WA_connectionDB, $WA_connection);
@session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

Attached Files
confirm.php
Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure what you are going for here. What is the rule "Successful update". Why not use the same button press rule as the Store cart Summary below?

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...