Jump to content

[SOLVED] This query is killing me...


Gayner

Recommended Posts

So essentially while im uploading, i want to run WHERE file_path = {$_FILES["file"]["name"]}

 

 

So here it goes:

 

mysql_query("INSERT INTO `la_items` (`pack_id` ,`file_path`) VALUES (
'". mysql_real_escape_string('5') ."',
'{$_FILES["file"]["name"]}');");

      move_uploaded_file($_FILES["file"]["tmp_name"],
      "packs/cimage/" . $_FILES["file"]["name"]);
  $result = mysql_query("SELECT item_id FROM la_items WHERE file_path = '{$_FILES["file"]["name"]}' ")
or die(mysql_error());
while($row = mysql_fetch_array( $result ))  {

}


mysql_query("INSERT INTO `la_items_purchased` (`item_id` ,`pack_id` ,`group_id` ,`user_id` ,`points_spent`,`purchase_date`) VALUES (
'". mysql_real_escape_string($row[item_id]) ."',
'". mysql_real_escape_string('5') ."',
'". mysql_real_escape_string('test') ."',
'". mysql_real_escape_string($user_info[user_id]) ."',
'". mysql_real_escape_string('test') ."',
'test');");
      echo "Stored in: " . "packs/cimage/" . $_FILES["file"]["name"];
  echo $row['item_id'];
  echo "hey";

 

 

 

 

So right here is when im trying to grab the item_id while im uploading my .gif

 

move_uploaded_file($_FILES["file"]["tmp_name"],
      "packs/cimage/" . $_FILES["file"]["name"]);
  $result = mysql_query("SELECT item_id FROM la_items WHERE file_path = '{$_FILES["file"]["name"]}' ")
or die(mysql_error());
while($row = mysql_fetch_array( $result ))  {

}

 

but for somereason when i put that into my query below it:

 

 mysql_query("INSERT INTO `la_items_purchased` (`item_id` ,`pack_id` ,`group_id` ,`user_id` ,`points_spent`,`purchase_date`) VALUES (
'". mysql_real_escape_string($row[item_id]) ."',
'". mysql_real_escape_string('5') ."',
'". mysql_real_escape_string('test') ."',
'". mysql_real_escape_string($user_info[user_id]) ."',
'". mysql_real_escape_string('test') ."',
'test');");
      echo "Stored in: " . "packs/cimage/" . $_FILES["file"]["name"];
  echo $row['item_id'];
  echo "hey";

 

The $row['item_id']  isn't coming out from the WHERE claus to $_FILES["file"]["name"]

 

Help anything thanks!..

Link to comment
https://forums.phpfreaks.com/topic/175581-solved-this-query-is-killing-me/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.