Page 1 of 1

[SOLVED] mysql -> Problem with inserting data into databa

Posted: Tue Jul 05, 2005 10:05 am
by Terriator
Hey, this might be a nooby question, but it's better to ask right? ;p ..

Anyways, I have following;

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons VALUES ($userid)");
}
This code does not insert the data into the users_weapons unless I change it to;

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons VALUES ($userid,0,0,0)");
}
How do I make it only insert data into the first field and leave the others default, without specifying all the values?..If I have to specify all the fields, I'd have to change this code every single time I wanted to add a weapon into 'users_weapons'...

/Thanks in advance =)

EDIT: No problem....I figured it out...I'm foggy today...sorry

Re: [SOLVED] mysql -> Problem with inserting data into da

Posted: Thu Jul 07, 2005 10:20 pm
by harrisonad
You have to specify what column to fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
weapons (userid) VALUES ($userid)");
}]if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)&quote;);
}y what column to fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
p;quote;INSERT INTO users_weapons (userid) VALUES ($userid)");
}b2af]ery("INSERT INTO users_weapons (userid) VALUES ($userid)&quote;);
}amp;quote;INSERT INTO users_weapons (userid) VALUES ($userid)");
}11;'userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}UES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
erid) VALUES ($userid)");
}d VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
f]_weapons (userid) VALUES ($userid)");
}ill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
LUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
d VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
INSERT INTO users_weapons (userid) VALUES ($userid)&quote;);
} column to fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTOS. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
ee7b2af]if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}y what column to fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
hp]if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}y what column to fill before the keyword VALUES. Like this...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUEf(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
]s...

Code: Select all

if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}
e;INSERT INTO users_weapons (userid) VALUES ($userid)");
}f]dadee7b2af]pons (userid) VALUES ($userid)");
}if(!$user['userid']){mysql_query("INSERT INTO users_weapons (userid) VALUES ($userid)");
}