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'>
ERROR WHILE FECHING IMAGES
Moderator: General Moderators
ERROR WHILE FECHING IMAGES
Last edited by pickle on Thu Jan 21, 2010 10:52 am, edited 1 time in total.
Reason: Removed database credentials
Reason: Removed database credentials
- flying_circus
- Forum Regular
- Posts: 732
- Joined: Wed Mar 05, 2008 10:23 pm
- Location: Sunriver, OR
Re: ERROR WHILE FECHING IMAGES
the blackslash is an escaping character. try modifying this line to:
See: http://www.php.net/manual/en/language.types.string.php
Code: Select all
$imgdir = "..\\blob\\uploads\\";
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: ERROR WHILE FECHING IMAGES
You might not want to show your password and username on an open forum.
Re: ERROR WHILE FECHING IMAGES
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
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
please i need your help on this.why cant it load the images
.
.
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: ERROR WHILE FECHING IMAGES
Make sure the path to the images is right, and do it with slashes, not with backslashes