Forum Moderators: coopster
My concern is how robust is the code generated is. Any one has experince with this? I am using sessions to handle login authentication. I also checked my php parser settings and Global Variables are off.
The code generated is not using any globals cause its working fine.
Like I say, I have very very little experience with it though, so hopefully someone will chime in. If not, you might try over at the Editors forum.
Tom
$query_getMemInfo = sprintf("SELECT * FROM mem_info WHERE id = %s", $colname_getMemInfo);
what does the %s represent here? any ideas.
sprintf [php.net]
minck is a distant admirer of terse
The italics were to emphasize the nomenclature and the simple link was a point of reference. Sorry if it seemed short, I was rushing to get out of the office and didn't want to leave juliebelle without an answer.
I'll terse you, mister ergophobe .... ;-)
I need books that teach good procedured to cater for code reusability. I think that is very important, especially with PHP 5 being fully object oriented. Any suggestions?...
Thanks very much
Julie
try this thread for some ideas
Learning PHP - Books, Tutorials and Online Resources [webmasterworld.com]
You can get all kinds of scripts off the net for all purposes, but many of them are not good to learn from, so be a little careful of what you take as your model. I suppose that's obvious. If you're just new to PHP rather than new to programming in general, then I think modifying existing scripts is a good way to learn syntax. Learning style is another matter. I don't know of any really good PHP-oriented resources for that.
As for being terse...
Coop, that wasn't meant as a bad thing! According to Meriam-Webster's:
terse (adj)
1 : smoothly elegant : polished
2 : devoid of superfluity.
synonyms: see concise
Hardly a reproach!
Tom
Code re-usability is important indeed; just remember this fact, keep it in you mind as one of the issues of coding, but don't let the gurus scare you about what the golden ideal of coding is; most of this comes from noxious reactions to really, really badly written code (one thing I really like about this forum: no gurus who take pleasure in verbal spankings). If you start out realizing that code re-usability is an essential value in coding, as you already do, you won't write utt-bugly code, and will have time later to get down to dotting your i's and crossing your t's when it comes to re-usability and elegance. First you just have to have a good understanding of how stuff fits together. So first get a good grasp of coding - for style, I'd say learn from the beginning to avoid quoting strings in double quotes and start out with single quotes and concatenators
('.' - $color = 'yellow'; $destination = 'home'; $sentence = 'the '.$color.'flew '.$destinaton'; instead of $sentence = "the $color bird flew $destination";). Before you try to understand OO, classes, methods, etc., make sure you have got a good understanding of multiple-dimension arrays.
I've often wondered what scripts would be the best for newbies to get a grasp of what PHP is actually doing, and unfortunately couldn't really name any - most seasoned PHP coders will be working on their own scripts, and these are often long and gnarly, even if written well. I would indeed like to hear from others if they know of good scripts for recommending to beginners.
Code that Dreamweaver produces is probably not a good style example, either in HTML or in PHP; the example you gave, for example, isn't very good - '*' is an inefficient way of querying a database (although very easy - use it when you begin learning, but replace later), and using sprintf in that way may have some value in security for auto-generated scripts, but isn't good for code you write by hand - too confusing, also a bit less efficient - would be better done otherwise.
cheers :)
Julie
BTW. I was wondering about sessions. I read that session_start()must be declared on each file that must be 'protected' using sessions. is that true or will it start a new session each time session_start() is called.
I need a way to create a robust user authentication system where not more that one user can log-in with one account. any tips. I thought about creating another session variable and use it as a flag to check the status of the user. when the user logs in, the flag is set to true, when he logs out back to false. while the flag is set to true, no one else can log-in. I think i would need to write the flag in the user database however....
just an idea. Any opinions?
session_start()before your session variables are available. This is a misleading-sounding function because it only 'starts' a new session when it can't find a valid session to continue. If there's a session that's still fresh that it can find, it will use that one.
Yes, you'll have to have a db entry in addition to sessions to allow usernames to be logged in only once at any time - sessions don't know anything about other existing sessions.
I wish you lots of success with your project. If you have further questions along these lines (sessions), I'd suggest you start a fresh thread - it's good to start new threads with new questions.
BTW. ergo. Thanks for the information. ....so i was on the right track :-)
julie