wframe Posted April 3, 2011 Share Posted April 3, 2011 Hello guys, I'm using the following script to rename my directory to values stored in a table. The one table (table1) has the name of the current directory and we are trying to rename it to the new value in the second table (table2): Below is the script: (NOTE: the 'echo' statement was used just to let me know if the values were pulled. <?php # Named 'script3.php sets the new random number. In other words, it is responsible for naming a new filename/url.' require_once ('./stuff); // Connect to the database. $query="SELECT * FROM table2"; $result = mysql_query($query); // Run the query. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) $url2_id = $row[url2_id]; echo $url2_id; $query1="SELECT * FROM table1"; $result = mysql_query($query1); // Run the query. while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) $url1_id = $row[url1_id]; echo $url1_id; rename("$url1_id","$url2_id"); ?> Below is the error we get: Warning: rename(832740485,857465976) [function.rename]: No such file or directory in /home/content/01/7477001/html/join/step6.php on line 15. Any advice??? Link to comment Share on other sites More sharing options...
Stuart Posted April 3, 2011 Share Posted April 3, 2011 The error just means that the file doesn't exist at the location you've specified. Are those numbers actually the filenames you're using? Is the file you're trying to rename in the same directory as the executing script? Because thats just the filename and not a full path it's going to be looking in the /join directory for the file named 832740485 - also do they not have extensions? You should really be providing the full path to the filename - here's the basic example from the PHP manual: rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt" 1 Link to comment Share on other sites More sharing options...
Recommended Posts