Nezinītis Posted May 26, 2010 Report Share Posted May 26, 2010 (edited) Sveiki. Izmeklējos, bet tā arī nevarēju sekmīgi atrast, ko man vajag. :x Griežos pie jums. Kā pareizi kvērijā tiek izmantots inet_aton un inet_ntoa? Vēlos Ip adresi glabāt tabulā ar integer tipu. Mēģinu - $kveerijs=mysql_query("INSERT INTO issues (subject, content, type, project_id, user_id, status, ip_add) VALUES (".S($subject).",".S($content).",".S($type).",".S($project_id).",".S($_SESSION['u_id']).",".S($veert_main).",inet_aton(".$ip."))")or die('buum, nomira.'); bet dabuju ar lineāru pa pirkstiem. :( Edited May 26, 2010 by Nezinītis Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 26, 2010 Report Share Posted May 26, 2010 (edited) Ip adrese ir string tips, tāpēc to jāliek apostrofos. Doma aptuveni tāda: mysql_query("insert into table (ip) values ('$ip')"); Edited May 26, 2010 by Maris-S Quote Link to comment Share on other sites More sharing options...
Nezinītis Posted May 26, 2010 Author Report Share Posted May 26, 2010 (edited) Ip adrese ir string tips, tāpēc to jāliek apostrofos. Doma aptuveni tāda: mysql_query("insert into table (ip) values ('$ip')"); bump. A viņš man php mainīgo tāpat arī apēdīs? Kaut kur esi aizdomājies. :) + ja uzraksta pareizo tavu variantu.. tāpat tas neko nedod.. :x Edited May 26, 2010 by Nezinītis Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted May 26, 2010 Report Share Posted May 26, 2010 Pārveido jau php pusē uz int - http://lv.php.net/manual/en/function.ip2long.php Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted May 26, 2010 Report Share Posted May 26, 2010 Pārveido jau php pusē uz int - Kaapec?? Kaads labums?? Sarezgiitaks kods? Nav ko mociit PHP, ja to lieliski var izdariit ar SQL funkciju ... to Nezinītis: tev viss itkaa pareizi tik, padotaa IP bija jaieliek pedinjas (strings) Piedevam neaizmirti ka lai glabatu IP kaa integer, jaizmanto atribuuts UNSIGNET (pie datu tipa) Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 26, 2010 Report Share Posted May 26, 2010 Īsti nesapratu ko Tu domāji ar php mainīgā apēšanu? Tas jau Tev ir cik saprotu pirms vaicājuma definēts un viņam piešķirta ip adrese kā vērtība. Quote Link to comment Share on other sites More sharing options...
Nezinītis Posted May 26, 2010 Author Report Share Posted May 26, 2010 Hmmm.. paņemu ip adresi - $ip=$_SERVER['REMOTE_ADDR']; ievietoju tabulā - INSERT INTO issues (ip_add) VALUES (inet_aton('".$ip."')) bet tabulā lauka vērtība ir NULL. why? :x Quote Link to comment Share on other sites More sharing options...
Nezinītis Posted May 26, 2010 Author Report Share Posted May 26, 2010 bump*. :( Quote Link to comment Share on other sites More sharing options...
waplet Posted May 26, 2010 Report Share Posted May 26, 2010 (edited) mysql_query("INSERT INTO issues(ip_add) VALUES (inet_aton('".$ip."'))"); Edited May 26, 2010 by waplet Quote Link to comment Share on other sites More sharing options...
Nezinītis Posted May 26, 2010 Author Report Share Posted May 26, 2010 Nu tak, tur nav problēma.. viss kvērijs - $kveerijs=mysql_query("INSERT INTO issues (subject, content, type, project_id, user_id, status, ip_add) VALUES (".S($subject).",".S($content).",".S($type).",".S($project_id).",".S($_SESSION['u_id']).",".S($veert_main).",inet_aton('".$ip."'))")or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
briedis Posted May 26, 2010 Report Share Posted May 26, 2010 Kur tad ir problēma? Kādi kļūdas ziņojumi? Quote Link to comment Share on other sites More sharing options...
Nezinītis Posted May 26, 2010 Author Report Share Posted May 26, 2010 Nekādu. Tikai tabulā, lauka - ip_add - vērtība ir NULL. Datu tips laukam - ip_add = INT UNSIGNED. :X Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 26, 2010 Report Share Posted May 26, 2010 Pirms paša vaicājuma izpildīšanas izvadi kāds šis izskatās. echo("INSERT INTO issues (subject, content, type, project_id, user_id, status, ip_add) VALUES (".S($subject).",".S($content).",".S($type).",".S($project_id).",".S($_SESSION['u_id']).",".S($veert_main).",inet_aton('".$ip."'))"); Quote Link to comment Share on other sites More sharing options...
Maris-S Posted May 26, 2010 Report Share Posted May 26, 2010 Kas tā par funkciju S? S($subject) Quote Link to comment Share on other sites More sharing options...
Леший Posted May 27, 2010 Report Share Posted May 27, 2010 (edited) Pārveido jau php pusē uz int - http://lv.php.net/manual/en/function.ip2long.php Wrong, PHP, cik atceros, strādā tikai ar signed int. Par tēmu: piekritīšu Maris-S, vaina, laikam, ir S() funkcijai. Ja tā returno string, tad šis query nestrādās. Vispār, tev tur nekur nav '(quote), neticu, ka visi fieldi ir skaitļi. Edited May 27, 2010 by Леший Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.