Unstoppable Domains

Query problem again

Spaceship 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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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
•••
$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
•••
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
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back