millers Posted September 17, 2008 Report Share Posted September 17, 2008 (edited) Sveiki.Jautājums tāds kā lai Ievieto Datubāze lietotāj vārdus un pectam to izvilkt ārā .. Es dariju kko šādu ,bet viņjs ievieto datubāzē tikai skaitli un velk ārā ari tikai skaitli .. Rekur kko šādu es meiģināju Šī Daļa Atrodas index.php failā $user = quote_smart(htmlspecialchars($_POST['username'])); $pass = quote_smart(md5($_POST['password'])); $id = mysql_result(mysql_query("SELECT id FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'id'); $_SESSION['mans_id'] = $id; šis atrodas forum.php $virsraksts = quote_smart($_POST['topic']); $raksts = quote_smart($_POST['teksts']); mysql_query("INSERT INTO forums (topic,teksts,datums,pievienojis) VALUES ($virsraksts,$raksts,".time().",{$_SESSION['mans_id']})"); Ar šo es Izvelku ārā echo $row['pievienojis']; iekšā mysql pievienojis Lauks ir int Mana doma ir tāda vainu mysql lauks ir nepareizs vainu kkas ar to kodu kas atrodas index.php failā Edited September 17, 2008 by millers Link to comment Share on other sites More sharing options...
Paulinjsh Posted September 17, 2008 Report Share Posted September 17, 2008 izdrukā pirms inserta datus, kuri glabājas sesijā. Link to comment Share on other sites More sharing options...
andrisp Posted September 17, 2008 Report Share Posted September 17, 2008 Nu bet tu jau pats ievieto tur ID. Link to comment Share on other sites More sharing options...
werd Posted September 17, 2008 Report Share Posted September 17, 2008 $id = mysql_result(mysql_query("SELECT id FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'id'); SELECT id - izvelk tikai id SELECT id, niks - izvelk id un niku Link to comment Share on other sites More sharing options...
millers Posted September 17, 2008 Author Report Share Posted September 17, 2008 (edited) Es meiģināju arī SELECT niks FROM ... Bet nekā tikuntā viņs pēctam inserto lietotāja id.. Nevarētu būt problēma kad pievienojis lauks ir int ? Edited September 17, 2008 by millers Link to comment Share on other sites More sharing options...
andrisp Posted September 17, 2008 Report Share Posted September 17, 2008 Nu vecīt, bet tu taču pats kverijā ievieto $_SESSION['mans_id']! Ko tad pats brīnies ? Link to comment Share on other sites More sharing options...
millers Posted September 17, 2008 Author Report Share Posted September 17, 2008 nu jā bet vaitad viņš to mans_id nenolasa no index.php faila koda kur ir SELECT id FROM ? tiko es aizstāju to SELECT id FROM pret SELECT niks FROM bet tikunta viņš man ievieto to lietotāj id ... Link to comment Share on other sites More sharing options...
andrisp Posted September 17, 2008 Report Share Posted September 17, 2008 Tavā kodā es īsti nespēju orientēties, bet tev vajag kaut ko aptuveni šādu tad: $_SESSION['user_data'] = select id, niks from users where niks = bla and pass = bla insert into forums un izmanto $_SESSION['user_data']['niks']. Link to comment Share on other sites More sharing options...
kasisppr Posted September 17, 2008 Report Share Posted September 17, 2008 Neesmu pārliecināts, bet, ja mainiji SQL, tad $id = mysql_result(mysql_query("SELECT id FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'id'); //vai tikai nav japamaina kas vairak??? $id = mysql_result(mysql_query("SELECT niks FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'niks'); Paskaties ko isti dara mysql_result() 3-ais parametrs. Link to comment Share on other sites More sharing options...
millers Posted September 17, 2008 Author Report Share Posted September 17, 2008 (edited) Neesmu pārliecināts, bet, ja mainiji SQL, tad $id = mysql_result(mysql_query("SELECT id FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'id'); //vai tikai nav japamaina kas vairak??? $id = mysql_result(mysql_query("SELECT niks FROM registretie_lietotaji WHERE niks = $user AND parole = $pass"),0,'niks'); Paskaties ko isti dara mysql_result() 3-ais parametrs. Dariju tā nepalīdz .. andrisp tava doma bij šāda ? $_SESSION['user_data'] = mysql_result(mysql_query("SELECT id,niks FROM lietotaaji WHERE niks = $username AND parole = $password"),0,'id'); Edited September 17, 2008 by millers Link to comment Share on other sites More sharing options...
anonīms Posted September 17, 2008 Report Share Posted September 17, 2008 a vaitad nevajag $forumas = mysql_query("SELECT blablabla FROM forums"); ... $posters = mysql_query("SELECT id, niks FROM registretie_lietotaji WHERE id = '$forumas[pievienojis]'"); $posters = mysql_fetch_array($posters); echo $posters[1]; Link to comment Share on other sites More sharing options...
anonīms Posted September 17, 2008 Report Share Posted September 17, 2008 a vaitad nevajag $forumas = mysql_query("SELECT blablabla FROM forums"); ... $posters = mysql_query("SELECT id, niks FROM registretie_lietotaji WHERE id = '$forumas[pievienojis]'"); $posters = mysql_fetch_array($posters); echo $posters[1]; Link to comment Share on other sites More sharing options...
Recommended Posts