Insert Database Not Working


Danny Cheah

Dear All,

I need help. My php script works on its on but when I run it via AB it does not insert. I've check and could not detect what is wrong. I'm not sure where the error is on my php script.


Thank you.
Best regards,
Danny Cheah

decsoft

Hello Danny,

May can be difficult to help in this case, even when we are happy to do it when possible. Taking a look there is no syntax errors in the script, so, they must work, at least in order to see what happen. Since you are using the stuff provided by the Database app sample, look at the "Initialization.php" script, and, change the below lines:

... by the below lines:

Doing that we are ready to receive any possible PHP error. But that's what we can do... debug the HTTP call to see what happen, place some "echo" in the script that can help us to see what happen, in few words: debug the script...

Check that the database connection is OK, look for the HTTP call response (is the Error event of the HTTP client fired?). Do it in a brower like Firefox with the Console Developer open: this offer to us lot of information about the HTTP call, what code response we get, what response text, etc.

Please, try the above, and, post here what happen, if you get an specific error message, etc.



Danny Cheah

Hi David, 

I have already make the changes for the following in my Initialize.php

Now to test it, do I run the script from my brower and not from my AB right? 


Thank you.
Best regards,
Danny Cheah

Danny Cheah

Hi David, 

I ran the script from the browser and it was successful. It managed to insert into the database.


Thank you.
Best regards,
Danny Cheah

decsoft

Hello Danny,

Please, use the "code" HTML tag when you post code or console outputs, etc. About your last question, in fact it's not important if the script is called outside of AB or not, that is, the script expect certain arguments (comming from the POST input), and therefore they do their work. That is, except if you setup one, talking about this specific script, we no need to call it from AB in order to put it working.

But maybe the above is not what matter here... what matter here is that you can / must debug the script, and to do this you can call to the script using AB or another tool: probably it's better to call it using AB, so you are not only debugging the server script, but also the client side. But it's completely up to you how you debug the script. What I recommend is that you use a browser like Firefox with the Console developer opened, that is, launch the app (from AB) in Firefox or other browser.



decsoft

Hello Danny,

Sorry, I see now your latest post. If the script works in an "alone" way, there is no reason to work calling it from AB, if you provide to the script the right arguments, of course. But, if something is wrong, if some argument is missing, then the script must provide the right response, so the client side (the AB app) can know what happen and what to do.

But remember: there is no differences between a call to the script "alone" and a call to the script "from AB"... in both cases we are talking about HTTP calls, that must include the right arguments, etc. If the AB calling to the script don't work... then something is wrong and you must investigate what happen.



Danny Cheah

Hi David, 

I have check the call from AB and my code as per below. I don't see any problem with the code: 


Thank you.
Best regards,
Danny Cheah

decsoft

Hello Danny,

Please, please, use the HTML code tag when post code... in other case I must do it for you! About your question, certainly, the code that you shown appear correct, so, the point is what happen... for that reason I told you to use the Firefox Developer Console... after you made the HTTP call using your AB code, something must happen... the request must end... successfully or not... may you can see some other error, etc.



Danny Cheah

Hi David,

Sorry I don't quite understand what you mean by use HTML code tag. Can you explain more. Sorry for being a pain as I'm try to learn as much as I can. 

Also, 


Thank you.
Best regards,
Danny Cheah

decsoft

Hello Danny,

No problem! (sorry if I appear rude, that's not my intention at all!) When you write your posts here in this forum, you use some "p" HTML tags to define paragraphs. Ok, just in the same way use the "code" HTML tag, and place inside that HTML code tags the code that you wanted. Look here for more information about the "code" tag.



Danny Cheah

Hi David,

You are not rude. It's me that I am very new that makes it hard for you. 

I thought I use the html code to post my question becuase I'm using this link to compose my message https://html-online.com/editor/

I must not have work. I will study the html code then. 

Sorry for all the incovenience caused. 

 

By the way, I managed to solve my script problem. I have a spelling mistake under the HTML properties URL. 


Thank you.
Best regards,
Danny Cheah

decsoft

No problem at all! Glad to know that you finally catch the problem :-)


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.