Query problem again

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
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
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back