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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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