Forum Moderators: coopster

Message Too Old, No Replies

Unknown Parse error

         

dkin

5:43 am on Dec 15, 2004 (gmt 0)

10+ Year Member



I am getting this error from this script.

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/eqoagui/public_html/img/loademup.php on line 30

This is line 30

print "<strong>$_FILES['userfile']['name'][$q]</strong> did not upload!";

if (move_uploaded_file($_FILES['userfile']['tmp_name'][$q], $uploaddir . $new_pic)) {
$sql = "INSERT INTO `pics` ( `pic_id` , `name` , `descrip` )VALUES ('$new_id', NULL , NULL);";
mysql_query($sql);
} else {
print "<strong>$_FILES['userfile']['name'][$q]</strong> did not upload!";
}

I have been looking at it for 20 mins and can not find anything, any help would be appreciated.

Thanks all.

Cheers

orion_rus

7:22 am on Dec 15, 2004 (gmt 0)

10+ Year Member



make it so
print "<strong>".$_FILES['userfile']['name'][$q]."</strong> did not upload!";
Good luck to you

orion_rus

7:29 am on Dec 15, 2004 (gmt 0)

10+ Year Member



And i'm don't sure but change
$sql = "INSERT INTO `pics` ( `pic_id` , `name` , `descrip` )VALUES ('$new_id', NULL , NULL);";
to
$sql = "INSERT INTO `pics` ( `pic_id` , `name` , `descrip` )VALUES ('$new_id', NULL , NULL)";

coopster

12:43 pm on Dec 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Right on both counts, orion_rus.

Array do's and don'ts [php.net]
mysql_query() [php.net] strings should not end with a semicolon.

dkin

1:19 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



That got me one step further, now I am getting all these errors.

Warning: move_uploaded_file(/home/eqoagui/public_html/img/): failed to open stream: Is a directory in /home/eqoagui/public_html/img/loademup.php on line 26

Warning: move_uploaded_file(): Unable to move '/tmp/phpwZgocg' to '/home/eqoagui/public_html/img/' in /home/eqoagui/public_html/img/loademup.php on line 26
02-12-2004 03;30;47PM.JPG did not upload!
Warning: getimagesize(): Read error! in /home/eqoagui/public_html/img/loademup.php on line 35

Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in /home/eqoagui/public_html/img/loademup.php on line 49

Warning: imagecreatefromjpeg(): '/home/eqoagui/public_html/img/' is not a valid JPEG file in /home/eqoagui/public_html/img/loademup.php on line 49

Warning: imagecopyresized(): supplied argument is not a valid Image resource in /home/eqoagui/public_html/img/loademup.php on line 51

Warning: imagejpeg(): Unable to open '/home/eqoagui/public_html/img/thumbs/' for writing in /home/eqoagui/public_html/img/loademup.php on line 52

if (move_uploaded_file($_FILES['userfile']['tmp_name'][$q], $uploaddir . $new_pic)) {
$sql = "INSERT INTO `pics` ( `pic_id` , `name` , `descrip` )VALUES ('$new_id', NULL , NULL)";
mysql_query($sql);
} else {
print "<strong>".$_FILES['userfile']['name'][$q]."</strong> did not upload!";
}

$new_thumb = "thumbs/$new_pic";
$sourcefile = "$uploaddir$new_pic";
$picsize = getimagesize("$sourcefile");
$source_x = $picsize[0];
$source_y = $picsize;

if ($source_x > $source_y){
$dest_x = 200;
$dest_y = 150;
} else {
$dest_x = 150;
$dest_y = 200;
}

$targetfile = "$uploaddir$new_thumb";
$jpegqual = 75;
$source_id = imagecreatefromjpeg("$sourcefile");
$target_id = imagecreatetruecolor($dest_x, $dest_y);
$target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
imagejpeg($target_id,"$targetfile",$jpegqual);

That is from the first line error to the last. I cannot see why I am getting these. Anyone know.

Thanks

orion_rus

9:31 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Ur folder haven't right permissions. Whats why u can't move file there

orion_rus

9:32 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



and print ur $movie_pic value pls)

orion_rus

9:32 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



$new_pic) sorry again)

dkin

2:52 am on Dec 16, 2004 (gmt 0)

10+ Year Member



