Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Query problem again

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch
Impact
19
Hey
Whats wrong wid this code now
PHP:
@mysql_select_db($database) or die( "Unable to select database");
$query= 'INSERT INTO `user` (`id`, `username`, `pass`, `email`, `lastlogin`, `health`, `country`, `level`, `armysize`) VALUES (NULL, $username, $pass, $email, NULL, \'100\', $country, \'1\', \'1\');';
mysql_query($query);

its not giving any error but instead of adding whats in $username its adding the "$username" into the database..
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Change it too this.

PHP:
 @mysql_select_db($database) or die( "Unable to select database");
$query= "INSERT INTO user ('username', 'pass', 'email', 'lastlogin', 'health','country', 'level', 'armysize') VALUES ($username, $pass, $email, NULL, \'100\', $country, \'1\', \'1\')";
mysql_query($query);

All use " (double quotes) while setting the mysql query. Also ` are extremely slow. So use ' insted.

" = text & variables
' = text (variables are thought of as text)

- Steve
 
0
Close
$query= "INSERT INTO `user` (`id`, `username`, `pass`, `email`, `lastlogin`, `health`, `country`, `level`, `armysize`) VALUES (NULL, $username, $pass, $email, NULL, \'100\', $country, \'1\', \'1\')";

That should do it...I think.
 
0
Close
PHP:
@mysql_select_db($database) or die("Unable to select database"); 
$query= "INSERT INTO user(id, username, pass, email, lastlogin, health, country, level, armysize) VALUES (NULL, '$username', '$pass', '$email', NULL, 100, '$country', 1, 1)";
mysql_query($query);

That'll do it.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Member card: see how many threads a member started
The member card now shows a Threads number, right after Posts. The member card is the box that opens when you point at a name. Profile...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back