tags:

views:

126

answers:

1

Greetings! Been staring at this all day and can't seem to figure out why my update statement fails to update the field 'image_filename':

  $fileName = $_FILES['image_filename'];
 if($fileName["name"] <> ""){
  $imageFile = $fileName['name']; 
  $destination = "../../../../assets/resources/images/".$fileName['name'];
  move_uploaded_file($fileName['name'], $destination);
 } 


  $updateSQL = sprintf("UPDATE content SET image_filename='$imageFile' WHERE id=%s",
     GetSQLValueString($_POST['resource_id'], "int"));

mysql_select_db($database_conn_talent, $conn_talent); $Result1 = mysql_query($updateSQL, $conn_talent) or die(mysql_error());

Can a SQL pro tell me what I"m missing? Much thanks in advance for your feedback!

A: 

You appear to be building a query, but never executing it. Also, Drupal'll handle all the sprintfing for you, if you let it.

$query = "UPDATE content SET image_filename='$imageFile' WHERE id=%i";
db_query($query, $_POST['resource_id']);
ceejayoz
My bad. I didn't paste that part of my code (updated now). Thanks!
Jason Sweet
If this is in Drupal, why are you rolling your own database connections? Drupal handles all that for you, what you're doing is redundant.
ceejayoz
Hi. Its not Drupal. Sorry for the confusion.
Jason Sweet
I'm going to remove the Drupal tag from your question, then. Why did you include it?
ceejayoz
It was inadvertent.
Jason Sweet