Connection With MySQL With Android [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am using this tutorial for connecting mysql database with android apps
androidhive.info/2013/12/…
There are 4 files for PHP . They are Config.php , DbConnect.php , get_categories.php , new_category.php . After putting this http://localhost/food_api/get_categories.php to my browser , I get the following result .
{"categories":[{"id":"1","name":"Beverages"},{"id":"2","name":"Bread"},{"id":"3","name":"Cereals"},{"id":"4","name":"Cheese"},{"id":"5","name":"Citrus Fruits"}]}
But in my android application , there is no data coming from server . Where is the problem ? My assumption is that therre may be some mistake in url which is as following :
**// API urls
// Url to create new category
private String URL_NEW_CATEGORY = "http://10.0.2.2/food_api/new_category.php";
// Url to get all categories
private String URL_CATEGORIES = "http://10.0.2.2/food_api/get_categories.php";**
My error is as following :
I am passing almost 2 days to solve this probelm , but could not get any solution . Please help me to solve this problem .

the link- "10.0.2.2 " for localhost will work only for emulator.
If you try to work with real device this link will not work. In that case you have to host the php and database in a global server or you have to make a lan/wlan with the mobile device and then the pc localhost url wil be the ip address of that PC

Related

Image Source to Include a PHP Input [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to create an image that changes dependent on the genre grabbed from an icecast server, I am pretty sure I have the base code correct I think I've just incorrectly inputted the PHP variable.
<?php
$stats = $core->radioInfo( "http://http://sc.onlyhabbo.net:8124/status-json.xsl" );
?>
<img src=http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif/>
is the full code. Have I inputted the PHP variable incorrectly
Where are the quotes in your Html?
<img src="http://www.habbo.com/habbo-imaging/avatarimage?user=<?php
echo $stats['genre'];
?>&action=std&direction=2&head_direction=2&gesture=sml&size=m&img_format=gif"/>
UPDATE EVERYBODY
This is now resolved, I decided to go down the CURL route for this, and at first it didn't work until my host raised our CloudLinux Process Limit. I am unsure what the actual issue with this code was, but the CURL route works fine. Thank you for any answers

Any way (Best way) to alter user's IP address before passing query onto remote server [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
We have a script running on a managed server (LAMP) that uses php/curl to post a user's query to a remote server and then display the results that are returned. What we would like to do is anonymize the users by passing our server IP to the remote server instead of the user IP. How can we implement this? Any suggestions will be appreciated and tried with no hard feelings or snide comments if it doesn't work. We're out of ideas. Thank you.
tor
curl bot.whatismyipaddress.com => 91.240.86.250
use sock:
curl bot.whatismyipaddress.com --socks5 127.0.0.1:9050 => 178.17.174.99
use php
curl_setopt($ch, CURLOPT_PROXY, 127.0.0.1 . ":" . 9050);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);

Symfony2 The CSRF token is invalid [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I have a problem with Symfony. When I submit the FOSUserBundle register form on the built-in Symfony server (on the port :8000), it shows the error below:
"The CSRF token is invalid. Please try to resubmit the form."
But, when I submit form on Apache server (by /web/app_dev.php/), all works fine.
Hidden token input exists in form.
Your session could be invalid, after it timed out or due some changes in your code.
You need to clear the server and browser cache, then it should work again.

Login Functionality not working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
So I took the login script demonstrated in this tutorial: http://www.9lessons.info/2014/07/ajax-php-login-page.html
However, when I try to run it, I keep getting an incorrect login information error. The database, the table, all of that is correct. I'll look at it again, but I'm sure that's fine.
I haven't changed anything besides the name of the table, and my db info.
Why does the PHP dissapear? Solved
the php at the top of index.php goes away when I look at the source code on a browser
This is a good thing :)
PHP code is processed server-side. The result of that code (which is usually HTML) is then sent to the browser. PHP code itself should never be sent to the browser for a couple of reasons:
It would expose your server-side code to users, which could help them do malicious things.
The browser wouldn't know what to do with it.

JSON and php . . . NOT FOUND [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
still a beginner on php i'm trying to get data from my sql table into an iphone app, i decided to use JSON to do so.
To get my data i use :
mysql_connect($config['mysql_host'],$config['mysql_user'],$config['mysql_pass']);
//select database
#mysql_select_db($config['db_name']) or die( "Unable to select database");
mysql_query('SET CHARACTER SET utf8');
$fet=mysql_query('select * from actualites');
$json = array();
while($r=mysql_fetch_array($fet)){
$json[] = $r;
}
echo $json_data=json_encode($json);
When i print the result into my browser, the json appears but i have a big NOT FOUNT with the following :
Not Found
The requested URL /"http:////www.youtube.com//embed//uspc5ZS-YLI/" was not found on this server.
And so the JSON file is imcomplete ! I have searched the web but found nothing !
What do i do wrong ?
Thank you very much !
EDIT : I have a well formed JSON until i get the Not found.
THe value in the db is :
the result from db looks badly "add_slashes()"-ed somewhere in php code. can you see if that field in db is properly filled? provide sqlfiddle?
EDIT: the code you provided looks normal and should work without problems
Define Content-type for JSON file loaded with PHP.
For JSON:
header('Content-Type: application/json');
For JSON-P:
header('Content-Type: application/javascript');

Categories