daxguy Posted August 18, 2010 Share Posted August 18, 2010 i have a random no. of directories and files being created using the mkdir and touch functions and the newly created files are copying a pre-made template.. the links of the pages which were being created had %20 signs between the spaces.. i wanted to change them with "-" soo i used the following code.. but it gives errors.. as invalid arguments in mkdir and touch and as well as copy function can anyone help? here is the code while ($row = mysql_fetch_assoc($result1) ) { $hosting = explode(',', $row['host']); $linking = explode(',', $row['links']); $parts = explode(',', $row['link_no']); $no_host = count($hosting); //miniusing the no of loops to make it accurate $count_host = count($hosting); $count_links = count($parts); $current_k = 0; $sum = 0; $parts_href = ''; $new = null; $updated_part = null; for($i=0; $i<($count_host-1); $i++ ) { $j = $i+1; $hos = str_replace(":","",$hosting[$i]); $path = "$base_folder/{$hos}"; echo "<br />{$hos}"; echo "<br />{$path}"; mkdir($path); for($k=$current_k; $k<($count_links); $k++) { for($f=0; $f<$parts[$current_k]; $f++ ) { $for_touch = "$base_folder/{$hos}/".$linking[$sum].".php"; $for_touch = str_replace(" ","-",$for_touch); touch("$for_touch"); $new_seo = "{$part_href}/{$hos}/".$linking[$sum].".php"; $new_seo = str_replace(" ","-",$new_seo); $new = "$new_seo"; $updated_part = $updated_part.$new; $updated_part = $updated_part.","; //copy function $old_file = "$for_touch"; $new_file = "{$part_page}/part".$sum.".php"; $new_file = str_replace(" ","-",$new_file); $new_file = "$new_file"; copy($new_file,$old_file); $sum++; } $query_href = 'update movies set href_parts = \''.$updated_part.'\''; mysql_query($query_href) or die('COULD NOT EXECUTE THE QUERY FOR PARTS HREF'); echo "<br />{$updated_part}"; $sum = $sum; $current_k = $current_k+1; break; } } PLEASE HELP ME! Quote Link to comment https://forums.phpfreaks.com/topic/211044-seo-optimization-help/ Share on other sites More sharing options...
Adam Posted August 18, 2010 Share Posted August 18, 2010 Could you post more information about the actual data (echo it out) you're passing to the functions, and the errors you're getting..? Quote Link to comment https://forums.phpfreaks.com/topic/211044-seo-optimization-help/#findComment-1100660 Share on other sites More sharing options...
daxguy Posted August 18, 2010 Author Share Posted August 18, 2010 These are the errors Warning: touch() [function.touch]: Unable to create file C:/xampp/htdocs/gl/uploads/movies/2010/08/I-Hate-Luv-Storys-2010-Hindi-Movie-Watch/Dailymotions-Video-Link--Alternative-Link-/I-Hate-Luv-Storys-2010-Hindi-Movie-Watch-Part-1.php because No such file or directory in C:\xampp\htdocs\gl\movie_process.php on line 197 Warning: copy(C:/xampp/htdocs/gl/uploads/movies/2010/08/I-Hate-Luv-Storys-2010-Hindi-Movie-Watch/Dailymotions-Video-Link--Alternative-Link-/I-Hate-Luv-Storys-2010-Hindi-Movie-Watch-Part-1.php) [function.copy]: failed to open stream: No such file or directory in C:\xampp\htdocs\gl\movie_process.php on line 208 The complete code $part_href = "http://localhost/gl/uploads/movies/{$year}/{$month}/{$title}"; $base_folder = "{$base}uploads/movies/{$year}/{$month}/{$title}"; $base = $_SERVER['DOCUMENT_ROOT']."/gl/"; $path = "http://localhost/gl/albums"; $query1 = "select * from movies where title = '".$title."' ;"; $result1 = mysql_query($query1) or die('Could Not Execute The Query'); while ($row = mysql_fetch_assoc($result1) ) { $hosting = explode(',', $row['host']); $linking = explode(',', $row['links']); $parts = explode(',', $row['link_no']); $no_host = count($hosting); //miniusing the no of loops to make it accurate $count_host = count($hosting); $count_links = count($parts); $current_k = 0; $sum = 0; $parts_href = ''; $new = null; $updated_part = null; for($i=0; $i<($count_host-1); $i++ ) { $j = $i+1; $hos = str_replace(":","",$hosting[$i]); $path = "$base_folder/{$hos}"; echo "<br />{$hos}"; echo "<br />{$path}"; mkdir($path); for($k=$current_k; $k<($count_links); $k++) { for($f=0; $f<$parts[$current_k]; $f++ ) { $for_touch = "$base_folder/{$hos}/".$linking[$sum].".php"; $for_touch = str_replace(" ","-",$for_touch); touch("$for_touch"); $new_seo = "{$part_href}/{$hos}/".$linking[$sum].".php"; $new_seo = str_replace(" ","-",$new_seo); $new = "$new_seo"; $updated_part = $updated_part.$new; $updated_part = $updated_part.","; //copy function $old_file = "$for_touch"; $new_file = "{$part_page}/part".$sum.".php"; $new_file = str_replace(" ","-",$new_file); $new_file = "$new_file"; copy($new_file,$old_file); $sum++; } $query_href = 'update movies set href_parts = \''.$updated_part.'\''; mysql_query($query_href) or die('COULD NOT EXECUTE THE QUERY FOR PARTS HREF'); echo "<br />{$updated_part}"; $sum = $sum; $current_k = $current_k+1; break; } } Quote Link to comment https://forums.phpfreaks.com/topic/211044-seo-optimization-help/#findComment-1100675 Share on other sites More sharing options...
Adam Posted August 18, 2010 Share Posted August 18, 2010 Okay well looking at the code I'm going to guess that 1 or more of the paths you're trying to create don't have parent directories. Try passing the recursive parameter to mkdir and see if that fixes the problem. Quote Link to comment https://forums.phpfreaks.com/topic/211044-seo-optimization-help/#findComment-1100703 Share on other sites More sharing options...
daxguy Posted August 18, 2010 Author Share Posted August 18, 2010 it doesnt.. Quote Link to comment https://forums.phpfreaks.com/topic/211044-seo-optimization-help/#findComment-1100833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.