Page 1 of 1

error cod Mysql select

Posted: Tue Jun 24, 2008 9:29 am
by crinaalex
my cod is

Code: Select all

 $query= "SELECT sectia_ai.url,sectia_ai.semestru , user.username  "."  FROM sectia_ai, user "." WHERE sectia_ai.s_id = user.s_id ";
were sectia_ai and user are 2 tables and sectia_ai has 3 fieds : url , semestru , s_id
user has 2 fields : username , s_id

when i try to insert into the database :

Code: Select all

 $query = "insert into opt_alese (username ,url,semestru) values
            ('$username', '$url','$semestru')";
opt_alese is also a table where i want to insert username , url and semestru
it inserts only url and username.

pls explain to me way does insert only url and username .... and semestru doesn't :| :cry:

Re: eror cod Mysql select

Posted: Tue Jun 24, 2008 9:59 am
by jayshields
What is the value of $semestru? And what error do you get?

Re: eror cod Mysql select

Posted: Tue Jun 24, 2008 11:15 am
by crinaalex
$ semestru it is a filed in the table named : sectia , and his value is summer ... or ... winter

the error is the fact that instead of inserting in table opt_alese the all three arguments ( $semestru , $url ,$username ) , he saves only ($url, and $username ) ... and i need him to save all three in the table opt_alese

thanks for answering

Re: error cod Mysql select

Posted: Tue Jun 24, 2008 11:36 am
by jayshields
$semestru is not a field in the sectia table, it's a variable in your PHP script. I take it that

Code: Select all

INSERT INTO `opt_alese` (`username`, `url`, `semestru`) VALUES ('test', 'test', 'test')
will run fine and produce expected results. In this case, considering you haven't posted your whole script, I can only guess that $semestru is an empty string which you are inserting into your table instead of the string you actually want to insert.

error cod Mysql select

Posted: Tue Jun 24, 2008 11:48 pm
by crinaalex
am rozolvat problema ... mc oricum :)

Re: error cod Mysql select

Posted: Wed Jun 25, 2008 6:28 am
by jayshields
You're not setting the values of the variables which you are passing to add_opt. I'm guessing you've got register_globals on, and your $_POST variables are automatically being assigned to the shorthand variable names. So, if you want to get a variable from the URL, you will need to access it with the $_GET array.