Jump to content

file upload error and mysql column count error


Shockhazard30

Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.