last day (14 days later) » 

1:07 PM
0
Q: Where to save this ios web server application

user3720631I am following a tutorial: http://www.raywenderlich.com/13541/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-22. It's an iOS app with a PHP/MySQL backend. When I compile the app (no official errors) I go to the register page from my iPad to test the functionality. I enter my...

 
Are you running the PHP on your local machine? If not, that's where you need to start. Your could not connect to the server sounds like your iOS code cannot get a route to the API, so you may need to debug that first. There will be a configuration that lets you set the IP/domain of the API, and you'll probably need to set it to the IP address of your development machine. It might look something like http://192.168.1.5/path/to/api.php. There may also be a dev machine firewall in the way, so you could try hitting this from your iPad web browser first.
 
Yes I am running it directly on my machine thanks for your answer. Using the ip is a good idea, I was going to try that, I think I'll give it a try but I'm still in the dark about the proper hierarchy all together.
 
In security terms, there is some effort made with mysqli_real_escape_string but it needs paramterisation, and passwords should never be stored in plain text. Follow the material by all means, but be aware the PHP side of things is not safe to publish as is.
 
It'd be great if I got some feedback on The sub directory / htdoc conundrum. Do ios apps get sub directories the same way a .php web page would?
 
Bear in mind also that this question is rather broad. You've made a good effort, and I think it is in a grey area for this site, so I will refrain from voting to close it. However be aware that it might go that way - but you have a few clues in the comments already to be looking into.
Re the "htdocs conundrum", see what URL your app is trying to connect to. For the example URL I gave earlier, you would need to create folders. So if /htdocs is at the root of your machine, the folder structure you create would be /htdocs/path/to/ and then you'd save api.php in there. Think of the htdocs folder as mapping to the root of the website, e.g. http://192.168.1.5/.
 
1:07 PM
Thanks for the help. To future readers: a good visual aid would be welcomed
 
To help other readers (who may help you back) please edit into the question the API URL used by the app. Also, let us know if you can reach the API from your iPad Safari app, via your local LAN.
 
Would I need to save the api.php files directly in htdocs or must they have sub folders to (I think it was recommended but it seems Itd be easier to just put them directly in htdocs)? I will try to swap out local host with my IP address also...
as far as the url , It was just set to local host, if I am understanding you correctly 'localhost'
 
That'll be the problem! "Localhost" means "self", so on your iPad, it means "connect to the iPad" (but your API presumably is on your development computer). You need an IP address in your iOS app so it connects across your LAN. My guess is it is urlString in your Objective C code, what value is this set to?
 
Yes, The app uses an api.m file to declare '#define kApiHost @"localhost" and directly under it '#define kApiPath @'iReporter/" (the folder to save the pics I think) Ok I'll try 127.0.0.1 . Recompiling in progress...
 
No, 127.0.0.1 is the IP of localhost, and has the same problem. You need an IP for your API machine on your LAN.
 
1:07 PM
Ok do you know what I should set that to?
 
Err no, you'll need to discover that yourself (it is not possible for me to know). It is usually assigned by your home router via DHCP, and I don't know what kind of dev machine you are running. If it's a Mac, ifconfig at the console will tell you the IP of all the connected network interfaces.
 
Ah ok, I'll check it out
You mean the IP address that's tapped to my router correct? I'll give it a try
 
If the PHP API is running on your router, sure! But it probably isn't - the API runs on your development machine. I suspect you'll need to brush up on HTTP and networking - this is going to be pretty hard if you don't know the basics. (Hopefully the above has been of help, but I'll need to bow out - this is why I thought the topic might be overly broad).
 
Ok thanks. Last thing, there was no IP address on the router...my bad. Can you give me the specific key term of the type of IP address I should try and where I can find it quickly? I think it's woth a shot. Ty for the help
Actually I just saw your post about ifconfig. I'll give that a shot. Update in progress
it turns out my ip address on my machine is 169.281.84.33. i kApiHost to this but still no go
 
Alright, debugging time! Make sure you can ping your API machine from another machine in your network. If you can, but you can't reach your API from your iPad browser, see if your API machine has a firewall. Lots to try, lots to learn :).
 

last day (14 days later) »