This is a very similar to the question posed at Use php and simPro API to list customers.
The response to that question suggests downloading examples from GitHub. I have downloaded the SimPro examples at GitHub and have them functioning on the commandline.
I want to be able to use a web page as an intermediary between my FileMaker Pro database and the SimPro API. I can pass data to a web page written in PHP. It can convert the data to JSON and form a call to SimPro receive a response and display the success or failure as a web page.
Presently I have my JSON data hardcoded so that I can test the process. When run from a web browser I don't get a result, though the code works perfectly well running from the command line.
I'm not sure what I need to do make the examples web compatible. Can someone push me in the right direction?
Would be more than happy to help - could you post a snippet of your code - minus the auth info of course - so that I can try to assist?
Do you have your code printing anything else to the browser first - so that you make sure the script is actually executing as it should from the web server side - and have you checked your web server logs for any errors?
In some cases I've seen this is usually due to PHP config (there are separate configs for CLI and CGI in most setups) and can mean whilst libraries are loaded in one environment they may not be available to the other. The web server also usually requires a reload if you have just loaded libraries for use within your script.
Hope that helps.
Related
I'm building small application to collect data. For data collection PHP is used, for data storage PostgreSQL is used. PostgreSQL is included so I have full control over it. The PHP for collection is triggered by external entity and I have no control over PHP interpreter that will run the code.
Is there a way how to load php_pgsql.dll? at run-time?
I know it was asked already, for example here, here and my best source of information was here. If I get it right there is no way if I'm not root of the system (because dl() was removed).
I can add PHP to my application the same way I have added PostgreSQL (to have control over PostgreSQL and do not need to ask someone to install, configure, maintain...), BUT my PHP files are triggered by external application so I have no control over used PHP interpreter/environment.
Is there a way to start from PHP code (let's call it systemPHP) the same PHP code but in different PHP environment (myPHP environment I have control over and where I will have the dll included)?
For example if systemPHP starts collect.php the pseudo code of collect.php will be:
if <this is myPHP> { # How to detect it?
<execute the data collection code>
}
else {
<Start collect.php in myPHP transfering all the data to it> # For example if started by apache then also headers, session information etc...
<Send back result from myPHP via the systemPHP>
}
How to achieve this PHP 'tunnel'?
Thanks for any help or hint. I know that best will be root or at least have intelligent admin, however this is not the case :-(
Currently I'm trying workaround by executing database tasks via shell and then getting response back in PHP, but sometimes it works sometimes not and I believe there is a better way of doing this (not to mention speed and resource usage).
Have you looked into using a messaging queue system? Write to the queue, then have your PHP script running that has php_pgsql.dll already loaded, which checks for new messages in the queue and processes them.
Before this question gets closed, I know the setup above is possible. I just want clarification on some things.
I just started learning Aurelia because I want to convert one of my projects into a web app. My project is built with html+css+JavaScript(jQuery)+ PHP(MySql).
I havent used any sort of framework before.
In the guide, they mention a few ways to setup a web server. I used the http server with node. Now this is where I need some help understanding a few things.
I dont want to use node.js. I want to use PHP on the server. Will that work and how?
When using Apache server, I know any PHP page is sent to the interpreter that renders the final html. I use XAMPP and its apache comes bundled with PHP. Does the http server used by node come with PHP? Is this even a sensible question?
Now I know Aurelia is purely front end. If it used to make single page applications, it uses Ajax. So now I made the following assumption:
Using Aurelia, the user accesses the root page of the app that the web server sends. After that, Aurelia makes various Ajax requests to the server which will use my PHP files to do database query stuff.
Is that right or am I missing something. And can I just use xampp(apache) to host my app instead of server from node?
Aurelia is a framework that, after you export it to any server, does not rely on any back-end software at all. This means that with the help of the http- / fetch-client API, you can just call out to your php script.
I have an example in my github:
https://github.com/rjpvroegop/randyvroegop.nl-made-with-aurelia
Here I use the http-client to post data to my php script wich has a very simple email functionality.
You can see the action inside my view-model in src/pages/contact/index.js.
You can see the PHP script in src/assets/components/contactengine.php.
These work the way they should. Note: you have to change your gulp build if you want your PHP served the way I serve mine, from the dist folder after gulp-watch or gulp-export.
Next to that you can use any back-end functionality you would like, as long as it returns the proper data. This PHP script does that. If you would download my distribution to test this you can simply do the following:
gulp export from your terminal in the root folder
copy everything from the export folder to your PHP webserver.
I wrote an HTML page using XAMPP on my Windows computer, and everything works great locally. However, I want to host the content on a website, and I have no idea how to do it. Here it is as is, with a PHP code displayed, instead of actually running.
Does github.io support running PHP at all? I read that it doesn't. If so, where would I be able to host my code so that my PHP and JavaScript could run given that I point my browser to the webpage's URL? Also, XAMPP had linked it to an MySql database, but I am unsure of how to set that up as well on a server.
These seem like simple questions for the beginning web developer, but I scoured Google and couldn't find an answer. Thank you.
To deploy php on the server you have to check:
Is there PHP?
Take care of pretags
Check version of php (it will run with error if php parser is on)
Configure your wwwroot or httpdocs or hotdocs (webpage public folder)
Take care of .htaccess if something is crashing
And not every server is apache and not every server is node and not every... Just ask support of this hosting because in some cases you have to "turn on" PHP by some fancy button.
Have a nice day!
No, Github Pages doesn't have PHP, it's only meant to host static pages. It does support Jekyll, a static site generator (in that it generates static pages once per push which are then hosted as-is), but that's about all.
PHP/MySQL is only one of the many sets of possible web application technologies, so you can't expect it to be everywhere where web hosting is. It has to be either explicitly listed on hosting service's website, or be available for installation in case you get yourself a full-fledged server machine (maybe virtual) to run your website.
Browser-based JavaScript will still be run by the client, since it's not the server's responsibility to run it, just the delivery. So it can be hosted on GitHub Pages. Also, 3rd party services that don't depend on your own server's code execution are usable too: stuff like commenting systems, searches (you can even make a client-side one!) and analytics.
Ive built an AngularJS application over the last several months that utilizes a MySQL database for its data. This data is fetched by Angular making calls to PHP and PHP returns JSON strings etc.
The issue is once this application is running inside node-webkit, none of the php works, so all of the content areas are empty. I assume (though the documentation on this issue is null and so i have no confirmation) this happens because Node-webkit is a client-side application framework and therefor wont run server-side languages like php. Is there a way to expand node webkit to run php and other server side languages?
I have done my best to find an answer to this question before posting, but documentation for this is nonexistent, and all of the information I have found about node-webkit talks about installing node on your server and installing npms for MySQL and having angular make calls to node. This defeats the purpose of the application entirely as it is designed so that the exe/deb/rpm/dmg can run and you can set up a database with any cloud database provider and be ready to go. Not ideal if you have to buy a vps just to run this one thing.
I have to assume this is possible in some way. i refuse to believe that everyone with an nw application hard codes all their data.
Thanks in advance
I know of four methods to accomplish this. Some of which you have preferred not to do but I am going to offer them in the hopes it helps you or someone else.
Look for an NPM that can do this for you. You should be able to do this functionality within node.js. - https://www.npmjs.com/search?q=mysql
You can host your PHP remotely. Using node-remote you can give this server the appropriate access to your NW.js project.
You can code a RESTful PHP application that your JavaScript can pass off information to.
You can use my boilerplate code to run PHP within a NW.js project. It however fires up an express.js web server internally to accomplish this. But the server is restricted to the machine and does not accept outside connections - https://github.com/baconface/php-webkit
1 and 4 both carry a risk in your case. Your project can be reversed engineered to reveal the source code and the connection information can be retrieved rather easy. So this should only be in an application on trusted machines and 2 and 3 are the ideal solutions.
I have an Android application that is connectiont to a web server running MySQL DB. On the web server I have php files that run scripts and return JSON Objects to the client (application). I recently upgraded the versions of my web server and as of then, the SELECT statements are no longer returning anything to the client if they have parameteres, however if I run a SELECT with no parameters, it works fine. Has anyone ever encountered a similar problem?
To be more clear about my question:
Is there anyway I can debugphp scripts?
I thought maybe debugging via a web browser wouldn't work because the client is triggering the php files directly and not a direct access to the web.
All help is much appreciated!
Chrome has a set of tools that let you remote debug from your android.
Check them out: https://developers.google.com/chrome-developer-tools/docs/remote-debugging
You could wirte your own error handler an let him wirting some debug informations to a own log-file. than you can read the log file and check it for errors
Look at the MySQL error log and the php error log on your server
Check you activated the correct php_mysql* extensions in the newly upgraded PHP
Run the scripts on the server through a browser with the same parameters that your app uses, watch for errors
Upgrade the PHP code running on the server so it captures any errors and does something OBVIOUS with them.
I would recommend to use XDEBUG for debugging PHP code, or any analogue for yours web server. It is really simple to set-up and use it with any PHP IDE (like Netbeans) and it gives you a lot of abilities to explore your application condition. There is no difference in what browser you will open link with ?XDEBUG_SESSION_START=netbeans-xdebug parameter.
Also you can watch MySQL and Web-server logs.
If you cannot do anything above and you need to watch network action (AJAX requests), you can set-up ADB and use chrome developer console for debugging js (or to see php var_dump() in ajax calls) in you android chrome browser.
If you need to debug js in native android browser - try to redirect to "about:debug" page, and after this you will be able to see browsers js console (in some cases this button appears only when console has something to show - error or any othe message, in some cases it just doesn't work).
Update Watch Duplicate Copy Move
As mentioned by others, you can debug using the error logs given by mysql and php. There are also IDEs which come with debugging tools for scripting languages like php.
With an IDE like phpStorm by JetBrains, which I highly recommend using over just a normal text editor, you can configure data sources like a connection to your MySQL db. This is useful because you can run scripts in the IDE and see whether it's the retreival of the data from your db or something in your scripts or handling of the JSON object back in the client. So if you configure a data source and run those same scripts and you get the correct data back then you know there is either something wrong in the code where you send the data or something wrong in the code where you receive it.
**p.s. I know that I am 5 years (oh my days its been 5 years since 2013) late to this post but none the less you never know who may be having this same issue and they stumble accross this answer
1st - Setup Xdebug for remote debugging with your IDE(Eclipse, PHPStrom, etc), and put breakpoints in your script.(for example here's link for setting up eclipse envirompment).
2-nd - When sending your url request to server add parametres to your url(http://your/url.php&XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=XXXXX,
-1st parameter - XDEBUG_SESSION_START=ECLIPSE_DBGP starts debugging session. (as for me I am using eclipse IDE for developing, so my key will be ECLIPSE_DBGP).
-2nd parameter - KEY=XXXXXX - is a session number(type any number here).
After that you'll get your code breaks at your debugging point in your script.