i have a script here that adds info to a table. now it works fine with one table, but when i changed the variables so it would work with my other table it does not. i know the problem MUST be with how i made the table, meaning the settings/properties. cuz i tried it with a table in which i only gave "username varchar(50)" properties. and it worked. so heres my script and heres the table creation code. hope you can help. im pretty new with mysql so im not sure about these settings i gave it, which is probably why im gettin errors. a link to a tutorial for learning all these settings would be a big help too . thank you
create table users (
userid int not null unsigned auto_increment primary key,
user varchar(50),
password varchar(50,
email varchar(50)
);
and now heres the script.. it doesnt throw an error, it tells me it is successful. but no data gets entered into table =/.----
if ($user) {
mysql_connect("localhost", "user", "pass") or die ("Problem connecting with database");
$query = "insert into user values ('$user')";
$result = mysql_db_query("box", $query);
echo "data inserted. new table: <br><p></p>";
$query = "SELECT * FROM user";
$result = mysql_db_query("box", $query);
if ($result) {
while ($r = mysql_fetch_array($result)) {
$user = $r["user"];
When I read that insert statement, I can see that you are inserting into a table called "user" and I can see you want to insert the value "$user", but I can't see which of the fields you want to insert "$user" into. Do you think that since you have a field called "user" that mysql somehow knows that it should insert $user into "user" and not into "userid", "password", or "email" ?
Bookmarks