Mikijs Posted January 26, 2008 Report Share Posted January 26, 2008 (edited) Sveiki. es jau labu laiku rosos lai pajautātu, bet negribēju izklausīties pēc galīga muļķa... vopš lieta tāda ka veidoju savu CMS un sāku ar jaunumu sadaļu, bet aizkēros aiz muļķīga ID, pasakiet plz kas nav pareizi. admin.php?do=jaunumi&what=new if ($_GET['what']=="new"){ $makeid = dbquery("SELECT * FROM ".PREF."raksti"); $plus = "1"; $selid = dbrows($makeid)+$plus; echo "<form method='post' action='admin.php?do=jaunumi&what=save&id=".$selid."'><h1>Jaunumi - pievienot</h1> ".$lv['005']."<br /><input type='text' name='virsraksts'><br /> ".$lv['008']."<br /><input type='text' name='lasitvairak'><br /> ".$lv['006']."<br /><textarea name='teksts'></textarea><br /> <input type='submit' value='ok'></form>"; } admin.php?do=jaunumi&what=save if ($_GET['what']=="save"){ $title = $_POST['virsraksts']; $teksts = $_POST['teksts']; $ievietots = $_SERVER['REQUEST_TIME']; $id = $_GET['id']; $lasitvairak = $_POST['lasitvairak']; dbquery("INSERT INTO ".PREF."raksti ( id, virsraksts, teksts, ievietots , lasitvairak ) values( '".$id."', '".$title."', '".$teksts."', '".$ievietots."', '".$lasitvairak."' ) "); echo "<dib align='center'>Saglabāts</div>"; } Zinu ka stūlbi tur izskatās tas ID, bet savādāk nemāku xD, vismaz nēsmu atradis =/ Edited January 26, 2008 by Mikijs Link to comment Share on other sites More sharing options...
andrisp Posted January 26, 2008 Report Share Posted January 26, 2008 Neģenerē pats to ID. Ļauj, lai SQL serveris pats piešķir ID. Tb, vienkārši taisi insertu, nenorādot ID (tikai atceries, ka tev tai kolonnai jābūt primary un auto_increment). Un ja tev to id pēc tam vajag, tad uzreiz pēc pievienošanas vari dabūt to ar mysql_insert_id(). Link to comment Share on other sites More sharing options...
Mikijs Posted January 26, 2008 Author Report Share Posted January 26, 2008 (edited) TATAD ? dbquery("INSERT INTO ".PREF."raksti ( id, virsraksts, teksts, ievietots , lasitvairak ) values( 'NULL', '".$title."', '".$teksts."', '".$ievietots."', '".$lasitvairak."' ) "); strada =] tnQ Edited January 26, 2008 by Mikijs Link to comment Share on other sites More sharing options...
andrisp Posted January 26, 2008 Report Share Posted January 26, 2008 To ID ņem ārā vispār no kverija. Link to comment Share on other sites More sharing options...
mounkuls Posted January 27, 2008 Report Share Posted January 27, 2008 To ID ņem ārā vispār no kverija. Vai tad? Mikijs jau itkā pareizi manuprāt ieliek kā NULL vai '0'. Tas gan pie nosacijuma, ka id ir auto increment tikai šancēs man liekas... Link to comment Share on other sites More sharing options...
andrisp Posted January 27, 2008 Report Share Posted January 27, 2008 Ja SQL serveris nav Strict režīmā, tad strādās, bet vispār tas nav labs stils. Link to comment Share on other sites More sharing options...
Recommended Posts