Get Browser Information in MySQL Procedure - mysql

Is it possible to get browser information in a PROCEDURE via MySQL code?
Without having to pick up via backend code and pass as parameter. That is, does MySQL have any function that returns browser information?

No, it's not possible.
MySQL runs at server side whereas browser info is sent from client side (in request headers). So, unless it's passed to MySQL stored procedure or function (via a web app or php), there is no way MySQL would get the browser information.

Any browser information is going to come in the HTTP request and will need to be passed on by your backend code to your MySQL server. There is no function in MySQL that can give it to you directly because the MySQL server doesn't have access to that information.

Related

AS3 Variables from http query string

I am writing an air application in which some keystrokes are sent that activate functions.
Now, since this means that the application shall not be iconized (otherwise the shortcuts would not work), I want to understand if it is possible to send commands (variables) using http query strings.
I have an external device that is capable to send the requests for example: http://localhost/?var=1.
I tried opening a socket but it receives 0 length data when I send something.
Any other suggestion is of course welcome.
Thank you

define a link (GET) on trigger

How can I send my mysql table parameters to a link through GET?
e.x. : http:/example.com/Send.ashx?id=[member.id]&name=[class.name]
You cannot access MySQL via http directly. You will need to set up a rest API server that handles http requests, makes the corresponding SQL queries, formats the result (typically as json or XML) and sends it back to the client.
In case you already have an API / web server, we need more detailed information on your setup

cordova cross domain request

I want to create a cordova generic client for debug purpose. but I face the cross domain request problem. My case is:
1. I deploy my source code (html code) on a web server A.
2. My backend data source is from server B.
3. I create a cordova app and run on the device or simulator. the App access the url from server A and open the app page, that work fine. but when my js code read data from Server B, all request is failed. I guess it's cause by cross domain restriction.
Any one have solution to resolve this problem?
Thanks!
Well, since your initial HTTP request goes through and HTML is returned, it seems that the connection from the Cordova is working, at least for server A.
What you could try is to upload temporarily "content" to server A which you try to fetch with AJAX calls.
If that succeeds, you can be sure that the fault is on server B and CORS works okay from front-end. In which case you could try to access the A & B from web client etc. to see possible differences in response headers. The server B is in that case probably missing Access-Control-Allow-Origin: * header. Try to add it to your server configuration or try JSONP. Also as a long shot, read your config.xml if you have only allowed connections to server A with
<access origin="<server A>"/>
in which case you obviously need to allow server B too.
If that fails, there is much less to work with and I can only suggest you to study resources like enable-cors.org which demonstrate how to actually allow CORS.

WCF Service not returning results while stored procedure does. How can I debug?

I have implemented a WCF service (written in C#) that serves as a backend to a Webapp. The WCF is supposed to call stored procedures from a SQL database and return the data via JSON so it can be displayed in the WebApp. My issue is that the WCF service sometimes will return an empty JSON array. If I use the same parameters and execute the stored procedure using SQL Management Studio I get hundreds of rows returned. How can I debug this issue? I've been looking at Chrome's dev tools and Firebug and they both show that the request is being responded too (it's just empty).
Thanks for the help.
There's three main places you can debug:
Use the WCF test client to call the service directly rather than from front-end code.
Use SQL Server profiler to make sure your service is calling the sprocs with the parameters you expect.
Attach the debugger to your WCF service and step through the code.
Attach a debugger to the WCF service and see what happens to the result set provided by the DB.

How to update mysql fields with Javascript

I don't understand. I have searched all internet forums but found nothing helpful. I am trying to update the numberOfLikes field on my postsTable in MySql when the user clicks on the like button. I know this is done through ajax but I am only familiar with prototype ajax and none internet forums state anything about it.
Here's the flow chart
1. On "seeForums.php" user clicks on the "like" link.
2. The like link has an id that triggers the function which updates numberOfLikes on my postsTable.
Thats it. Thats all I need. But I need it in a prototype ajax format, something like this.
function processLikes()
{
new Ajax.Request(theUrl,
{
contentType:"text/HTML",
onSuccess:updateLikesMySql,
onFailure:error
onException:error,
});
}
Helps are appreciated :)
You can't do this with Javascript alone as it is client side only, you'll need to get a server side language (e.g. PHP) involved as well.
The idea is that you send an AJAX request to your PHP file along with the data that you want to update, and your PHP file will handle inserting values into the database. That PHP file would then print an output (e.g. success or failure) which would be received in your Javascript so you can act accordingly.
You should know that the nature of HTTP (web) makes it Request/Response like.
So your backend code runs on the server,
And javascript and all frontend code run on the client.
Client has no access to your database, So you can't do anything to your database with Javascript.
Best thing you can do is ask your serve with javascript to update the database,
Make a server-side script available at some URL,
Then use ajax to call that URL.
In the server-side script, do the code which updates the database.