Jump to content

Recommended Posts

It's a clan system for this game I run. First of all I insert a new record into `clans` and then grab the mysql_insert_id() so I can update their user record with what clan they're in. The first query works fine, but the only bit that works on the second query is setting `clan_since` to UNIX_TIMESTAMP(). Setting `clan` to mysql_insert_id() doesn't work and neither does setting `clan_confirmed` to '1'.

 

I echo()'d out the exact query too and it looks fine:

 

UPDATE `users` SET `clan` = '15', `clan_confirmed` = '1', `clan_since` = UNIX_TIMESTAMP() WHERE `id` = '101'

 

When I copy and paste that into phpMyAdmin it works absolutely fine... So seriously, what's wrong? It's probably going to be something simple but I've been trying to fix this for 3 hours now and my mind feels like it's gunna explode.

 

$db->query("INSERT INTO `clans` (`owner`, `tag`, `name`, `created_time`, `created_ip`, `created_user`) VALUES ('" . $db->escape($pun_user['id']) . "', '" . $db->escape($_POST['tag']) . "', '" . $db->escape($_POST['clan']) . "', UNIX_TIMESTAMP(), '" . $db->escape($_SERVER['REMOTE_ADDR']) . "', '" . $db->escape($pun_user['id']) . "')");

$id = $db->insert_id();

$db->query("UPDATE `users` SET `clan` = '" . $db->escape($id) . "', `clan_confirmed` = '1', `clan_since` = UNIX_TIMESTAMP() WHERE `id` = '" . $db->escape($pun_user['id']) . "'");

echo "UPDATE `users` SET `clan` = '" . $db->escape($id) . "', `clan_confirmed` = '1', `clan_since` = UNIX_TIMESTAMP() WHERE `id` = '" . $db->escape($pun_user['id']) . "'";

I showed in my first post that I echo()'d out the query and I copied and pasted it too. It isn't just that which isn't setting, `clan_confirmed` isn't being set to 1 either. :(

 

I've used $db->insert_id() in another page and it works fine.

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.