close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

When I apply a MySQLi Manage Relational Table behavior, it is somehow applying an old function

Thread begun 4/17/2019 12:29 pm by TroyD | Last modified 6/07/2019 6:57 pm by Ray Borduin | 4759 views | 43 replies |

TroyD

When I apply a MySQLi Manage Relational Table behavior, it is somehow applying an old function

I have an old insert page that I needed to convert to MySQLi. It includes a single insert behavior and a manager relational table behavior. I stripped out all the old behaviors and js so that I could apply them as new MySQLi behaviors.

The form contains a multi select list named “ProductCategory”, populated by a rs. The list is used for the options form field in the MRT.

When I applied the MySQLi MRT behavior, it modified the select list as it has in the past by adding the [] to the select name

<select name=“ProductCategory[]" multiple="multiple" id=“ProductCategory”>

.

It also modified the option in the list to look like this…

<option value="<?php echo($rsRecordSet->getColumnVal("CategoryID")); ?>" <?php if (!(strcmp(($rsRecordSet->getColumnVal("CategoryID")), WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, ($rsRecordSet->getColumnVal("CategoryID")))))) {echo "selected=\"selected\"";} ?> ><?php echo($rsRecordSet->getColumnVal("CategoryName")); ?></option>



This is now causing a fatal error in the list box, which is understandable because I’m pretty sure that the WA_AB_returnPreSelectValue() function is an old one and isn’t used anymore.

Fatal error: Call to undefined function WA_AB_returnPreSelectValue()…


I’m not sure why or how it keeps being applied when I use the Webassist > MySQLi > Data Management > MySQLi MRT behavior.

Any thoughts?

I am using the latest download of DB 2.3.5, which I installed yesterday. I deleted the files rsobj.php and queryobj.php and regenerated them. Not sure what I’m doing wrong. Do I need to do something different to the multi select list before I apply the MRT? It’s been a while since I applied a MRT from scratch.

Thanks,
TroyD

Sign in to reply to this post

Ray BorduinWebAssist

This is just leftover code that needs to be updated...
this:

php:
<?php if (!(strcmp(($rsRecordSet->getColumnVal("CategoryID")), WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, ($rsRecordSet->getColumnVal("CategoryID")))))) {echo "selected=\"selected\"";} ?> >


should now be:

php:
<?php echo(in_array($rsRecordSet->getColumnVal('CategoryID'),$RelationalQuery_1->getSelected())?"selected":""); ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

TroyD

That's what I thought but it keeps adding it back in there when I open and make changes to the MRT behavior. I'm now getting Truncated incorrect INTEGER value: in my list and when I look at the source generated it shows this...

<option value="1" select="" parent_categoryid="" from="" category_products="" where="" parent_productid="0" and="">Truncated incorrect INTEGER value: </option>

. That looks like I have something else breaking my code maybe but I am still looking. I will double check all my syntax.

Thanks
TroyD

Sign in to reply to this post

Ray BorduinWebAssist

The code must think your MRT is mySQL and not MySQLi for some reason. It will use the old syntax with the MySQL version. I'd need FTP access and a URL to reproduce to debug it, but it sounds like the MRT server behavior may not be updated properly to MySQLi yet on the page or maybe your connection isn't being recognized as MySQLi.

Sign in to reply to this post
Did this help? Tips are appreciated...

TroyD

Ray,

This is currently on a local server. Would it help if I attached the page file?
I have several recordsets and the single insert behavior that all use MySQLi. I've removed the old connection as well.

The only original files I still have included are ckeditor/ckeditor.php, file_manipulation/helperphp.php and security_assist/helper_php.php. I've removed all the other old files.

Sign in to reply to this post

Ray BorduinWebAssist

It might help. I can take a look.

Sign in to reply to this post
Did this help? Tips are appreciated...

TroyD

Ray,

See attachment. I simplified this page as much as I could, hoping I would either see, or at least strip out any issues but it continues to elude me. If I open the MRT wizard and click through to "Finish", it adds the old code back to the multi-select box. In the attached file, I have that part removed completely and it still won't work. No matter what I do, it will not write to the relational table in my db. It inserts the main product into the product table but nothing for the relational selected options.

