Jump to content

My Insert Function Are Inserting Empty Values In Database


Recommended Posts

Hi everybody,

i have class with some variables and insert function, but when i call insert function in database are inserted empty values, just id (AUTO INCREMENT) has value other cells are emtpy...

My class is:

<?php 


include ('db_fns.php');


class preduzece {

         public $naziv_preduzeca;
         public $sifra_mesta;
         public $ulica;
         public $broj;
         public $opis;
         public $sifra_delatnosti;
         public $sifra_usluge;
         public $aktivno;

public function dodaj_preduzece ($preduzece)

        {

  $query = "INSERT INTO preduzece (naziv_preduzeca, sifra_mesta, ulica, broj, opis, sifra_delatnosti, aktivno) VALUES 
  ('$preduzece->naziv_preduzeca','$preduzece->sifra_mesta','$preduzece->ulica','$preduzece->broj',
'$preduzece->opis','$preduzece->sifra_delatnosti','$preduzece->aktivno')";


  $result = mysql_query($query) or die("Doslo je do greske prilikom unosa preduzeca:" .mysql_error());


         // insert

 }
}
?>

And in other page i use it (have form from witch i collect values for db):

include("scripts/preduzece_fns.php")
$firma=new preduzece() ;
$firma->ulica=$_POST['ulica'];
$firma->broj=$_POST['broj'];
$firma->ulica= mysql_real_escape_string( $firma->ulica );
$firma->broj= mysql_real_escape_string( $firma->broj );
$firma->naziv_preduzeca = $_POST["naziv_preduzeca"];
$firma->naziv_preduzeca = mysql_real_escape_string( $firma->naziv_preduzeca );
$firma->sifra_mesta = $_POST["mesto"];
$firma->opis = $_POST["opis"];
$firma->opis= mysql_real_escape_string( $firma->opis );
$firma->sifra_delatnosti = $_POST["delatnost"];
$firma->aktivno = $_POST["aktivno"];
$firma->dodaj_preduzece();

when i echo $firma->naziv_preduzeca or anything else values are collected from form, only when i call function dodaj_preduzece something goes wrong...

Does anybody know why this is happening?

Ps sorry for grammar errors if i have it (I am from Serbia :) )

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.