Page 1 of 1

ERROR WHILE FECHING IMAGES

Posted: Wed Jan 20, 2010 5:43 pm
by davies
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'>

Re: ERROR WHILE FECHING IMAGES

Posted: Wed Jan 20, 2010 6:10 pm
by flying_circus
the blackslash is an escaping character. try modifying this line to:

Code: Select all

 
$imgdir = "..\\blob\\uploads\\";  
 
See: http://www.php.net/manual/en/language.types.string.php

Re: ERROR WHILE FECHING IMAGES

Posted: Thu Jan 21, 2010 10:32 am
by Bill H
You might not want to show your password and username on an open forum.

Re: ERROR WHILE FECHING IMAGES

Posted: Tue Feb 02, 2010 5:05 am
by davies
thanks so much it actually worked out that is is cleared the error but the image did not display. could it be the directory where the images are loaded. the default in wamp is c:/wamp/tmp(php.ini file). but i specified ..\blob\uploads\. forgive me for being a novice.
this is the output it gives

Warning: move_uploaded_file(..\blob\uploads\office 004.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\private\check_image.php on line 11

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\phpD.tmp' to '..\blob\uploads\office 004.jpg' in C:\wamp\www\private\check_image.php on line 11
Here is your pic

please help .thanks

Re: ERROR WHILE FECHING IMAGES

Posted: Fri Feb 05, 2010 11:48 am
by davies
please i need your help on this.why cant it load the images
.

Re: ERROR WHILE FECHING IMAGES

Posted: Fri Feb 05, 2010 1:44 pm
by klevis miho
Make sure the path to the images is right, and do it with slashes, not with backslashes