I am sure I am overlooking something here but I don't know what it is.

Thanks for any help you can provide me.

TroyD

Sign in to reply to this post

Ray BorduinWebAssist

With MySQLi on an Insert page, you don't have to use MRT at all. In fact, with a multi-select list like you have, you don't even need to use Multiple Insert server behavior.

You can just use the Insert server behavior and bind the DepartmentCategory array to the field you want repeated and the server behavior will do the multiple insert automatically.

Sign in to reply to this post
Did this help? Tips are appreciated...

TroyD

Ok, I wondered about that but assumed that I would at least need to use the multi-insert behavior. I did as you mentioned and it works perfectly using just the single insert behavior.

For anyone else looking for this solution, I added a second Single Insert behavior to insert into a table that acts as the relationship between the department categories table and the products table. I have 3 tables here.

tblProducts (first insert adds the new product to this table)
tblDepartmentCategories (this table holds the department categories and is used populate the multi-select list)
relDepartment_Products (second insert adds all of the selected department's ids and the product id into this table)

In the second insert, I bound the product id column to the session created by the first insert behavior. I then bound the department id’s column to the multi-select. I assume you would have to manually add [] to the name of the multi-select like this, name="DepartmentCategory[]".

If I have anything wrong here, please let me know.

So, having that one finished, I am now working on the update page for this same record. I’m not sure yet if I will see the same issues since I will need to use the MRT behavior, but I will report back.

Thanks
TroyD

Sign in to reply to this post

TroyD

I'm having the exact same issues with the update page with regards to the old code being inserted. But this time, it's inserting the old code within the part I added from your post up top.
Here is the select with your added "select if" code. It works to select the matching ids already in the relational table, but if I click Update, I loose them. All the relational ids are removed from the table. This might be a different issue, I'm still investigating that.

php:
<select name="u_DepartmentCategory[]" multiple="multiple" id="u_DepartmentCategory">

  <?php
while(!$rsDepartmentCategories->atEnd()) { //dyn select
?>
  <option value="<?php echo($rsDepartmentCategories->getColumnVal("DepartmentCategoryID")); ?>"<?php echo(in_array($rsDepartmentCategories->getColumnVal('DepartmentCategoryID'),$RelationalQuery_1->getSelected())?"selected":""); ?>><?php echo($rsDepartmentCategories->getColumnVal("DepartmentCategoryName")); ?></option>
  <?php
  $rsDepartmentCategories
->moveNext();
//dyn select
$rsDepartmentCategories->moveFirst();
?>
</select>


If I open the MRT wizard and inspect or change it, and click "Finish", this is what happens to the multi-select. You can see that not only is old code inserted, but it splits out the current if statement.

php:
<select name="u_DepartmentCategory[]" multiple="multiple" id="u_DepartmentCategory">

  <?php
while(!$rsDepartmentCategories->atEnd()) { //dyn select
?>
  <option value="<?php echo($rsDepartmentCategories->getColumnVal("DepartmentCategoryID")); ?>"<?php echo(in_array($rsDepartmentCategories->getColumnVal('DepartmentCategoryID'),$RelationalQuery_1- <?php if (!(strcmp(($rsDepartmentCategories->getColumnVal("DepartmentCategoryID")), WA_AB_returnPreSelectValue($WA_PreSelect_RelationalTable_1, ($rsDepartmentCategories->getColumnVal("DepartmentCategoryID")))))) {echo "selected=\"selected\"";} ?> >testgetSelected())?"selected":""); ?>><?php echo($rsDepartmentCategories->getColumnVal("DepartmentCategoryName")); ?></option>
  <?php
  $rsDepartmentCategories
->moveNext();
//dyn select
$rsDepartmentCategories->moveFirst();
?>
</select>



I don't have any redirects in either of the Update behavior or the MRT behavior, so I know it's not moving away form the page.
Is there a different way I should be doing this page as well?

Thanks,
TroyD

Sign in to reply to this post
loading

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