Jump to content

[SOLVED] SQL with $_GET issue


2K

Recommended Posts

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

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.

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!

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.