Jump to content

PHP -> MySQL update not working


Go to solution Solved by budimir,

Recommended Posts

Guys,

 

I'm trying to update a row in db, but nothing happens..

 

This is my query.

$upitak = "UPDATE kalkulacija_stavke SET vrijeme = '$vrijeme', kataloski_broj = '$kataloski_broj', kategorija_artikla = '$kategorija_artikla',
grupa_proizvoda = '$grupa_proizvoda', podgrupa_proizvoda = '$podgrupa_proizvoda', cijena_EUR = $text, cijena_KN = $hq_cijena_kn, carina = $carina_razlika, spediter = $spediter_razlika, 
banka = $banka_razlika, transport = $transport_razlika, nabavna_cijena = $nabavna_cijena_nova, drezga_marza_po_grupi = $drezga_marza_nova, drezga_zarada = $drezga_zarada_nova, neto_VPC = $vpc_drezga_nova,
neto_MPC = $mpc_drezga_nova, trosak_firme = $trosak_firme_nova, trosak_firme_p = $trosak_firme_p_nova, diler_marza_po_grupi = $diler_marza_nova, preporucena_VPC = $preporucena_vpc_nova1,
preporucena_MPC = $preporucena_mpc_nova, zarada_diler_kn = $zarada_diler_kn_nova, zarada_diler_post = $zarada_diler_p_nova, zarada_za_nas_kn = $zarada_drezga_kn_netto_nova, zarada_za_nas_post = $zarada_drezga_p_netto_nova,
brutto_zarada_za_nas_kn = $zarada_drezga_kn_brutto_nova, brutto_zarada_za_nas_post = $zarada_drezga_p_brutto_nova WHERE id = $id_redka AND id_kalkulacija = $id_kalkulacije ";		
echo "$upitak";
$rezultat = mysql_query($upitak,$veza) or die (mysql_error());

When I echo the query, this is the result:

UPDATE kalkulacija_stavke SET vrijeme = '2013-04-19 11:25:31', kataloski_broj = '967 18 85-01', kategorija_artikla = '', grupa_proizvoda = '', podgrupa_proizvoda = '', cijena_EUR = 1250, cijena_KN = 9625, carina = 481.25, spediter = 48.13, banka = 14.44, transport = 0, nabavna_cijena = 10168.82, drezga_marza_po_grupi = 52, drezga_zarada = 5287.7864, neto_VPC = 15456.6064, neto_MPC = 19320.758, trosak_firme = 2936.76, trosak_firme_p = 19, diler_marza_po_grupi = 40, preporucena_VPC = 21639.25, preporucena_MPC = 27049.06, zarada_diler_kn = 6182.64, zarada_diler_post = 40, zarada_za_nas_kn = 2351.03, zarada_za_nas_post = 15.21, brutto_zarada_za_nas_kn = 5287.79, brutto_zarada_za_nas_post = 34.21 WHERE id = 161241 AND id_kalkulacija = 2

 

Everything is OK as I can see it, but it won't update. I tried with mysql_affected_rows and it's not doing anything.

 

Can you help me?

 

Link to comment
https://forums.phpfreaks.com/topic/277137-php-mysql-update-not-working/
Share on other sites

you are supplying a database connection in the mysql_query() statement. you need to use that same connection in mysql_error() statement to insure you are getting any mysql error for the query you just ran.

 

are you sure you have a row WHERE id = 161241 AND id_kalkulacija = 2 and what are the datatypes of those two columns?

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.