aywars Posted February 12, 2008 Report Share Posted February 12, 2008 Sveiki! Esmu uzrakstījis php scriptu ar kura palīdzību es varu pārveitot uz serveri mazo un lielo bildi un šo bilžu path noglabaat datubazee... Talak izmantoju shos path (img src="path_no_tatubazes" bla bla bla), lai uztaisiitu taa, ka uzspiezhot uz mazaaas bildes atveras lielaa.. Tiktal viss buutu labi.. Probleemas saakas ar dzeeshanu.. Shos path ierakstus no datubazes izdzeest nav probleema, bet es gribu panaakt to, ka izdzeshot lielaas un mazaas bildes path, izdzeeshas arii pashas bildes.. Ceru ka saprataat ideju.. tabula izskataas apmeram shadi: ---------------------------------------------------- id | mazas_bildes_path | lielaas_bildes_path | ---------------------------------------------------- Ta nu jautaajums: Kaa to dabuut gatavu? Jau ieprieksh pateicos par paliidzību.. Link to comment Share on other sites More sharing options...
Aleksejs Posted February 12, 2008 Report Share Posted February 12, 2008 Nu, droši vien dzēšanai Tu padod bildes id, vai ne? Tādā gadījumā vispirms izveic SELECT mazas_bildes_path, lielasbildes_path FROM tabulas_vards WHERE id=$id tad unlink($rezultats['mazas_bildes_path']); unlink($rezultats['lielas_bildes_path']); un visbeidzot: DELETE FROM tabulas_vards WHERE id=$id Link to comment Share on other sites More sharing options...
Paulinjsh Posted February 12, 2008 Report Share Posted February 12, 2008 tikai nočeko vai tāds fails ir ar http://lv.php.net/manual/en/function.file-exists.php savādāk metīs errorus Link to comment Share on other sites More sharing options...
aywars Posted February 13, 2008 Author Report Share Posted February 13, 2008 (edited) Re kur dzēšanas sadaļa: if (isset($_GET['delete'])) { $id = $_GET['delete']; $query = "SELECT thumbpath, fullpath FROM portfolio WHERE id=$id"; $result = mysql_query($query) or die ("<p> Neizdevās veikt pieprasījumu. </p>"); unlink($result['thumbpath']); unlink($result['fullpath']); $sql = "DELETE FROM portfolio WHERE id='$id'"; if (@mysql_query($sql)) { echo '<p>Darbs tika veiksmīgi izdzēsts! </p>'; } else { echo '<p>Neizdevās izdzēst darbu: ' . mysql_error() . '</p>'; } } šķiet ka sintaksē kļūdu nav, bet tapat man met error: Warning: unlink() [function.unlink]: No such file or directory in.. Kur esmu kļūdījies? AA.. starp citu.. ja, piemeram $result['thumbpath'] vietā es vienkarshi ielieku path uz bildi, teiksim img/thumbs/bilde.jpg tad šis fails arī izdzēšas.. Tā kā laikam taa nebuus probleema ar permisijaam.. Edited February 13, 2008 by aywars Link to comment Share on other sites More sharing options...
aywars Posted February 13, 2008 Author Report Share Posted February 13, 2008 ok es pats tiku galaa.. Shitaa vietaa: $result = mysql_query($query) or die ("<p> Neizdevās veikt pieprasījumu. </p>"); unlink($result['thumbpath']); unlink($result['fullpath']); Ieliku šo: $result = mysql_query($query) or die ("<p> Neizdevās veikt pieprasījumu. </p>") $row = mysql_fetch_object($result); unlink($row->thumbpath); unlink($row->fullpath); Nu katrā zinjaa tas straadaa.. Varbūt kaads specs varetu nokomentet? :) Link to comment Share on other sites More sharing options...
Aleksejs Posted February 13, 2008 Report Share Posted February 13, 2008 Nu, domāju, ka pašam tak Tev nu jau ir skaidrs. Tava problēma bija tajā, ka mēģināji dabūt no mysql recordset resursa ārā elementus. ...mysql_query() returns a resource on success ... The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data. ... Principā, lai strādātu mans variants, vienā rindā to varēja pierakstīt kaut kā šādi: $result=mysql_fetch_assoc(mysql_query("SELECT thumbpath, fullpath FROM portfolio WHERE id=$id")); P.S. šito: if (isset($_GET['delete'])) { $id = $_GET['delete']; labāk šitā: if (isset($_GET['delete'])) { $id = intval($_GET['delete']); Jo citādi Tev kāds iebaros dzest.php?delete=1'; Drop tabula Link to comment Share on other sites More sharing options...
aywars Posted February 13, 2008 Author Report Share Posted February 13, 2008 Paldies par komentāru.. Ņemšu vērā :) Link to comment Share on other sites More sharing options...
Recommended Posts