473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ftp_fput() error help

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

Error:
Warning: ftp_fput() expects parameter 2 to be string, resource given in /home/jaboo12/public_html/staff2/guide_p/game_p.php on line 52
Line 52:
[PHP]ftp_fput($connection, $bandle, $file, FTP_ASCII);[/PHP]

Whole Code:
[PHP]<?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='jaboo12'; //ftp username
$ftpPass='staycool'; //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 file
ftp_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 file
unlink($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 permissions
ftp_chmod($connection, 0750, $ftpdir);



//Post navigation link on index;

//chmod directory so that the server can create a file
ftp_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 permissions
ftp_chmod($connection, 0644, $nav);

//close connection
ftp_close($connection);

?>[/PHP]
Aug 6 '06 #1
2 2649
bevort
53
You get this error because the var $bandle does not exist

I think you made an error typing the $handle var, you typed $bandle with a B instead.

Vincent
Aug 7 '06 #2
no, lol, i put bandle becuase i already had another handle and i thought that might of been causing the problem.


$bandle = fopen("$tempfile", 'r');

ftp_fput($connection, $bandle, $file, FTP_ASCII);

fclose($bandle);
Aug 7 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
2
by: Maurizio Amoroso | last post by:
.... DTSRun: Executing... DTSRun OnStart: DTSStep_DTSExecuteSQLTask_1 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_2 DTSRun OnStart: DTSStep_DTSExecuteSQLTask_4 DTSRun OnStart:...
6
by: Rowan | last post by:
Hello, I have been trying to solve this problem for a couple of weeks now with no progress. I created a package that works when it runs from my computer but when it runs as a scheduled job, it...
8
by: Rene | last post by:
Hi, I'm spend many hour to fix this problem, read many articles about it but no article gave a solution. To isolate the problem I've created in IIS6 (WServer2003) a virtual directory test to...
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
10
by: DataBard007 | last post by:
Hello Access Gurus: I use Win98SE and Access97. I just built a simple Access97 application which holds all contact information for my personal contacts, such as first name, last name, address,...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: kvarada | last post by:
Hello Experts, I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
0
by: andy3381 | last post by:
Hi, I am having a scheduled job running DTS packages on my production environment. My production server server is having Window 2003 Sp2 installed on it. Before rebuilding the server I was...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.