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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

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

Post 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
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

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

Post 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)");
}
Post Reply