Page 2 - Discuss Post Json Object in the PHP Development forum on Dev Shed. Post Json Object PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
PHP 4.3 was officially given an "end of life" by the PHP team on 31 March 2005 - near enough 8 years ago. the entire 4.x branch died in August 2008 and since then 3 versions of PHP 5 have reached their end of life
Time spent in forums: 2 Months 4 Weeks 7 h 23 m 29 sec
Reputation Power: 1092
Compared to what we usually see around here, I don't find the code too bad. Sure, some parts are hopelessly outdated. But at least he/she tried to make the code secure and actually wrote down some descriptive comments. Great! Finally someone who seems to actually care about good code and doesn't stop at "It compiles" (aka "It works" when using an interpreter).
But, yeah, outdated code and knowledge seems to be the biggest problem of PHP. People learn the basics from some 15-year-old online tutorial, and that's it. "It works", so why learn something new?
No matter how many deprecation warnings the PHP developers put into the manual, no matter how many tutorials about MySQLi/PDO get written, people still use
mysql_query('SELECT * FROM users WHERE user_id = $_GET[id]') or die(mysql_error());
Because that's what w3schools has taught them.
And I doubt this will change in the near future. The PHP learners tend to be lazy and ignorant, the PHP devs are afraid to break legacy code, and the PHP hosters don't update their stuff. It's just sad. We have a small elite programming and using the latest fancy features, and we have masses of (amateur) programmers who are stuck in time and still write their HTML and PHP like it was 1995.
this function takes a json string and turns it into an object
If you want it as an array, send true as the optional second argument (the link to the docs gives more info).
Then test with print_r or var_dump
I corrected the double quote.
I am using a JSON_Decode with a true value?
Ive been able to echo the $password, username, secret_key and I get accurate info. However that info is not being carried over into my script?
Time spent in forums: 4 Weeks 8 h 38 m 51 sec
Reputation Power: 4123
now all you need to do is prevent SQL injection.
Just because the data is coming from json, does not mean it is safe, the username field in the json string could still contain characters that are unsafe for MySQL
Also, please consider alternatives to the mysql_* library functions. My sig contains a link to a migration guide (might have to scroll up to my first reply to see it) and shows how to easily protect against SQL injection