Jump to content

Wheres my mistake?


EchoFool

Recommended Posts

Hey

 

 

I have a script that registers users, but i cannot work out why it will not process the information.

I echo'd the variables and its all correct yet it just will not do it =/

 

This is the script i have - was hoping some one might be able to see the mistake:

 

 

database script:

<?php

class DB extends mysqli {

    public function execute($query) {
echo $query;
        return $this->query($query);
    }



    public function qstr($str) {
        if (is_array($str)) {
            return $this->qstrArr($str);
        }

        return "'{$this->real_escape_string($str)}'";
    }

    public function qstrArr($arr) {
        foreach ($arr as $key => $value) {
            $arr[$key] = $this->qstr($value);
        }

        return $arr;
    }


?>

 

 

Register Process

 

<?php
$pass = $db->qstr($_POST['pass']);
$user = $db->qstr($_POST['user']); 
$email = $db->qstr($_POST['email']);
$db->execute("INSERT INTO users (username,pass,email) VALUES ($user,$pass,$email);");

?>

 

 

On the database script i echo the query and it displays like this:

INSERT INTO users (username,pass,email) VALUES ('test','098f6bcd4621d373cade4e832627b4f6','test@test.com');

So why could it not be working =/ i get no error displaying by the way.
Link to comment
Share on other sites

I got this - its a bit ugly to read:

 

object(DB)#2 (17) { ["affected_rows"]=> int(-1) ["client_info"]=> string(50) "mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $" ["client_version"]=> int(50008) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(1054) ["error"]=> string(37) "Unknown column 'pass' in 'field list'" ["field_count"]=> int(1) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(6) "5.5.16" ["server_version"]=> int(50516) ["sqlstate"]=> string(5) "42S22" ["protocol_version"]=> int(10) ["thread_id"]=> int(48) ["warning_count"]=> int(0) }

 

 

 

I'm connected like this:

 

<?php

$db['default']['hostname'] = "localhost";
$db['default']['username'] = "root";
$db['default']['password'] = "**********"; // removed
$db['default']['database'] = "table_name";
$db['default']['dbdriver'] = "mysqli";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.