close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi statements failing to execute

Thread began 1/15/2019 9:18 am by s.joiner74419001 | Last modified 1/24/2019 11:51 am by Ray Borduin | 76 views | 8 replies |

s.joiner74419001

MySQLi statements failing to execute

I am currently in the process of updating a website with MySQLi server behaviours. On my first page test I am getting the following error: “Your SQL statement failed to execute.”

Any ideas what could be causing the problem. I have attached the page plus a link to the page on the remote server with FTP and database connections in the attached PDF.

To the replicate the test, scroll down to the “Get an Estimate” link and submit the small form which should execute two “Insert Record Behaviours|

Thanks in advance!

Sign in to reply to this post

Ray BorduinWebAssist

You can update the rsobj.php file to tun on the debug option in order to get the actual error message.

In this case the error is: "Column 'address' cannot be null"

This is because your database is set up to not allow null values for the address column in your database, and in the insert server behavior you have the "value if blank" setting for that column set to "null".

You can either update the database to allow null in that column, or update the server behavior to insert "blank" instead of "null" when that insert value is blank for that column.

Sign in to reply to this post

s.joiner74419001

Thanks Ray.. school boy errors!!

Now I've got the data being inserted. I now have a problem with an email behaviour that gets triggered at the end of the form submit from "quote-result.php". This was working fine before the MySQLi updates.

The email body ( blank_6.php ) uses some database bindings from a recordset. I wasn’t sure how to update the bindings for the correct code so I have pasted the connection file code and rsobj file code directly into the email body file with the recordset code.

I have tested with and without the PHP/MySQLi code so I don’t think its the bindings that is effecting the mail sending.

I have tried ‘mail’ and ‘SMTP’ methods from the email behaviour.

Any ideas?

Sign in to reply to this post

Ray BorduinWebAssist

You have a redirect in your update server behavior before the email is sent. You will need to remove the redirect from the update and move it to the email server behavior so it can send before the redirect occurs.

Sign in to reply to this post

s.joiner74419001

Thanks for that Ray.
I now have an issue with my contact form, which incidentally was working fine before MySQLi updates. Strangely the emails are sending when tested on my localhost which is running PHP 7.2.10. But they're not sending on the live server. I have tried with PHP versions 7.2 and 7.3 which its currently set as but with no joy.

Any Ideas?

Link to test page in PM

Sign in to reply to this post

Ray BorduinWebAssist

Some servers require an active email address as the FROM address. I updated yours to use the same email address you had set as the TO address and that seems to have fixed it.

Sign in to reply to this post

s.joiner74419001

Sorted.. thanks Ray

Not sure if its ok to continue through this thread but I will as you have FTP/DB access

I now have this problem:

using basic PHP calculation as value for database update


<?php
$totalCost = ($rsCalculate->getColumnVal('no_of_flats') * 75) + ($rsCalculate->getColumnVal('no_of_blocks') * 500);
?>

The recordset is built from a session variable that is created from an 'Insert record behaviour" on the previous page you are directed from.
This works fine as I have tried binding $totalCost into the page and it shows.
I want to bind this value to a column value in an “Update record behaviour” that is triggered by an access rule that checks a URL variable value.
The binding comes from a small form with a single hidden element that holds the $totalCost value.
The “Update record behaviour” is being triggered as I use a redirect to the same page with a url variable test. The problem is the $totalCost value is not passing.

The two pages in question here are

https://www.rtmf.org.uk/admin/new-enquiry.php

https://www.rtmf.org.uk/admin/enquiry-list.php

Sign in to reply to this post

Ray BorduinWebAssist

Please start new threads with new issues, so that users that might have the same problem can find them more easily and we don't dirty up threads with good questions and answers with unrelated issues.

I'm not sure how you would expect this page to work. You have a form with a single form element in it, but I don't think that form is ever submitted.

Did you want the value to be updated every time this page is accessed? Or did you have a link that adds the url parameter that triggers it?

My guess, without fully understanding the problem or what you are doing, is that you can fix the problem by:

1) deleting the form and hidden form element completely (it isn't doing anything)
2 updating this code:

php:
<?php

if (WA_Auth_RulePasses("submitted")) {
  
$UpdateQuery = new WA_MySQLi_Query($RTMFi);
  
$UpdateQuery->Action "update";
  
$UpdateQuery->Table "enq_details";
  
$UpdateQuery->bindColumn("estimated_fee""s""".((isset($_POST["total_cost"]))?$_POST["total_cost"]:"")  ."""WA_DEFAULT");
  
$UpdateQuery->addFilter("enq_det_id""=""i""".$_SESSION['enquiryDetID']  ."");
  
$UpdateQuery->execute();
  
$UpdateGoTo "enquiry-list.php?redirect=yes";
  if (
function_exists("rel2abs")) $UpdateGoTo $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
  
$UpdateQuery->redirect($UpdateGoTo);
}
?>
<?php
$totalCost 
= ($rsCalculate->getColumnVal('no_of_flats') * 75) + ($rsCalculate->getColumnVal('no_of_blocks') * 500);
?>



to:

php:
<?php

$totalCost 
= ($rsCalculate->getColumnVal('no_of_flats') * 75) + ($rsCalculate->getColumnVal('no_of_blocks') * 500);
?>
<?php
if (WA_Auth_RulePasses("submitted")) {
  
$UpdateQuery = new WA_MySQLi_Query($RTMFi);
  
$UpdateQuery->Action "update";
  
$UpdateQuery->Table "enq_details";
  
$UpdateQuery->bindColumn("estimated_fee""s""".($totalCost)  ."""WA_DEFAULT");
  
$UpdateQuery->addFilter("enq_det_id""=""i""".$_SESSION['enquiryDetID']  ."");
  
$UpdateQuery->execute();
  
$UpdateGoTo "enquiry-list.php?redirect=yes";
  if (
function_exists("rel2abs")) $UpdateGoTo $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
  
$UpdateQuery->redirect($UpdateGoTo);
}
?>



There is no need to use a hidden field or form at all, you can update the table with the calculation directly once you do the calculation above the update code.

Sign in to reply to this post

s.joiner74419001

Apologies Ray... I will in future start a new threading this situation.

I now realise the form was completely unnecessary.
I had tried using the calculation directly.. Which would have worked but I have noticed what was wrong with my update behaviour. the filter was referring to the wrong session ID.

$UpdateQuery->addFilter("enq_det_id", "=", "i", "".$_SESSION['enquiryDetID'] ."");

Should have been
$UpdateQuery->addFilter("enq_det_id", "=", "i", "".$_SESSION['enquiriesDetID'] ."");

Working fine now.. Many thanks

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...