reiniger Posted April 10, 2008 Report Share Posted April 10, 2008 (edited) <input type="file" name="img" /> $uploadname = basename($_FILES['img']['name']); echo $uploadname; $query="UPDATE table_img SET img_name='$uploadname'" Ar formu nosuta failiņu. Fails veiksmigi tiek saglabāts un ar echo tiek nodrukāts faila nosaukums, BET datu bāzē nekas nesaglabajas. Kad ar roku lieku kadu citu vartibu saglabāt viss strādā, bet kad taisni $uploadname grib saglabāt tad saglabājas tukšums. Kas par problēmu varētu būt? Edited April 10, 2008 by reiniger Link to comment Share on other sites More sharing options...
andrisp Posted April 10, 2008 Report Share Posted April 10, 2008 echo mysql_error() uzreiz pēc kverija. Link to comment Share on other sites More sharing options...
reiniger Posted April 10, 2008 Author Report Share Posted April 10, 2008 (edited) Nekādu error neparāda... varbūt vajag kā savādāk saglabāt faila nosaukumu? Edited April 10, 2008 by reiniger Link to comment Share on other sites More sharing options...
andrisp Posted April 10, 2008 Report Share Posted April 10, 2008 A ko atgriež mysql_query() ? Paskaties ar var_dump() Link to comment Share on other sites More sharing options...
NiTrino Posted April 10, 2008 Report Share Posted April 10, 2008 (edited) varbuut kveriju vajag izpildiit? :D Edited April 10, 2008 by NiTrino Link to comment Share on other sites More sharing options...
darksign Posted April 10, 2008 Report Share Posted April 10, 2008 (edited) <input type="file" name="img" /> $uploadname = basename($_FILES['img']['name']); echo $uploadname; $query="UPDATE table_img SET img_name='$uploadname'" Tev kverijs nepareizs nav WHERE nosacījums! Līdz šim sql update vismaz bija obligāti norādīt kam to update taisīt UPDATE table_name SET column_name = new_value WHERE column_name = some_value; Edited April 10, 2008 by darksign Link to comment Share on other sites More sharing options...
darksign Posted April 10, 2008 Report Share Posted April 10, 2008 varbuut kveriju vajag izpildiit? :D jā un tas arī :D Link to comment Share on other sites More sharing options...
NiTrino Posted April 10, 2008 Report Share Posted April 10, 2008 nav taisnība. UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_condition] kā redzams, WHERE ir kvadrātiekavās, kas nozīmē ka viņš nav obligāts. http://dev.mysql.com/doc/refman/5.0/en/update.html Link to comment Share on other sites More sharing options...
reiniger Posted April 10, 2008 Author Report Share Posted April 10, 2008 (edited) Nu ir man ari WHERE es vienkarshi visu lieko noņēmu nost. kad izdara shita tad $uloadname=2; $query="UPDATE table_img SET img_name='$uploadname' WHERE id = 1" tad viss strādā! izdod man šādu rezultātu: var_dump($query) UPDATE table_img SET img_name='24.gif', img_adres='../img/24.gif' WHERE id=1" Edited April 10, 2008 by reiniger Link to comment Share on other sites More sharing options...
darksign Posted April 10, 2008 Report Share Posted April 10, 2008 nav taisnība. UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_condition] kā redzams, WHERE ir kvadrātiekavās, kas nozīmē ka viņš nav obligāts. http://dev.mysql.com/doc/refman/5.0/en/update.html Nezinu, bet man savā dzīvītē vēl ne reizi nav nācies redzēt brīnumus, ka UPDATE ir iespējams bez WHERE, ja es kļūdos, tad ieskaidro man... manuprāt specifikācijā kļūda... tā arī var gadīties... Link to comment Share on other sites More sharing options...
bubu Posted April 10, 2008 Report Share Posted April 10, 2008 Protams, ka drīkst nerakstīt WHERE. Piemēram, tu gribi visiem tabulas ierakstiem palielināt count lauka vērtību par 1: UPDATE tabule SET count = count + 1 Ļoti valīds kverijs. Link to comment Share on other sites More sharing options...
darksign Posted April 10, 2008 Report Share Posted April 10, 2008 (edited) tnx bubu par info, nekad sho te nebija vajadziibas izmantot :)) tagad zinaashu :)) reiniger varbuut labaak iepasto to formu un php visu.. man jau saak likties ka vaina ir kur citur... pamēģini izprintēt print_r($_FILES) un pasties vai vispar esi dabūjis to ko gribi... un vai skaties pareizās ailes tai masīvā... Edited April 10, 2008 by darksign Link to comment Share on other sites More sharing options...
NiTrino Posted April 10, 2008 Report Share Posted April 10, 2008 nu formai laikam ir pielikts enctype="multipart/form-data" ... ? Link to comment Share on other sites More sharing options...
reiniger Posted April 10, 2008 Author Report Share Posted April 10, 2008 (edited) enctype="multipart/form-data" jap shitais ir pievienots... <form action="img_upload.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="250000" /> <br /> <input type="file" name="img" /> bet ka jau rakstiju DUMP man parada ka viss ir ok . visas vertibas saktrit. bet phpmyadmin rada neko! print_r($_FILES) rezultats: Array ( [upload_header_img] => Array ( [name] => 24.gif [type] => image/gif [tmp_name] => C:\wamp\tmp\php49E3.tmp [error] => 0 [size] => 3756 ) ) var_dump($query); rezultats: "UPDATE table_img SET img_name='24.gif', img_adres='../img/24.gif' WHERE id=1" bet mans MYSQL datu bazes lauki ir tukshi izņemot id=1 :( Edited April 10, 2008 by reiniger Link to comment Share on other sites More sharing options...
Val Posted April 10, 2008 Report Share Posted April 10, 2008 http://php.lv/f/index.php?s=&showtopic...ost&p=81815 Link to comment Share on other sites More sharing options...
Recommended Posts