Count = 0 ? Should be 1

Well, i cant see why it would be adding anything to your string, because i cant see where you define all those input variables

but i’d do this:

function quote_smart($value)  
{  
//INSERT THIS
$value = trim($value);

that’ll get rid of extraneous spaces / tabs / newlines on the ends of the string/number.

This code is unreadable crap.

Why are you naming queries things like $query1 and $query2? And why do you use seemingly random strings to check statuses of things? It’s ridiculous. Do you even know what a boolean is?

This kind of code is why I hate working on projects made by other people. If I started working for a company with code like this, I’d probably resign before dinnertime on the first day.

You shouldn’t be using the mysql_ functions btw. At all. Why are you using them? Argh… this code is so crap.

I couldn’t edit my above post, so some more comments from me:

Why are you writing queries like this: SELECT * FROM ValidISP WHERE ISP = ‘$ipisp’";

Shouldn’t you be assigning an ID to the ISP data, so you can search for an ISP by ID rather than a string? Searching for companies like this in your general queries is poor - you should be using a unique id, not a string.

I hope this code isn’t for anything important, as on a larger scale it’ll very quickly turn into an unmaintable mess.

I’d suggest reading a book like this: http://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

Seriously.

Thanks StarLion for all the help you have given me :slight_smile:

@aaarrrggh Not being funny but you criticise me for my ‘crap’ coding, yes im still learning PHP and yes once i get better and learn from my mistakes then ill get better. No point in coming here and telling people how bad they are, people come on these forums to get help and be taught the right way of doing things. If your sick of people doing things the wrong way when people are learning then maybe this forum is not for you. Also reading the whole topic before replying first would of helped save both your and mine time reading your ‘crap’ responses, as if you had read them you would of seen my issues have been resolved.

Someone (@HAWK) ban this ‘crap’ user.

Hearing you. Tone it down please @aaarrrggh; - this is a forum for people of ANY level and they have the right to non-judgemental support.

My problem though is that we constantly see really poor code being posted here, and instead of giving them real advice about how to get better, people just take on board the problem with the crap code and solve it, instead of giving real advice about how to improve things.

I stand by everything I said. I’d rather be banned than not be able to speak properly.

I’ve also given you some constructive criticism in the previous email, and it was criticism you should pay attention to, because it will make your code better. I also linked you to a book that would help you out massively.

Your code IS crap, but that doesn’t mean you can’t improve it.

I didn’t realise you were such a beginner, and for that reason maybe my tone was a bit harsh - the stuff I said was still correct though.

It’s more an issue I have in general with places like this. There are people giving advice here that don’t really give advice that will help you improve the quality of your code over time. Just fixing the issue someone is having a problem with isn’t necessarily going to give you the help you need.

As an example: a few months ago, someone posted on this forum regarding a mysql query that wasn’t working. Everyone in the thread just posted help regarding the query itself - totally ignoring how terrible his code was, and how it was also open to something called a “sql injection” attack. I posted a response explaining the nature of the threat, and telling him to focus on that FIRST, before addressing the issue he had with his query. I even sent him a private message showing him the exact string I could append to his URL to delete his user table database (and it would have worked, too) - the response from people in this forum? Stuff like: “That’s not the question he was asking, please stop posting”

Your code is poorly written, however if you’re just learning that’s fair enough. You should still pay attention to people like me though, because I know for a fact that code written in the way you’ve written it currently will be difficult if not impossible to work with over time.

I apologise for the tone, simply because I thought you were more experienced than you obviously are. Everyone has to learn somewhere and I appreciate that.

Do yourself a favour and buy this book: http://www.amazon.co.uk/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

I’m not suggesting for a moment that shouldn’t be honest… just polite. Insulting someone is not the way to get your point across. Thanks for your apology to the OP.