Code that use to work and no longer does!?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tsiko
Forum Newbie
Posts: 2
Joined: Fri Apr 02, 2004 12:36 pm

Code that use to work and no longer does!?

Post by tsiko »

OK guys, first new to this forum so a hello to all. I am not by any means and experienced php coder although I am a programmer of many years.
I friend has a site that was already up and running until she had to move it to another server. I am assuming an upgrade on the version of php has broken this script, I have tried a multitude of changes with no success so have decided the best solution is to get help from the pros.
There are two scripts one calls the other to upload informtion to mysql and move a image from the personal machine to a folder on the site. Folder on the site is set to permissions 755. All the details about a product go into the mysql along with the path of the picture, this in turn is used to layout a page. The error message I get looks like this:
copy C:\\Documents and Settings\\tsikora\\My Documents\\sites\\flyingstarstables\\data\\images\ \saddles\\cntycmp_b.JPG to
Warning: copy(C:\\Documents and Settings\\tsikora\\My Documents\\sites\\flyingstarstables\\data\\images\ \saddles\\cntycmp_b.JPG): failed to open stream: No such file or directory in /home/kbenson/public_html/saddleadded.php on line 32

The two scripts, first the form:

?>
<FORM ACTION="saddleadded.php" METHOD=POST>
<INPUT TYPE="radio" NAME="type" VALUE=1>Jumping<INPUT TYPE="radio" NAME="type" VALUE=2>Dressage<BR>
Brand: <INPUT TYPE="text" NAME="brand"><BR>
Treesize: <INPUT TYPE="text" NAME="treesize"><BR>
Seatsize: <INPUT TYPE="text" NAME="seatsize"><BR>
Color: <INPUT TYPE="text" NAME="color"><BR>
Description:<BR>
<TEXTAREA NAME="description" ROWS=4 COLS=60></text><BR>
Price: <INPUT TYPE="text" Name="price"><BR>
Thumbnail: <INPUT TYPE="file" name="thumbnail"><BR>
Full-size Picture: <INPUT TYPE="file" name="bigpic"><BR>
<INPUT TYPE="submit" VALUE="Add Saddle">
</FORM>
<?
include("footer.php");
//mysql_close($link);
?>


then the part of the script receiving the error message
<?
include ("header.php");
$Host = 'localhost';
$User = 'user';
$Password = 'password';
$DBName = 'dbname';
$Link = mysql_connect($Host, $User, $Password) or die ('I cannot connect to the database because:' .mysql_error());
if ($bigpic) {
print("copy $bigpic to $bigpic_name");
if(copy($bigpic, "images/saddles/tmp.jpg")) {
print("Big picture successfully uploaded.<P>\n");
}else{
print("Sorry, try again.");
}
}

...there is more but it's all working properly as the mysql database is updated
It seems to me it's trying to find the file to upload on the site itself and I'm not sure why or how to fix it.
Thanks
Terri
:(
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The most obvious candidate is register_globals, the code requires it to be On (and it's Off by default with PHP => 4.2.0 ), so i'd check that first.
A <?php phpinfo() ?> page will tell you.
tsiko
Forum Newbie
Posts: 2
Joined: Fri Apr 02, 2004 12:36 pm

fixed it well kinda

Post by tsiko »

OK it was not the globals but rather the form that was wrong

ENCTYPE="multipart/form-data"

however I am now getting
failed to open stream: Permission denied in /home/owner/public_html/saddleadded.php on line 20

the folder I am copying to is setup as 755 is this not enough?
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Post by TheBentinel.com »

755 would give everyone but the owner read and execute, but not write permission. 766 would give read/write.
Post Reply