REQ: Help SQL Code
Hay All,
1st off I am sorry if this is posted in the wrong place so plz dont flame me. I am new to the forums I did search but could not find.
Any how this is my problem I am makeing a small site...
Now when members sine up ther account is made but I get this error...
=====================================
Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in /home/XXXXX/htdocs/modules/mod_register.php on line 46
Sorry, but there is a problem with our scripts!
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1
UPDATE members SET highest_rank=3 WHERE id= LIMIT 1
=====================================
The SQL in the PHP is...
=====================================
$username = trim(stripslashes($_POST["username"]));
$password = stripslashes($_POST["password"]);
$email = strtolower(trim(stripslashes($_POST["email"])));
$username = preg_replace("/\s{2,}/", ' ', $username);
$db->query( "INSERT INTO members ( username, password, email, ".
"joined, last_updated ) VALUES ( '".
$db->escape( $username )."', '".md5($password)."', '".
$db->escape( $email )."', UNIX_TIMESTAMP(), UNIX_TIMESTAMP() )" );
$insert_id = mysql_insert_id();
$db->query( "SELECT * FROM members" );
$rank = $db->countRows();
$db->query( "UPDATE members SET highest_rank=".$rank." WHERE id=".$insert_id." LIMIT 1" );
$db->query( "UPDATE sessions SET member_id=".$insert_id.", admin='0' WHERE id='".
session_id()."' LIMIT 1" );
$ref = htmlentities( stripslashes( $_POST["ref"] ) );
$ref = empty( $ref )? "/" : $ref;
?>
=====================================
And this is the Databace SQL....
=====================================
CREATE TABLE IF NOT EXISTS `members` (
`id` bigint(20) NOT NULL auto_increment,
`email` varchar(250) collate latin1_general_ci NOT NULL default '',
`forename` varchar(100) collate latin1_general_ci NOT NULL default '',
`surname` varchar(100) collate latin1_general_ci NOT NULL default '',
`username` varchar(32) collate latin1_general_ci NOT NULL default '',
`password` varchar(32) collate latin1_general_ci NOT NULL default '',
`admin` int(1) NOT NULL default '0',
`admin_permissions` text collate latin1_general_ci NOT NULL,
`plays` bigint(20) NOT NULL default '0',
`favourite` int(4) NOT NULL default '0',
`gender` enum('m','f','u') collate latin1_general_ci NOT NULL default 'u',
`bday_day` int(2) NOT NULL default '0',
`bday_month` int(2) NOT NULL default '0',
`bday_year` int(4) NOT NULL default '0',
`country` varchar(100) collate latin1_general_ci NOT NULL default '0',
`plays_detailed` text collate latin1_general_ci NOT NULL,
`joined` int(10) NOT NULL default '0',
`avatar` bigint(20) NOT NULL default '0',
`last_updated` int(10) NOT NULL default '0',
`last_game` int(4) NOT NULL default '0',
`buddies` text collate latin1_general_ci NOT NULL,
`highest_rank` bigint(20) NOT NULL default '0',
`sexuality` varchar(20) collate latin1_general_ci NOT NULL default '',
`status` varchar(20) collate latin1_general_ci NOT NULL default '',
`about_me` text collate latin1_general_ci NOT NULL,
`body` varchar(30) collate latin1_general_ci NOT NULL default '',
`ethnicity` varchar(100) collate latin1_general_ci NOT NULL default '',
`religion` varchar(50) collate latin1_general_ci NOT NULL default '',
`smoke` varchar(100) collate latin1_general_ci NOT NULL default '',
`drink` varchar(100) collate latin1_general_ci NOT NULL default '',
`drugs` varchar(100) collate latin1_general_ci NOT NULL default '',
`occupation` varchar(150) collate latin1_general_ci NOT NULL default '',
`custom_fields` text collate latin1_general_ci NOT NULL,
`images` text collate latin1_general_ci NOT NULL,
`location` varchar(250) collate latin1_general_ci NOT NULL default '',
`last_play` int(10) NOT NULL default '0',
`profile_views` bigint(20) NOT NULL default '0',
`notepad` text collate latin1_general_ci NOT NULL,
`member_status` int(11) NOT NULL default '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci PACK_KEYS=0 AUTO_INCREMENT=8 ;
==========================================
I know this is alot for a 1st post but I did not know what else to do.
Thanks so much for takeing the time to read this and I hope someone out ther can help me.
Thanks again,
Shell.