BlackKite Posted August 6, 2006 Share Posted August 6, 2006 I have this script I wrote up as a php backend. But its throwing some errors i dont quite understand. Hope someone can help me fix this. Please[u][b]Error:[/b][/u][quote]Originally Posted byWarning: ftp_fput() expects parameter 2 to be string, resource given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52[/quote][u][b]Line 52:[/b][/u][code]ftp_fput($connection, $bandle, $file, FTP_ASCII);[/code][u][b]Whole Code:[/b][/u][code=php:0]<?php //Check for file existence;$ourFile = $_POST['title'];$filename = "/home/jaboo12/public_html/$ourFile";if (file_exists("$filename")) { echo "The file $filename already exists. Please hit the back button and choose a new one"; exit();} else { echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>";} //If it doesn't exist, login to FTP and chmod;############################ ftp settings #$ftpServer='ftp.neohound.com'; //ftp server, without ftp://$ftpPort=21; //the ftp port (don't change if you don't know what it is)$ftpUser='XXXXXX'; //ftp username$ftpPass='XXXXXX'; //ftp password# end ftp settings ######################################################## file settings #$tempfile = '/home/jaboo12/public_html/temp.php';$ftpdir = 'public_html';$nav = 'public_html/index.php';$file = '/home/jaboo12/public_html/$ourFile';# end file settings ############################//connect to server$connection = ftp_connect($ftpServer, $ftpPort);ftp_login($connection, $ftpUser, $ftpPass);//chmod directory so that the server can create a fileftp_chmod($connection, 0777, $ftpdir);//make temporary file$handle = fopen("$tempfile", 'w');fclose($handle); //upload file using ftp$bandle = fopen("$tempfile", 'r');ftp_fput($connection, $bandle, $file, FTP_ASCII);fclose($bandle);//delete temporary fileunlink($tempfile); $ourFileName = $_POST['name'];$ourLinkName = $_POST['link']; //Post content feild to the file created;$myFile = "/home/jaboo12/public_html/$ourFile";$fh = fopen("$myFile", 'w') or die("can't open file");$content = $_POST['content'];$help = stripslashes ($content);$newcontent = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>');fwrite ($fh, $newcontent);fclose($fh);//reset directory permissionsftp_chmod($connection, 0750, $ftpdir); //Post navigation link on index;//chmod directory so that the server can create a fileftp_chmod($connection, 0777, $nav);$newLink = "<br> » <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a><!-- game -->";$data = file_get_contents('/home/jaboo12/public_html/index.php');$data = str_replace ('<!-- game -->', $newLink, $data);$fp = fopen ("/home/jaboo12/public_html/index.php", 'w');fwrite ($fp, $data);fclose ($fp);//reset directory permissionsftp_chmod($connection, 0644, $nav);//close connectionftp_close($connection); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/ Share on other sites More sharing options...
ignace Posted August 6, 2006 Share Posted August 6, 2006 euhm.. are those your original username and password if it is, you might wanna change this...change this[code]ftp_fput($connection, $bandle, $file, FTP_ASCII);[/code]to[code]ftp_fput($connection, $tempfile, $file, FTP_ASCII);[/code]the second parameter needs to be an string not an resource i.e.: $bandle = fopen('$tempfile', 'w'); <-- resource Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-70338 Share on other sites More sharing options...
BlackKite Posted August 7, 2006 Author Share Posted August 7, 2006 0.0 Ooh crap, lol, i forgot i had them in there. Removed/changed. Thanks lol, that could of been bad.And thanks for the help, i'll go see if it works. Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-70418 Share on other sites More sharing options...
BlackKite Posted August 7, 2006 Author Share Posted August 7, 2006 Hm, well now i have another error that i dont understand. Actually... i do but i dont know how to fix it ebcause all this code is starting to confuse me. :-\ Im pretty sure its refering to the temp file becuase I have yet to see it in my file directory, but im not sure becuase if it is creating it then unlink is deleteing it.. right? ??? [b]Error:[/b][quote]Warning: ftp_fput() [function.ftp-fput]: Rename/move failure: No such file or directory in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52[/quote][u][b]Line 52:[/b][/u][code=php:0]ftp_fput($connection, $tempfile, $bandle, FTP_ASCII);[/code][u][b]My Code:[/b][/u][code=php:0]<?php //Check for file existence;$ourFile = $_POST['title'];$filename = "/home/jaboo12/public_html/$ourFile";if (file_exists("$filename")) { echo "The file $filename already exists. Please hit the back button and choose a new one"; exit();} else { echo "<center> Thank you for uploading your guide $ourLinkName ($ourFile). I has been posted to the neohound site. Please click <a href=\"http://www.neohound.com/staff2\">HERE</a> to returne to the staff panel.</center>";} //If it doesn't exist, login to FTP and chmod;############################ ftp settings #$ftpServer='ftp.neohound.com'; //ftp server, without ftp://$ftpPort=21; //the ftp port (don't change if you don't know what it is)$ftpUser='XXXXXX'; //ftp username$ftpPass='XXXXXX'; //ftp password# end ftp settings ######################################################## file settings #$tempfile = '/home/jaboo12/public_html/temp.php';$ftpdir = 'public_html';$nav = 'public_html/index.php';$file = '/home/jaboo12/public_html/$ourFile';# end file settings ############################//connect to server$connection = ftp_connect($ftpServer, $ftpPort);ftp_login($connection, $ftpUser, $ftpPass);//chmod directory so that the server can create a fileftp_chmod($connection, 0777, $ftpdir);//make temporary file$handle = fopen("$tempfile", 'w');fclose($handle); //upload file using ftp$bandle = fopen("$file", 'w');ftp_fput($connection, $tempfile, $bandle, FTP_ASCII);fclose($bandle);//delete temporary fileunlink($tempfile); $ourFileName = $_POST['name'];$ourLinkName = $_POST['link']; //Post content feild to the file created;$myFile = "/home/jaboo12/public_html/$ourFile";$fh = fopen("$myFile", 'w') or die("can't open file");$content = $_POST['content'];$help = stripslashes ($content);$newcontent = strip_tags($help, '<img><div></div><font></font><p></p><br></br><hr></hr><a></a><b></b><i></i><u></u>');fwrite ($fh, $newcontent);fclose($fh);//reset directory permissionsftp_chmod($connection, 0750, $ftpdir); //Post navigation link on index;//chmod directory so that the server can create a fileftp_chmod($connection, 0777, $nav);$newLink = "<br> » <a href=\"http://www.neohound.com/index.php?id=$ourFileName\">$ourLinkName</a><!-- game -->";$data = file_get_contents('/home/jaboo12/public_html/index.php');$data = str_replace ('<!-- game -->', $newLink, $data);$fp = fopen ("/home/jaboo12/public_html/index.php", 'w');fwrite ($fp, $data);fclose ($fp);//reset directory permissionsftp_chmod($connection, 0644, $nav);//close connectionftp_close($connection); ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-70427 Share on other sites More sharing options...
BlackKite Posted August 7, 2006 Author Share Posted August 7, 2006 bump Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-70756 Share on other sites More sharing options...
BlackKite Posted August 8, 2006 Author Share Posted August 8, 2006 lol...still need help Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-70915 Share on other sites More sharing options...
BlackKite Posted August 8, 2006 Author Share Posted August 8, 2006 Ugh, im not getting any more help am i? Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-71261 Share on other sites More sharing options...
BlackKite Posted August 9, 2006 Author Share Posted August 9, 2006 Bump #4 Quote Link to comment https://forums.phpfreaks.com/topic/16731-ftp_fput-error-still-need-help/#findComment-71558 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.