Welcome Guest, Not a member yet? Register   Sign In
Mysql Custom Select
#4

(This post was last modified: 01-04-2015, 10:52 AM by Jamie. Edit Reason: Incorporated links for CI2/CI3 documentations )

(01-03-2015, 10:34 PM)nahid.tct Wrote: I use below query:

$query = $this->db->query('select * from class_routine where semester='$semester' and day='$day' and time_schedule='$time_schedule' and (batch='$batch_no' or section='$section' or teacher='$teacher' or room='$room');');

And I get this error:

Parse error: syntax error, unexpected '$semester' (T_VARIABLE) in C:\xampp\htdocs\crm\application\models\m_class_routine.php on line 9

Hi Nahid.tct,

Either of the following should work. In your query string you are failing to join the string data with the full stop (period) character.

PHP Code:
$query $this->db->query('select * from class_routine where semester='.$semester.' and day='.$day.' and time_schedule='.$time_schedule.' and (batch='.$batch_no.' or section='.$section.' or teacher='.$teacher.' or room='.$room.');'); 

or

PHP Code:
$query $this->db->query("select * from class_routine where semester='$semester' and day='$day' and time_schedule='$time_schedule' and (batch='$batch_no' or section='$section' or teacher='$teacher' or room='$room');"); 

Hope this helps  Smile

You may wish to take a look at the query builder class: CI2 | CI3. Whilst your method would work it's always nice to learn a new method, eh? and it may help simplify your future database queries Smile
Jamie Bond
Full time International Development undergraduate.
Part time website developer.
Reply


Messages In This Thread
Mysql Custom Select - by nahid.tct - 01-03-2015, 03:59 AM
RE: Mysql Custom Select - by bclinton - 01-03-2015, 09:07 AM
RE: Mysql Custom Select - by nahid.tct - 01-03-2015, 10:34 PM
RE: Mysql Custom Select - by Jamie - 01-04-2015, 10:15 AM
RE: Mysql Custom Select - by nahid.tct - 01-04-2015, 11:37 AM
RE: Mysql Custom Select - by InsiteFX - 01-05-2015, 04:45 AM
RE: Mysql Custom Select - by bclinton - 01-05-2015, 09:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB