2K Posted June 10, 2009 Share Posted June 10, 2009 if($_GET['New'] != ""){ if($_GET['New'] != $user_class->id){ $New = mysql_query("SELECT * FROM `users` WHERE `id`='".$_GET['New']."'"); $result = mysql_query("UPDATE `group` SET `leader` = ".$New." WHERE `id`='".$_GET['New']."'"); NOT ALL THE CODE $_GET['New'] gets me the user id... Basically, what I want is for the username for the id to be updated into the group table and make 'leader' equal the username. No matter what I try to do, it isn't working... Link to comment https://forums.phpfreaks.com/topic/161732-solved-sql-with-_get-issue/ Share on other sites More sharing options...
Ken2k7 Posted June 11, 2009 Share Posted June 11, 2009 Try $result = mysql_query("UPDATE `group` SET leader = '".$New."' WHERE id=".$_GET['New']); Link to comment https://forums.phpfreaks.com/topic/161732-solved-sql-with-_get-issue/#findComment-853530 Share on other sites More sharing options...
2K Posted June 11, 2009 Author Share Posted June 11, 2009 Even that doesn't work...the username is still not getting into the group table. Link to comment https://forums.phpfreaks.com/topic/161732-solved-sql-with-_get-issue/#findComment-853806 Share on other sites More sharing options...
PFMaBiSmAd Posted June 11, 2009 Share Posted June 11, 2009 SELECT queries return a result resource when the query succeeds, or FALSE if the query fails. In order to get any data from a result resource you must use one of the mysql_fetch_xxxxxx() functions. $New is not anything that you can directly put into another query. Link to comment https://forums.phpfreaks.com/topic/161732-solved-sql-with-_get-issue/#findComment-853812 Share on other sites More sharing options...
2K Posted June 11, 2009 Author Share Posted June 11, 2009 php if($_GET['New'] != ""){ if($_GET['New'] != $user_class->id){ $New = mysql_query("SELECT `user` FROM `users` WHERE `id`='".$_GET['New']."'"); $row = mysql_fetch_object($New); $result = mysql_query("UPDATE `group` SET leader = '".$row->user."' WHERE id=".$_GET['id'].""); After a bit of tinkering with the code...I got it. If only I had known SELECT queries needed a mysql_fetch_xxxxxx() function. Thanks! Link to comment https://forums.phpfreaks.com/topic/161732-solved-sql-with-_get-issue/#findComment-854122 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.