473,735 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

issues writing a image path to mysql database

Hi

I am having trouble writing the file path of a image to the
database,also for some reason it is not uploading the images, anyone
have any ideas?

the code is below:

if($_POST[Submit] == 'Submit')
{
$target_path = "../reviewImages/";
$target_path = $target_path . basename(
$_FILES['uploadFile']['name']);
if(move_uploade d_file($_FILES['uploadFile']['tmp_name'],
$target_path)) {
echo "The file ". basename( $_FILES['uploadFile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try
again!";
}
echo $target_path;

$text = $_POST[text];
$press = $_POST[press];
$logo = "reviewImag es/".basename( $_FILES['uploadFile']['name']);
echo $logo;
$title = $_POST[title];
$author = $_POST[author];
$date = $_POST['date'];

$sql = "INSERT into reviews (press, title, author, date, text,
imagePath) VALUES ('$press', '$title', '$author', '$date', '$text',
'$logo')";
mysql_query($sq l) or die(mysql_error ());

echo "Informatio n added to the reviews table";
}

cheers

Glenn
Oct 3 '06 #1
1 2369
Check if you're using enctype="multip art/form-data" on the form. More
info here:

http://us3.php.net/features.file-upload

Example:

<form enctype="multip art/form-data" action="post.ph p" method="POST">
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>

Glenn Coyle wrote:
Hi

I am having trouble writing the file path of a image to the
database,also for some reason it is not uploading the images, anyone
have any ideas?

the code is below:

if($_POST[Submit] == 'Submit')
{
$target_path = "../reviewImages/";
$target_path = $target_path . basename(
$_FILES['uploadFile']['name']);
if(move_uploade d_file($_FILES['uploadFile']['tmp_name'],
$target_path)) {
echo "The file ". basename( $_FILES['uploadFile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try
again!";
}
echo $target_path;

$text = $_POST[text];
$press = $_POST[press];
$logo = "reviewImag es/".basename( $_FILES['uploadFile']['name']);
echo $logo;
$title = $_POST[title];
$author = $_POST[author];
$date = $_POST['date'];

$sql = "INSERT into reviews (press, title, author, date, text,
imagePath) VALUES ('$press', '$title', '$author', '$date', '$text',
'$logo')";
mysql_query($sq l) or die(mysql_error ());

echo "Informatio n added to the reviews table";
}

cheers

Glenn
Oct 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1466
by: A | last post by:
Hi everyone I was working on a php script to display images and I am running into problems. My problems are when I execute the query to thumb path it won't display the image/s. Anyhelp is alway's appreciated I have a mysql table with the following structure
9
3397
by: DaRemedy | last post by:
Hiya, Can anyone kindly help me to get started in creating a PHP/MySQL image gallery, it doesn't have to be anything fancy, just something that automatically reads the images in the folder and displays it. Cheers DaRemedy
3
11762
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
2
2275
by: david | last post by:
Hi, I have asp pages running from a MySQL database. I have placed a path in the required field (although not quite sure on the correct format). My asp page is just displaying the text path instead of the image. I'm using response.write. The Folder is called : images
1
1169
by: Nikki | last post by:
I have a database, front and data backend, I have written in Access 97 and it has been chugging along for the last 6 years all with constant updates except for the last year with almost no wupdates. Anyhow, the database backend that stores all the data is now 225Mb in size and needs to be compacted but some table issues stop me from doing this. Both the tables, tblClient and tblClientItems, have multiple memo fields and I believe the...
4
1662
by: jackpod | last post by:
Hi, I have been trying to write an image to a database table BLOB field in MySQL but when I try to retrieve the image to display it, it shows as being empty. Are there any special considerations I need to take into account when reading and writing images to a DB? Thanks.
3
6732
by: gsoguerrilla | last post by:
Hi, I have limited knowledge in php and I am having trouble with uploading an image to a remote directory and resizing it if it's larger and renaming it to a unique id, while at the same time I would like to create a record in mysql database. I've tried to find some tutorials but I've had trouble finding any good ones. Wondering if anybody has good examples or link to a good tutorial. Thanks in advance.
1
2507
by: swetha123 | last post by:
hello, Can any one please tell me I am Using php,Mysql,CSS to build my site In my database i have small images and large images i am show the small images to the right of the main container now i need to show the large image to left side when user clicks on these small images but when i click on the images it is showing the large image in the new browser
3
2511
by: swetha123 | last post by:
hello, Can any one please tell me I am Using php,Mysql,CSS to build my site In my database i have small images and large images i am show the small images to the right of the main container now i need to show the large image to left side when user clicks on these small images but when i click on the images it is showing the large image in the new browser
0
8784
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9199
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6049
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4821
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.