1

am using google cloud sql instance for my application db, when i try to insert records into it doesn't generate any error but the records are not inserted but when i use my local database everything works fine what could be the reason for this..

My project is a codeigniter application. meanwhile if i try to read from cloud instance(select ) it works. there is no problem with code because it works fine with my localhost.

$data['username']  = $this->input->post('username');
$data['email']  = $this->input->post('email');
$data['metamask_address'] = $this->input->post('metamask_address');
$data['address1'] = $this->input->post('address1');
$data['address2'] = $this->input->post('address2');
$data['phone'] = $this->input->post('phone');
$data['surname'] = $this->input->post('surname');
$data['zip']  = $this->input->post('zip');
$data['city'] = $this->input->post('city');
$data['state'] = $this->input->post('state');
$data['country'] = $this->input->post('country');
$data['langlat']       = '';
$data['wishlist']      = '[]';
$data['creation_date'] = time();

if ($this->input->post('password1') == $this->input->post('password2')) 
{
    $password  = $this->input->post('password1');
    $data['password'] = sha1($password);
    $this->db->insert('user', $data);
    $msg = 'done';
    if($this->email_model->account_opening('user', $data['email'], $password) == false)
    {
        $msg = 'done_but_not_sent';
    }
    else
    {
        $msg = 'done_and_sent';
    }
}
echo $msg;
Pradeep
  • 9,667
  • 13
  • 27
  • 34
Alcantara
  • 120
  • 7
  • 1
    **WARNING**: Do not create your own login system, especially one using a high-speed hashing function like SHA1. [Codeigniter has many to choose from](https://stackoverflow.com/questions/33311725/codeigniter-3-x-authentication-library). – tadman May 01 '18 at 23:51
  • 1
    This code is in controler ? `$this->db->insert('user', $data);` did you load database? – Ryuk Lee May 02 '18 at 03:41
  • 1
    Make sure your `$data` keys are the same as your db table column names. – Karlo Kokkak May 02 '18 at 03:54
  • Make sure the value of $data['creation_date'] is valid for its datatype in database. – Karlo Kokkak May 02 '18 at 03:56
  • So reading works but insert/update/delete doesn't? Do you have error reporting enabled? Please note that you may have to modify the `index.php` switch statement in `production` to reflect `development` to enable error reporting on remote env. – Alex May 02 '18 at 04:46
  • i see errors, from my other codes if there is but inserting to db doesnt work(cloud instance). when i insert locally it works but on cloud instance it doesnt – Alcantara May 02 '18 at 06:06
  • Did you set up correctly [your app.yaml](https://cloud.google.com/appengine/docs/standard/php/cloud-sql/using-cloud-sql-mysql#setting-up) to connect to the Cloud SQL instance? – Mangu May 17 '18 at 09:09

0 Answers0