I should have an interview for coding PHP soon, hopefully.
Moderator: General Moderators
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
I should have an interview for coding PHP soon, hopefully.
I work at a company doing technical support for xDSL, leased lines, email servers etc at the moment, which I hate. It's only the past month I've been learning PHP but I really love it. I asked the programming manager today what I'm expected to know to be considered for an interview and he asked me what I know, which is structure, loops, if statements, MySQL queries and he said he would try and set me up an interview. All I've gotta do in the interview is code a page that inserts data into a MySQL DB and I get 45 minutes to do that. Seems easy enough 
that's the only requirement?? Insert it in the database? that's not very hard... 2 lines...
I just got the job... and in less than one minute.
EDIT: I just realized I forgot to select the database... so maybe i didn't get the job haha I can't believe none of you caught that!! SHAME ON YOU GUYS!
Code: Select all
<?php
mysql_connect($host, $user, $pass);
mysql_select_db($db);
mysql_query("INSERT INTO table VALUES('crap')");
?>EDIT: I just realized I forgot to select the database... so maybe i didn't get the job haha I can't believe none of you caught that!! SHAME ON YOU GUYS!
Last edited by Luke on Thu Sep 21, 2006 2:26 pm, edited 2 times in total.
Re: I should have an interview for coding PHP soon, hopefull
Ask if they use a database abstraction library first. If not:impulse() wrote:All I've gotta do in the interview is code a page that inserts data into a MySQL DB and I get 45 minutes to do that.
- Connect to the database (handle errors if the database connection cannot be established)
- Select a database (handle errors if the database isn't found)
- Gather incoming data (use $_GET or $_POST)
- Validate that required data is available (use isset(), empty(), is_numeric(), strlen(), regexp for email validation, etc)
- Escape necessary string values (using mysql_real_escape_string(), might want to check get_magic_quotes_gpc() )
- Build an insert SQL string (include field names, might be nice to use imploded arrays or associative arrays)
- Run the query (handle insert errors)
- Get the insert id (call mysql_insert_id() )
- Close the connection nicely (mysql_close() )
- Don't forget to comment your code
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
you forgot to select the database....SMURFSLAP to ya...just for that ill call you the ultimate insult...POO POO HEAD!The Ninja Space Goat wrote:Code: Select all
<?php mysql_connect($host, $user, $pass); mysql_select_db($db); mysql_query("INSERT INTO table VALUES('crap')"); ?>
i cheated
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
Going back on topic - I've been told I wont be inserting into a DB anymore and it'll be a "surprise". What else could I be asked to do, baring in mind this is going to be basic stuff. I just don't want to screw this up so I want to have the resolution to every potential task. I can insert, update, delete, & sort a MySQL DB at the moment. What else might I be asked to do. What other basic functions are there in MySQL DBs?
Regards,
Regards,
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact: