February 24th, 2013, 09:46 AM
@engrmudasir: If he did that, it would execute his submission of the item being added, which he DOES NOT want, to avoid duplicates. If there is one in there, another is not to be submitted.
February 24th, 2013, 11:23 AM
Originally Posted by Triple_Nothing
Just do this if(Count>0) then do this else Do this. But i thin the scenario of using ==0 will not work fine.
February 24th, 2013, 12:29 PM
Originally Posted by s-p-n
is there a more secure way of writing it?
February 24th, 2013, 01:19 PM
First of all, get rid of the ancient MySQL extension (if possible). It's obsolete since almost 10 years, and it's officially deprecated in PHP 5.5, meaning you'll get an E_DEPRECATED error for every mysql_connect, mysql_query etc.
Originally Posted by eropsy
The only reason that extension is still alive is because the Internet is still full of 15-year-old PHP tutorials, and people still learn from them.
So if possible, jump into the 21. century and choose one of the two "new" database extensions. Each of them supports prepared statements, which allow you to safely pass values to queries. Check the link in my URL for a concrete example:
February 24th, 2013, 01:31 PM
Actually, it does work, engrmudasir.
Originally Posted by engrmudasir
But I'm going to go down the path Jaques1 advised about moving into the 21st century and get to learning this "prepared statements" stuff, the latest PHP, and the new data base extensions.
Which means everything I've taught myself in the past 6 months online may end up being only slimly useful if I want to write secure codes.
Since I'm still a newbie, I might as well learn the most up to date stuff.
February 24th, 2013, 06:57 PM
Excellent goal. There won't be much of a loss, though. Not TOO much has changed with PHP overall... Tis mostly just the MySQL interactions. Won't be hard.