Skip to content
Advertisement

Swift not passing variables to PHP Web Service to query my SQL database

I have a PHP Web Service that can insert a new row to my database if I hardcode the values in to the SQL query directly. But when I try to do this using variables passed to the PHP script from my Swift function it breaks down. I have add print statements to my Swift so I am confident that the values are being passed to the function correctly and the error must lie in the lines afterwards.

PHP: I have commented the SQL query line out with the hardcoded values – Carrots, but this query does work so I think PHP->SQL is working ok, but Swift->PHP is the problem.

Swift:

Error:

Many thanks.

Advertisement

Answer

I got this working after taking on board the suggestions. Thank you all. I changed the parsing to JSON in swift and improved the binding of variables in the PHP file.

PHP:

Swift:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement