Jump to content

Been looking at this for far too long now...


Kryptix

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.

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.