A) What should I CHMOD the folder, I tried 777 and still got the same errors.

B) I tried displaying the value of $new_pic and I get nohing.

dkin

3:35 am on Dec 16, 2004 (gmt 0)

10+ Year Member



ok, I fiddled around with it a little bit and it is now getting through those errors, I dont know if this is a solid change but thus far its working.

But I am getting this error now.

Warning: imagejpeg(): Unable to open '/home/eqoagui/public_html/img/thumb/thumbs/1.jpg' for writing in /home/eqoagui/public_html/img/loademup.php on line 54

It is on the last line of this snippet.

$targetfile = "$uploaddir$new_thumb";
$jpegqual = 75;
$source_id = imagecreatefromjpeg("$sourcefile");
$target_id = imagecreatetruecolor($dest_x, $dest_y);
$target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
imagejpeg($target_id,"$targetfile",$jpegqual);

I think this should be the last problem I have, if anyone can help I will be very grateful.

dkin

4:24 am on Dec 16, 2004 (gmt 0)

10+ Year Member



OK well, the problems seem to be hidden through out the entire script so I am going to post the whole thing, if someone sees an error please let me know.

<p></p><html>
<head><title>Enter Name and Descriptions of Pics</title></head>
<body>
<h1>Enter Name and Descriptions of Pics</h1>
<form action="view.php" method="post">

<?php
$dbh=mysql_connect("localhost", "*****", "*****") or die ('I cannot connect to the database.');
mysql_select_db("*****");

$result = mysql_query("SELECT * FROM pics ORDER BY pic_id DESC LIMIT 1",$dbh) or die ("query 3: " . mysql_error());
$row = mysql_fetch_array($result);

$uploaddir = '/home/*****/public_html/img/thumb/';
$tot = count($userfile);
$num = 0;
for($q=0;$q<$tot;$q++){

if ($_FILES['userfile']['name'][$q] == "") continue;

$num = $num + 1;
$sql = "SELECT pic_id FROM pics ORDER BY pic_id DESC LIMIT 1";
$result = mysql_query($sql);

$new_id = $row['pic_id'] + 1;
$new_pic = "$new_id.jpg";

if (move_uploaded_file($_FILES['userfile']['tmp_name'][$q], $uploaddir . $new_pic)) {
$sql = "INSERT INTO pics (pic_id,name,descrip)VALUES ('$new_id', NULL , NULL)";
mysql_query($sql);
} else {
print "<strong>".$_FILES['userfile']['name'][$q]."</strong> did not upload!";
exit;
}

$new_thumb = "$new_pic";
$sourcefile = "$uploaddir$new_pic";
$picsize = getimagesize("$sourcefile");
$source_x = $picsize[0];
$source_y = $picsize;

if ($source_x > $source_y){
$dest_x = 200;
$dest_y = 150;
} else {
$dest_x = 150;
$dest_y = 200;
}

$targetfile = "$uploaddir$new_pic";
$jpegqual = 75;
$source_id = imagecreatefromjpeg("$sourcefile");
$target_id = imagecreatetruecolor($dest_x, $dest_y);
$target_pic = imagecopyresized($target_id,$source_id,0,0,0,0,$dest_x,$dest_y,$source_x,$source_y);
imagejpeg($target_id,"$targetfile",$jpegqual);
?>
<div style="clear: both;">
<a href="/img/thumb/<?=$new_pic?>">
<img src="/img/thumb/<?=$new_pic?>" style="float: left" />
</a>
<strong><?=$_FILES['userfile']['name'][$q]?></strong><br /><br />
<strong>Name:</strong><br />
<input type="text" name="pic_name[<?=$num?>]" /><br /><br />
<strong>Descriptio<?php ?>n:</strong><br />
<textarea name="descrip[<?=$num?>]"></textarea>
<input type="hidden" name="pic_id[<?=$num?>]" value="<?=$new_id?>" />
</div>
<?php
}
?>
<input type="submit" value="Click to Save Descriptions" />
</form>
</body>
</html>

orion_rus

8:49 pm on Dec 16, 2004 (gmt 0)

10+ Year Member



try move out from syntaxis like this
$targetfile = "$uploaddir$new_pic";
make it so
$targetfile=$uploaddir.$new_pic;