Shockhazard30 Posted February 10, 2010 Share Posted February 10, 2010 These are the errors I am getting and I think the permissions 5 5 5 are part of the problem, however these are on my own server and I am not sure how to change them and I don't even know where to look for the problem with "Column count doesn't match value count at row 1" Warning: move_uploaded_file(http://127.0.0.1/nanrecipes/recphotoluckiepumpkin.JPG): failed to open stream: HTTP wrapper does not support writeable connections in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\nanrecipes\nanform1.php on line 37 Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\temp\php46.tmp' to 'http://127.0.0.1/nanrecipes/recphotoluckiepumpkin.JPG' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\nanrecipes\nanform1.php on line 37 Sorry, there was a problem uploading your file.Column count doesn't match value count at row I will post the source code as well <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <?php //This is the directory where images will be saved $target = "http://127.0.0.1/nanrecipes/recphoto"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $submitter=$_POST['pname']; $dname=$_POST['dname']; $recpic=($_FILES['photo']['name']); $recorigin=$_POST['recorigin']; $recbkgnd=$_POST['recbkgnd']; $recingrd=$_POST['recingrd']; $recinst=$_POST['recinst']; $recnotes=$_POST['recnotes']; // Connects to your Database mysql_connect("localhost", "root", "pass") or die(mysql_error()) ; mysql_select_db("chapter9") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO recipe (pname,dname,recorigin,recbkgnd,recingrd,recinst,recnotes,recpic) VALUES ('$submitter', '$dname', '$recpic', '$recorigin', '$recbkgnd' '$recingrd', '$recinst', '$recnotes')") ; //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."; echo (mysql_error()); } ?> <form method="post" action="nanform1.php" enctype="multipart/form-data"> <table> <tr> <th> Create a new recipe. </th> </tr> <tr> <td> Name of person submitting recipe: </td> <td> <input type="text" name="submitter"/> </td> </tr> <tr> <td> Name of the dish: </td> <td> <input type="text" name="Dish"/> </td> </tr> <tr> <td> Recipe Origin </td> <td> <input type="text" name="recorigin"/> </td> </tr> <tr> <td> <center>Background info on recipe<br> <textarea name="recbckgrnd" rows = "5" cols = "30"></textarea></center> </td> <td> <center>Ingredients please seperate them with a comma Ex. 1 tsp salt, 2 cups flour, ...<br> <textarea name="recingredients" rows = "5" cols = "30"></textarea></center> </td> </tr> <tr> <td> <center>Instructions for preparing Recipe<br> <textarea name="recinst" rows = "5" cols = "30"></textarea></center> </td> <td> <center>Any other notes or info about recipe<br> <textarea name="recnotes" rows = "5" cols = "30"></textarea></center> </td> </tr> <tr> <td colspan = 2> Please Upload a Photo of the dish. </td> </tr> <tr> <td> Photo: </td> <td> <input type="hidden" name="size" value="3500000"> <input type="file" name="photo"> </td> </tr> <tr> <td colspan = 2> <input TYPE="submit" name="upload" title="Add data to the Database" value="Add Recipe"/> </td> </tr> </table> </form> </BODY> </HTML> Quote Link to comment https://forums.phpfreaks.com/topic/191608-file-upload-error-and-mysql-column-count-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 10, 2010 Share Posted February 10, 2010 You cannot use a URL as the target/destination of a file write operation (unless you are using FTP.) You must use a file system path. The second error is fairly self explanatory, the number of columns and the number of data values don't match in your query and since we don't know if the list of columns or the list of data values is correct, it would be up to you to determine which part of the query to fix. Quote Link to comment https://forums.phpfreaks.com/topic/191608-file-upload-error-and-mysql-column-count-error/#findComment-1010030 Share on other sites More sharing options...
sader Posted February 10, 2010 Share Posted February 10, 2010 try $_FILES['uploadedfile']['name'] into this $_FILES['photo']['name']) Quote Link to comment https://forums.phpfreaks.com/topic/191608-file-upload-error-and-mysql-column-count-error/#findComment-1010031 Share on other sites More sharing options...
Shockhazard30 Posted February 10, 2010 Author Share Posted February 10, 2010 Thanks, I changed the path and fixed the file upload and rewrote the query and that fixed the column count problem Quote Link to comment https://forums.phpfreaks.com/topic/191608-file-upload-error-and-mysql-column-count-error/#findComment-1010108 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.