daniel28138 Posted January 19, 2014 Share Posted January 19, 2014 Okay the people that come here have been amazing. I have another issue though. I think I've learned a lot and got this almost working, but I"m getting the "500 Internal Server Error" with it. I'm trying to add an image upload directory and etc etc. I have the field added "photo" in the database at the end. Everything was working till I added the image upload. Here is what I have... *Note* I have the folder to store the image permissions set to 777 My HTML page with the form is: <html> <head> <title>Band Review Entry</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF"> <b><font face="Verdana, Arial, Helvetica, sans-serif">BAND REVIEW </font></b> <form action="connectionband.php" method="post" enctype="multipart/form-data" /> <p><font face="Verdana, Arial, Helvetica, sans-serif"><b>Name</b></font>: <br> <input type="text" name="Name" /> </p> <p><font face="Verdana, Arial, Helvetica, sans-serif"><b>Link</b></font>: <br> <input type="text" name="website" /> </p> <p><b><font face="Verdana, Arial, Helvetica, sans-serif">Description</font></b>: <br> <textarea name="Description" cols="100" rows="25"></textarea> </p> <p><font face="Verdana, Arial, Helvetica, sans-serif"><b>Photo:</b></font> <input type="hidden" name="size" value="350000"> <input type="file" name="photo"> </p> <p> <input type="submit" value="SEND IT" /> </p> </form> </body> </html> And my PHP page to get the info and send etc, is: <?php // Connects to your Database info here //This is the directory where images will be saved $target = "http://www.inthisreview.com/bandsreview/bandimages/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $Name=$_POST['Name']; $website=$_POST['website']; $Description=$_POST['Description']; $timestamp=$_POST['timestamp']; $photo = mysql_real_escape_string(htmlspecialchars($_FILES['photo']['name'])); //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo) VALUES ('$Name', '$website', '$Description', '$timestamp','$photo') ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Quote Link to comment Share on other sites More sharing options...
denno020 Posted January 19, 2014 Share Posted January 19, 2014 (edited) I'm not sure if it's just a problem with copying and pasting your code here, but can you see in your PHP, the highlighting isn't working correctly.. That is because you've missed a closing double quote and ending bracket.. Look at your mysql_query(...... line, and find where you're missing the required characters. Denno Edited January 19, 2014 by denno020 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted January 19, 2014 Share Posted January 19, 2014 the 500 server errors you have been getting (this and the last thread) are due to php fatal parse or runtime errors (there's no complete response back from the server.) you can get php to help you find what is causing the error by setting php's error_reporting setting to E_ALL and display_errors to ON in your php,ini file. Quote Link to comment Share on other sites More sharing options...
daniel28138 Posted January 19, 2014 Author Share Posted January 19, 2014 (edited) I updated but still getting the same error... here is the update. Mac_Gyver... thanks for the tip, but I don't know how to do that or where the php.ini file is? <?php // Connects to your Database mysql_connect("website", "user", "pass") or die(mysql_error()) ; mysql_select_db("bands") or die(mysql_error()) ; //This is the directory where images will be saved $target = "http://www.inthisreview.com/bandsreview/bandimages/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $Name=$_POST['Name']; $website=$_POST['website']; $Description=$_POST['Description']; $timestamp=$_POST['timestamp']; $photo = mysql_real_escape_string(htmlspecialchars($_FILES['photo']['name'])); //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo)"); VALUES ('$Name', '$website', '$Description', '$timestamp','$photo') ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file " . basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Edited January 19, 2014 by daniel28138 Quote Link to comment Share on other sites More sharing options...
denno020 Posted January 19, 2014 Share Posted January 19, 2014 (edited) This is wrong //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo)") VALUES ('$Name', '$website', '$Description', '$timestamp','$photo') ; This is right //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo) VALUES ('$Name', '$website', '$Description', '$timestamp','$photo')") ; You'll notice that you put the double quote and bracket in the wrong place... Edited January 19, 2014 by denno020 Quote Link to comment Share on other sites More sharing options...
daniel28138 Posted January 19, 2014 Author Share Posted January 19, 2014 Hmmm Thanks for the correction. Yes I see what you meant. But I'm still getting the error. Here is the whole thing I have now... <?php // Connects to your Database mysql_connect("site", "user", "pass") or die(mysql_error()) ; mysql_select_db("bands") or die(mysql_error()) ; //This is the directory where images will be saved $target = "http://www.inthisreview.com/bandsreview/bandimages/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $Name=$_POST['Name']; $website=$_POST['website']; $Description=$_POST['Description']; $timestamp=$_POST['timestamp']; $photo = mysql_real_escape_string(htmlspecialchars($_FILES['photo']['name'])); //Writes the information to the database mysql_query("INSERT INTO band (Name,website,Description,timestamp,photo) VALUES ('$Name', '$website', '$Description', '$timestamp','$photo')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file " . basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Quote Link to comment Share on other sites More sharing options...
daniel28138 Posted January 19, 2014 Author Share Posted January 19, 2014 UPDATE... it turns out there were permission issues with my hosting. Now I'm getting the error "Sorry, there was a problem uploading your file." Quote Link to comment Share on other sites More sharing options...
Barand Posted January 19, 2014 Share Posted January 19, 2014 Before doing anything with the uploaded file, check $_FILES['photo']['error'] value Quote Link to comment Share on other sites More sharing options...
daniel28138 Posted January 19, 2014 Author Share Posted January 19, 2014 Wow I really suck at this. I must have put that line all over my page and I'm just getting the 500 error. I think maybe it's time to admit defeat :/ I suppose not everyone is cut out to understand this. Does anyone know where there is this same thing that I have that actually works, that I can use? I've already been at this one page for a week every day and night. Quote Link to comment Share on other sites More sharing options...
daniel28138 Posted January 20, 2014 Author Share Posted January 20, 2014 The problem was the file path... I shrunk it down and it worked. Hope this thread can help someone else too Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.