Jump to content

I can guarantee this is a stupid question, but...


habook2

Recommended Posts

How do I insert a variable's value into a table?

Like:

mysql_query ('INSERT INTO `users` (`username`, `password`, `userid`) VALUES (\'I WANT A VARIABLE HERE\', \'I WANT A VARIABLE HERE\', NULL);)

When I just tried using the variables, they would actually add "$username" and "$pass" as the username and password.
problem is your quotes. do it like this:
[code]
mysql_query("insert into users (username,password,userid) values ('$username','$password','$userid')");
[/code]
or, if your userid is auto-generated by sql then don't include it in that list:
[code]
mysql_query("insert into users (username,password) values ('$username','$password')");
[/code]

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.