ERROR WHILE FECHING IMAGES
Posted: Wed Jan 20, 2010 5:43 pm
HI i am new to this forum and to php. while trying to store images in my mysql database it gives this error
EXPECTING T_VARIABLE OR T_STRING ON LINE 11.Below is my code, please kindly help me with this .i have spent up to a month trying to solve this.
<?php
$link = mysql_connect("localhost","usernameXXX","passwordYYY") or die("Could not connect now");
mysql_select_db("wid") or die("Database not found");
$image_caption = $_POST['image_caption'];
$image_username = $_POST['image_username'];
$image_tmpname = $_FILES['image_filename']['name'];
$today = date("Y-m-d");
$imgdir = "..\blob\uploads\";
$imgname = $imgdir.$image_tmpname;
if(move_uploaded_file($_FILES['image_filename']['tmp_name'],$imgname))
{
list($width,$height,$type,$attr)= getimagesize($imgname);
switch($type)
{
case 1:
$ext = ".gif"; break;
case 2:
$ext = ".jpg"; break;
case 3:
$ext = ".png"; break;
default:
echo "Not acceptable format of image";
}
$insert = "insert into image_product (image_caption, image_username,date)
values ('$image_caption','$image_username','$today')";
$insertresults = mysql_query($insert) or die(mysql_error());
$last_pic_id = mysql_insert_id();
$newfilename = $imgdir.$last_pic_id.$ext;
rename($imgname,$newfilename);
}
?>
Here is your pic
<img src=\"uploads/<?php echo $last_pic_id.$ext; ?>\" align='center'>
EXPECTING T_VARIABLE OR T_STRING ON LINE 11.Below is my code, please kindly help me with this .i have spent up to a month trying to solve this.
<?php
$link = mysql_connect("localhost","usernameXXX","passwordYYY") or die("Could not connect now");
mysql_select_db("wid") or die("Database not found");
$image_caption = $_POST['image_caption'];
$image_username = $_POST['image_username'];
$image_tmpname = $_FILES['image_filename']['name'];
$today = date("Y-m-d");
$imgdir = "..\blob\uploads\";
$imgname = $imgdir.$image_tmpname;
if(move_uploaded_file($_FILES['image_filename']['tmp_name'],$imgname))
{
list($width,$height,$type,$attr)= getimagesize($imgname);
switch($type)
{
case 1:
$ext = ".gif"; break;
case 2:
$ext = ".jpg"; break;
case 3:
$ext = ".png"; break;
default:
echo "Not acceptable format of image";
}
$insert = "insert into image_product (image_caption, image_username,date)
values ('$image_caption','$image_username','$today')";
$insertresults = mysql_query($insert) or die(mysql_error());
$last_pic_id = mysql_insert_id();
$newfilename = $imgdir.$last_pic_id.$ext;
rename($imgname,$newfilename);
}
?>
Here is your pic
<img src=\"uploads/<?php echo $last_pic_id.$ext; ?>\" align='center'>