Solved

Getting the error of undefined variable while submitting data to database

Posted on 2014-11-14
7
125 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 36

Accepted Solution

by:
Loganathan Natarajan earned 500 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 83

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 83

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 83

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OWA - local directory not showing 5 34
file too large for website 6 70
Tech Writing - 'Hover Over ' or 'Mouse Over' 4 78
WEB Farm 6 70
      Install BugTracker on Windows 2008 server Step 1:  Install windows 2008 server 32 bit OS and configure IIS. Step 2:  Install SQL server ( SQL server 2005 or SQL server 2005 Express edition. The installer for 2008  version isn’t very f…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
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.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

810 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