Jump to content
php.lv forumi

mysql updeits


false

Recommended Posts

Kods:

<?php
if(isset($_GET['op']) && $_GET['op'] == 'atdot'){
echo "Kam tu gribi atdot naudu?<br/><input name='lietotaajs' type='text'><br/>Cik tu gribi atdot?<br/><input name='cik' type='text'><input name='submjit' type='submit' value='Aizdot!'><br/>";
}
if(isset($_POST['submjit'])){
$l_co = $jor['coins'];
$l_coins = $_POST['cik'];
if($l_coins > $l_co){
echo "Aizsūtīts!";
$dadads = mysql_query("SELECT * FROM lietotaaji WHERE niks=".$_POST['lietotaajs']."");
while(mysql_fetch_array($dadads)){
$liet_coins = $kasd['coins'];
$sn_id = $kasd['id'];
$user_c_a = $l_co-$l_coins;
$da_c = $liet_coins+$l_coins;
mysql_query("UPDATE lietotaaji SET coins=".$da_c." WHERE id=".$sn_id."");
mysql_query("UPDATE lietotaaji SET coins=".$user_c_a." WHERE id=$id");
}
}else{
echo "<div class=error>Tev nepietiek naudas!</div>";
}
}
}
?>

Bet nekas neupdeitojas datubāzē.. Kāds var pateikt, kas par kļūdu?

Link to comment
Share on other sites

if(isset($_GET['op']) && $_GET['op'] == 'atdot'){

1. kas pie ir tas tāds? vienkārši:

if($_GET['op'] == "atdot") {

//bla bla

}

$l_co = $jor['coins'];

2. no kurienes šitais uzrodas ?

$dadads = mysql_query("SELECT * FROM lietotaaji WHERE niks=".$_POST['lietotaajs']."");

3. nebāz neko datubāzē, pirms neesi eskeipojis stringus. tas pats attiecās uz tiem update kverijiem.

šādi:

$niks = mysql_real_escape_string($_POST['lietotaajs']);

$dadads = mysql_query("SELECT * FROM `lietotaaji` WHERE `niks`='$niks'");

 

ok, tālāk ir vēl lielāka putra. sāc domāt loģiski. sastādi darbību secību.

un es neredzu, ka skripts meklētu savienojumu ar datubāzi..

Edited by thesnarkie
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...