0

Hi.

I am having problems getting PHP to insert data into a MYSQL data base. I am using the following variations of syntax.

mysql_query("INSERT INTO table member VALUES ('$var1', '$var2', '$var3')")
			or die("couldn't add new user");

and also with session variables as well

mysql_query("INSERT INTO table member VALUES ('$_SESSION[$var1]', '$_SESSION[$var2], '$_SESSION[$var3]')")
			or die("couldn't add new user");

i have put all these through a print statement to make sure the variables ae set and they print in the same block of code so i have no idea what i am doing wrong.?

3
Contributors
3
Replies
7
Views
7 Years
Discussion Span
Last Post by leviathan185
0

U need to specify the table structure to solve this.
The above code will work only if all the field types varchar or similar types, i mean those cannot be an int.

if that is not ur problem try specify which each column like

INSERT INTO table member (c1,c2,c3) VALUES ('$var1', '$var2', '$var3')
0

I am not really sure what i was doing wrong.... All I done is completely re-write that section of code, i can see i missed a ' in my examples bt i was copyig and pasting and they were in my origional code...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.