On Tue, 14 Sep 2004 18:32:50 +0800, Jason Wong <[EMAIL PROTECTED]> wrote: > On Tuesday 14 September 2004 18:06, Logan Moore wrote: > > Ok I think I figured out my own problem. The speechmarks in the Form break > > up the speech marks in the echo statement so I originally changed the echo > > statements speechmark to a ' which worked but was informed that this was > > considered bad syntax and that maybe I should add a \ in front of all > > speechmarks which are not part of the echo statement. > > It's up to you. IMO, using single quote strings and breaking out when handling > variables is more readable than using double quote strings and escaping the > double quote (\"). > > > I could still do with an example of how to put the information from the > > form into the db though. As I have never done this before. > > Plenty of tutorials out there. >
First of all, you're making some pretty harsh coding style errors. For the sake of compatibility, always make sure you're quoting non-numerical elements in an array, thus: write $_GET['action'] instead of $_GET[action]. Imagine, for example, what would happen if you've got some field named "public" and you're upgrading to php5? Or when, in php 5.4 (just saying smth), "action" suddenly becomes a keyword. You're stuck then with dead code. Good practice is also to check whether your expected array entry is actually set. I usually do smth like: isset($_GET['action']) or $_GET['action'] = 'thedefaultvalue'; or if (!isset($_GET['action'])) { $_GET['action'] = 'thedefalutvalue']; }; (both do the same, first one is just a lot shorter). As adviced before, whenever you have to check if a certain variable has a certain value, and if one of them is true, none of the others will be true (which is the case with $_GET['action'] checks, usually) - use the if ( /* conditions */ ) { } elseif ( /* other conditions */ ) { } method, rather than all seperate if's. I once changed this in somebody else's code and found the script running about 5 (!!) times faster, with about 15 conditions. For inserting into the databas, mysql_connect() and mysql_execute() are very good options. Or, if you're able to use the PEAR::DB package I'd advice you to use that. It's more fun to do it that way, and will help a lot if ever you'd want to change your database server from mysql to something else (postgres, for example). Ow, and it also helps a lot with any quoting problem you'd come up with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php