Gayner Posted September 26, 2009 Share Posted September 26, 2009 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 More sharing options...
Gayner Posted September 26, 2009 Author Share Posted September 26, 2009 HOLY SWEET SUGAR I FIXED IT changed it to mysql_insert_id()!!!! This is epic, thanks tho. Link to comment https://forums.phpfreaks.com/topic/175581-solved-this-query-is-killing-me/#findComment-925228 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.