?
Solved

Getting the error of undefined variable while submitting data to database

Posted on 2014-11-14
7
Medium Priority
?
129 Views
Last Modified: 2014-11-15
When i submit the registration form's data it is showing the following error....but the data is inserted in the database while viewing i am getting this error


A PHP Error was encountered

Severity: Notice

Message: Undefined variable: dbRet

Filename: models/registration_model.php

Line Number: 47

Model code

      public function save_registration($un,$email,$pwd,$utype)
    {
      try
      {
      $data = array(
   'username' => $un,
   'password' => $pwd,
   'email' => $email
   
    );
    //print_r($data);
    //die();
    $this->load->database();
    $this->db->reconnect();
    if($utype=='buss')
    {
        $dbRet=$this->db->insert('business', $data);    
    }
    else
    {
        $dbRet-$this->db->insert('user', $data);
    }      
      if (!$dbRet) {
      $ret['ErrorMessage'] = $this->db->_error_message();
      $ret['ErrorNumber'] = $this->db->_error_number();
      log_message('error', "DB Error: (".$ret['ErrorNumber'].") ".$ret['ErrorMessage']);
        $this->db->close();
      return $ret['ErrorNumber'];
        }
        else{
         $rid=$this->db->insert_id();
      $this->db->close();
      return $rid;
        }
      }


As i am new to this please give me the solution
0
Comment
Question by:geetika joshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 2000 total points
ID: 40444144
This line may be wrong?
$dbRet-$this->db->insert('user', $data);

Open in new window


It should be,

$dbRet = $this->db->insert('user', $data);

Open in new window

0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40444160
Agreed  ^^^  That will cause the error in the line that follows:

 if (!$dbRet) {
0
 

Author Comment

by:geetika joshi
ID: 40444170
what could be the solution?? as i am new to this please guide me
0
WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40444174
Replace that line with the one @Loganathan Natarajan showed you above.
0
 

Author Comment

by:geetika joshi
ID: 40444176
okk.....got it done problem solved thank you  both of you

Now i am getting this error

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/clubhouzz/public_html/application/controllers/registration.php:17)

Filename: libraries/Session.php

Line Number: 688
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 40444187
You may be printing some where on this file registration.php:17
just comment it. So there won't be any session prob
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40444194
'session_start' must come before any HTML or text output because it sets a cookie which is part of the 'response headers' that are sent before a web page.  Sounds like you may things in the wrong order.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question