Jump to content

[SOLVED] INSERT & UPDATE from SELECT help


jason1987

Recommended Posts

why isn't my insert and update working - i know the select statement returns the correct value as i have echoed it and used mysql to return its value

Its the ressimlink bit i think

 

$simlink = "SELECT simparentid FROM itsiminfo JOIN itequip ON itequip.equid = itsiminfo.simparentid WHERE itsiminfo.equid = '$equid' ";		 // for sim 
	//echo $simlink; 
	$ressimlink = mysql_query($simlink);
	$querytransins2 = " INSERT INTO itequiptransfers (equid, fromuserid, touserid) VALUES ('".$ressimlink."', '".$fromuserid."', '".$touserid."')";
  		$resulttransins2 = mysql_query($querytransins2);
    	$equins2 = "UPDATE itequip SET equuser='$touserid' WHERE equuser='$fromuserid' AND equid= '$ressimlink'";
    	$resultequins2 = mysql_query($equins2);

Link to comment
https://forums.phpfreaks.com/topic/73623-solved-insert-update-from-select-help/
Share on other sites

$ressimlink holds the resource id of the returned result set, not the simparentid.

 

<?php

$ressimlink = mysql_query($simlink);
$simparentid = mysql_result ($ressimlink, 0, 0);

 

Use $simparentid in the other queries.

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.