PHP problem just in my server.

josejad

Expert
Licensed User
Longtime User
Hi all:

I use a software (phpmaker) to create php crud pages over a database. I think it's quite easy and powerfull (I use just a little part of its possibilities, just like with B4X). It reads your database, and you can create the add, edit, update pages based in user permissions, etc... and it has a lot of events you can use to customize the behaviour.

When you update a field, you rise a Row_Updating event, where you can check some things and change values, etc... The default function just returns TRUE, so the database is updated.
The parameters of the function are the old values of the form, and the new ones.

Well, I edit a field in a modal page, so when I close the modal, I don't get the SuccessMessage or FailureMessage (it's shown in the modal, and after the update the modal is automatically closed)

So, to debug, I set the FailureMessage to show the new and the old value of my field, and return FALSE just to keep the modal opened and see the message.
B4X:
function Row_Updating($rsold, &$rsnew) {  
    $this->setFailureMessage("new: " . $rsnew['proyecto'] . " old: " . $rsold['proyecto']);
    return FALSE;   
}

In my laptop, if I delete the value of the field "proyecto", the value is "deleted" (I mean, set to '') in my database. But in my server (VPS server with UBUNTU, mariadb and nginx) the old value remains. If I change the value for another one, is changed, but if delete the EditText value, the old value is not changed.
In both databases (my laptop and my server) "proyecto" field is set up the same way, and it allows NULL values. There's not javascript in my page to change the field before the post.

As it's said: "a picture is worth a thousand words"
This is the expected behaviour, in my laptop

This is the problem, in my server:
As you can see, if I delete the field, it has no effect.

Thanks for reading to the end :)

The original post:

P.S.: I know... someday I will learn ABMaterial or BANANO and I will change my php page...
 

aeric

Expert
Licensed User
Longtime User
PHP:
function Row_Updating($rsold, &$rsnew) { 
    $this->setFailureMessage("new: " . $rsnew['proyecto'] . " old: " . $rsold['proyecto']);
    return FALSE;   
}

Is this correct? You have a & symbol at &$rsnew ?
 

josejad

Expert
Licensed User
Longtime User
Hi aeric:

Yes, it's correct. Most of the functions are made like that:

PHP:
// Row_Selecting event
function Row_Selecting(&$filter) {
    // Enter your code here
}

// Row Updating event
function Row_Updating($rsold, &$rsnew) {
    // Enter your code here
    // To cancel, set return value to FALSE
    return TRUE;
}

// Row Update Conflict event
function Row_UpdateConflict($rsold, &$rsnew) {
    // Enter your code here
    // To ignore conflict, set return value to FALSE
    return TRUE;
}
 

josejad

Expert
Licensed User
Longtime User
I can guess that both machines are having different date format settings.
Do you mean the OS, or the Database? Anyway, I'm having no issues with the dates.

What version of php do you have on your server and on your laptop?
In my computer: PHP Version 7.2.19
Server: PHP Version 7.2.24-0ubuntu0.18.04.7
 

josejad

Expert
Licensed User
Longtime User
Thanks. I did that test too.
The parameters is: $rsnew['proyecto'] and it's the same as $rsold['proyecto'], that's why I now just show $rsnew['proyecto'] and $rsold['proyecto'] and not the SQL sentence.
 

aeric

Expert
Licensed User
Longtime User
Try to see other values are empty or not.
$rsnew['dni']
$rsnew['fecha_hasta']
AdjustSql($rsnew['proyecto'])
 

josejad

Expert
Licensed User
Longtime User
So it is specific feature to phpmaker?
Yes. The problem was that it works on my laptop, so I deduced that was the behaviour.

From the phpmaker help file:
Force Selection

For use with Auto-Suggest and/or Auto-Fill (see below) with Lookup Table. This setting must be enabled if you want to use Auto-Fill with Auto-Suggest.

When this setting is enabled, the user must select one of the auto-suggested options, the textbox will become similar to a combobox ("select-one"). This setting is usually enabled if the field is a lookup field, i.e. the field stores Link Field values (e.g. primary key) of the Lookup Table.

If this setting is disabled, the form will submit the user input (not the Link Field value) if no suggestion is selected, so make sure user input is acceptable. For example, if the Link field is same as the Display field #1, then disabling this setting should be fine and the field will save one of the suggestion (if selected) or what the user inputs.

If Allow sort/search (see Lookup Table) is enabled, usually the user wants to search the display value rather than the Link field value, so this setting is disabled automatically in the search forms, which will submit the selected suggestion's display value or the user input, and the script will search the display value of the field.

As I understand, it should works with Force Selection disabled, (but I should check the user input is right)
 
Last edited:
Top