grlayouts Posted June 22, 2007 Share Posted June 22, 2007 i have an upload script that uploads the file fine. however it will not add the image to the database. i have placed the bit of code below, any ideas? { move_uploaded_file($_FILES["file"]["tmp_name"], 'uploads/'. $_FILES["file"]["name"] .''); echo "Stored in: " . "uploads/" . $_FILES["file"]["name"]; print '<p>'.$type.'</p>'; mysql_query("insert into images (user, image) values('$stat[id]','. $_FILES["file"]["name"] .')") or die("Could not update database."); } Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/ Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 ne1? Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280732 Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 Its not a good idea to store images in db.Store a link to image in db. What specific error u getting. Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280734 Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 none. it is the link i want to save in the database?? but the image uploads fine. just not the database part? Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280739 Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 It mean u want to store a link in db for that picture. So assign ur file name to a variable and then put in ur query to store. Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280741 Share on other sites More sharing options...
grlayouts Posted June 23, 2007 Author Share Posted June 23, 2007 why would i need to assign when i can use images/uploads/$Files[name].$files[extension] ?? Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280743 Share on other sites More sharing options...
mmarif4u Posted June 23, 2007 Share Posted June 23, 2007 i mean assign it like this its easy to handle code. $fileName = $_FILES['filename']['name']; Than insert it like this: $query = "INSERT INTO upload (name)VALUES ('$fileName')"; Link to comment https://forums.phpfreaks.com/topic/56684-upload-problem-with-database/#findComment-280748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.