i dont know what is the issue and it is not giving me a error in the error_log.

i have a variable that collects from the url to be put into the query were the DB field would go. i know that is is the part that is not working cause right after this is the part where is moves the uploaded file to the proper place. and yes it does have a DB connection at the top. and no when i go to the file it does not give me a error read out either and i do have errors print out

$query = "UPDATE properties SET $imagenum='$filename' WHERE id='$id' ";
	
	$result = mysql_query($query);

i have even tried

$query = "UPDATE properties SET ".$imagenum."='$filename' WHERE id='$id' ";
	
	$result = mysql_query($query);

thanks in advance.

Make your you have your dbs and tables spelt right

After setting $query, print its value to the screen, so you can see if it is correct. If it looks correct, copy and paste the query into phpmyadmin (or whatever tool you use to manipulate your database - TOAD for Oracle for example), and see what the result is. This should help you find the cause of the problem.

it is spelled right thats the problem.

this is the error that i get and i dont understand it. did it with both of the versions....

from phpmyadmin
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$query = "UPDATE properties SET $imagenum='$filename' WHERE id='$id' "' at line 1.

AAAAAHHHHHHH *head explodes*

it is spelled right thats the problem.

confirm this by printing out the contents of $query to the screen.

I imagine that you are expecting to see the variables $imagenum, $filename and $id to be expanded to their current contents (and I would expect so too), which means that you should see that $query contains something like UPDATE properties SET NNNN='FFF' WHERE ID='III' - this is assuming $imagenum contains "NNNN", $filename contains "FFF" and $id contains "III".

If the contents of $query then seem to be correct, paste it into phpadmin and see what result you get.

The error message you have shown seems to imply that you are sending the text $query = "UPDATE properties SET $imagenum='$filename' WHERE id='$id' " directly to the MySQL engine. Clearly this is not what you want.

Additional thought: you said that the error came from phpadmin, in which case you must have pasted into it the whole line starting from $query= ....

That makes no sense, as phpmyadmin has no knowledge of your PHP code. What you need to paste into phpmyadmin is the contents of the string $query, the actual contents just before you call the statement $result = mysql_query($query);

coming back to this issue i cant solve im going to post the whole code that i am running and hopefully i can figure it out

if (!empty($_FILES)) {
		$result = mysql_query("SELECT * FROM properties WHERE id='$id' ");
	while ($myrow = mysql_fetch_array($result))
	{	
$remove = $myrow[$imagenum];
@unlink('images/properties/'.$remove);
	}	

	
	
	
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
	
	$file = $_FILES['Filedata']['name'];
			
			  $filename = $tempFile;
			  $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
			  $ext = substr(strrchr($file, "."), 1);
			  $ext2 = '.'.$ext;

			  $randName = md5(rand() * time());
			  $filename = $randName . '.' . $ext;
			  
			  $query2 = "UPDATE properties SET $imagenum='$filename' WHERE id='$id'";
		$result2 = mysql_query($query2);
			  
			  
			  $file2 = str_replace($ext2, '', $file);                

						
	$targetFile =  str_replace('//','/',$targetPath) . $filename;
	
		
		move_uploaded_file($tempFile,$targetFile);
		
		
		echo "1";
	}

It would be easier to help you if you could give me the following information: What is the actual value of the query just before you sent it to MySql?

From your previous postings, I'm guessing that the error occurs at line 25 above. Insert after line 25 the code print("<br /><pre>$query2</pre><br />"); then post back the result.

Also, the database schema of the properties table might be of use.

oh wow a schema for the db well i will just put the necessary info

--Properties--
company_id
employee_id
image1
image2
image3
image4
image5
image6
image7
image8
image9
image10

also one thing that is the problem is that i am using a flash uploader called uploadify. idk if that would make a difference.
but i was able to test the query out by adding the var in the url and this is what i would come up with

UPDATE properties SET image1='a445b4ff5fa47c2adc960209980e63b4.jpg' WHERE id='155'

Well no, of course I didn't want the schema for the whole db! :) - that snippet is fine, I just wanted to be sure that your query was updating a field which did indeed exist on the database. That snippet was fine.

So the query looks valid, the next thing to try is paste it into phpMyAdmin, and see what the result is.

And another thing you could try, put the field name in single quotes, i.e. $query2 = "UPDATE properties SET '$imagenum'='$filename' WHERE id='$id'"; - it's possible that something along the line from your PHP code to the MySql engine is converting the field name to upper-case.

Additional thought - I don't see the field "id" in the schema....

ya the id field was a given in my head. i just forgot to write it.

all the code you see there is the only thing in that file. so i know its not turning it to upper-case.

ya the id field was a given in my head. i just forgot to write it.

all the code you see there is the only thing in that file. so i know its not turning it to upper-case.

How do you know, have you tried it? (put the field names in quotes, that is).

How do you know, have you tried it? (put the field names in quotes, that is).

oh ya i forgot to say that too. i did put them in quotes. for some reason it doesn't seem to be uploading either anymore. might you have a suggestion on a good flash uploader

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.