I want to insert this games and images, these have same names. I couldnt find where I mistake. Please write me some ideas. I'm waiting for good ideas. Thanks. I will rep who solve my problem. This is my code, where is mistake? $dir='mydir'; $open=opendir($dir); while ($file=readdir($open)) { if (is_file($file)) { $file=substr($file,0,-4); mysql_query("insert into oyunlar (id, name, image, catid, hit, categori, url) values ('', '$file', 'mydir/$file.jpg', '1', '0', 'Sport', 'mydir/$file.swf')"); } } closedir($open); Code (markup):
trying checking to see if the directory is opened to start with. if( $open = opendir($mydir) ) { //it's open } else { // error } PHP:
ErsinAcar, there is no error text on the screen from php. ansi, i controlled if it was opened or not as you say. it opened correctly. But it was not inserted into database again.
After the line: $file=substr($file,0,-4); PHP: put: echo $file."<br>"; PHP: to see what happens. Add: or die(mysql_error()); PHP: behind your query to see why it fails.
try something like this... <?php $dir = "mydir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $sql = "insert into tbl1(foo,bar) values('".$file."','".sprintf("%.02f",(filesize($file) / 1024))." kb')"; // send query : $result = mysql_query($sql); blah blah } } } else die("unable to open ".$dir); ?> PHP:
TheBorg, I did you say. But screen is same again. It didnt list files opened. ansi, there is no instering and no error..
did you edit it to put what you want where you want and actually send the query? in my example, it's just that an example with ficticious information.
I solve my problem. I see my mistake. Mistake ; I put in same file name jpg and swf to a folder. Example ; xxx.jpg and xxx.swf So it took 2 same file name "xxx", so it didnt wors. Now i put only swf files to folder, and run php file. it was done. thanks for all opinions. Reps added.