Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made my first script of MySQLi. I have just learnt it from 3rd party website. So, I am not sure i am using functions which are not deprecated or outdated. I should start to practice good scripts to access databases. So, I have posted here. Any mistake you see, please point it out.


include "functions.php";

$a = checkLogin();

if($a==1) {
    $id = $_COOKIE['id'];

    include "databaseConnector.php";

    $query = $mysqli->query("SELECT * FROM users WHERE id = '$id'") or die($mysqli->error.__LINE__);

    if($query->num_rows > 0) {
        while($row = $query->fetch_assoc()) {
            <?php echo stripslashes($row['firstname'])." ".stripslashes($row['lastname']); ?>   
    else {
        return false;   
else {

share|improve this question
("SELECT * FROM users WHERE id = '$id'") - read about SQL injection! – Peter Kiss Mar 7 '13 at 19:57

mysqli is somewhat outdated, you should see PDO that is much better both with security and database support (12 drivers vs. 1).

You can see here details of mysqli vs. PDO:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.