Forum Moderators: coopster
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
Array do's and don'ts [php.net]
mysql_query() [php.net] strings should not end with a semicolon.
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
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.
<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>