JSON and php . . . NOT FOUND [closed] - php

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');

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

Error message on my New Blog Post page which I cannot work out [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 8 years ago.
Improve this question
I am in the process of incorporating a Blog Posts section in my website.
However I am receiving an error message on the New Post page which I am unsure of the cause of.
Any help would be greatly appreciated.
I have received the above two Warning Error messages above.
I have also covered parts of the directory because they show names.
This is what the code looks like at the line specified.
<?php
include "cms/posts.php";
?>
Line 155 is the middle line of code.
If there is any more information which is required please let me know.
Thanks!
Reply to comment 1: Hi, I'm not sure why it is trying to open that file as I've never seen or heard of the file "usr/lib/php:/usr/local/lib/php".
Use this code and make sure the file exists:
<?php
include __DIR__ . "/cms/posts.php"; // PHP >= 5.3
include dirname(__FILE__) . "/cms/posts.php"; // PHP < 5.3
?>

Connection With MySQL With Android [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
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

How to echo url and database variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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 piece of code used to search a database for videos based on keywords. It then pulls the url from column $url. I then want to echo out a hyperlink to the video by echoing the website link and concatenating on the url variable pulled from the database.
So far I've come up with the following code. I'm new to php so im not sure how to concatenate variables in an echo.
echo "Link";
Also when I run this code the link brings me to http://danu6.it.nuigalway.ie/sm4business/danu6.it.nuigalway.ie/sm4business
Any help or resource that could help me to fix this would be appreciated.
You need to use dot to concate constant string with variables:
echo ''.$name.'';
for security reason you need to take care about propper variable escaping. Check php.net doc for htmlspecialchars and htmlentities
you can try something like this:
echo "Link";
or you can concat the $url value in the string like this:
echo "Link";
Hope it helps!

Mysql_num_rows not Valid - PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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.
Closed 9 years ago.
Improve this question
I use the method or function mysql_num_rows() in my php code, it worked great and had no issues. I later just changed my web host. I created a new database that is identical to my old one. I changed all the information to access the database and am getting access to the new database but it is throwing an error once the code reaches mysql_num_rows. Why am I getting an error for mysql_num_rows? The results are suppose to be 0 when the function is ran because I have no information in my new database, but I also added information just so I didn't get a 0 and it is still giving my an error. Why?!!!!
Sounds like you've moved to a server with a newer version of PHP - mysql functions are deprecated, use mysqli (and convert the rest of your database functions to mysqli):
http://au1.php.net/manual/en/mysqli-result.num-rows.php

Categories