error cod Mysql select

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crinaalex
Forum Newbie
Posts: 3
Joined: Tue Jun 24, 2008 9:15 am

error cod Mysql select

Post 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:
Last edited by crinaalex on Tue Jun 24, 2008 11:20 am, edited 1 time in total.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: eror cod Mysql select

Post by jayshields »

What is the value of $semestru? And what error do you get?
crinaalex
Forum Newbie
Posts: 3
Joined: Tue Jun 24, 2008 9:15 am

Re: eror cod Mysql select

Post 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
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: error cod Mysql select

Post 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.
crinaalex
Forum Newbie
Posts: 3
Joined: Tue Jun 24, 2008 9:15 am

error cod Mysql select

Post by crinaalex »

am rozolvat problema ... mc oricum :)
Last edited by crinaalex on Fri Jun 27, 2008 1:02 pm, edited 1 time in total.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: error cod Mysql select

Post 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.
Post Reply