Hi,
I m learning php and i am stuck at a place. i have created a function which throws a error saying no database selected. which i think is wrong because i pulled in global variable for the connection.i want to know how can i debug my function. here is the function
Code PHP:
[COLOR=#0433FF][FONT=Monaco]function [/FONT][/COLOR][COLOR=#0220B2][FONT=Monaco]get_subj_get_id[/FONT][/COLOR][COLOR=#000000][FONT=Monaco]([/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco]$id[/FONT][/COLOR][COLOR=#000000][FONT=Monaco]){[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco][COLOR=#000000]	[/COLOR]global [COLOR=#3c96a6]$con[/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#007A04][FONT=Monaco][COLOR=#000000]	[/COLOR][COLOR=#3c96a6]$query3 [/COLOR][COLOR=#0433ff]= [/COLOR][COLOR=#4c6085]mysql_query[/COLOR][COLOR=#000000]([/COLOR]"select * from subjects where id = {[COLOR=#3c96a6]$id[/COLOR]} LIMIT BY 1"[COLOR=#000000]);[/COLOR][/FONT][/COLOR]
[FONT=Monaco]	query_failed([COLOR=#3c96a6]$query3[/COLOR]);[/FONT]
[COLOR=#4C6085][FONT=Monaco][COLOR=#000000]	[/COLOR][COLOR=#0433ff]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#3c96a6]$result [/COLOR][COLOR=#0433ff]= [/COLOR]mysql_fetch_array[COLOR=#000000]([/COLOR][COLOR=#3c96a6]$query3[/COLOR][COLOR=#000000])){[/COLOR][/FONT][/COLOR]
[COLOR=#3C96A6][FONT=Monaco][COLOR=#000000]		[/COLOR][COLOR=#4c6085]echo [/COLOR]$result[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Monaco][COLOR=#000000]	}[/COLOR]else[COLOR=#000000]{[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Monaco][COLOR=#000000]		[/COLOR]exit[COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Monaco][COLOR=#000000]		[/COLOR]return [COLOR=#6b77f8]null[/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Monaco]	}[/FONT]
[FONT=Monaco]}[/FONT]
the query_failed is a function which dies when query doesn't execute. however i checked in my php error logs and it says
PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)
The line which it incidates is
Code PHP:
e[COLOR=#4C6085][FONT=Monaco]cho [/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco]$sel_subjects[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco][[/FONT][/COLOR][COLOR=#007A04][FONT=Monaco]'menu_name'[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco]][/FONT][/COLOR][COLOR=#000000][FONT=Monaco];[/FONT][/COLOR]
i m assigning the function mentioned above into
Code PHP:
[COLOR=#000000][FONT=Monaco]	[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco]if[/FONT][/COLOR][COLOR=#000000][FONT=Monaco]([/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco]isset[/FONT][/COLOR][COLOR=#000000][FONT=Monaco]([/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco]$_GET[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco][[/FONT][/COLOR][COLOR=#007A04][FONT=Monaco]'subj'[/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco]][/FONT][/COLOR][COLOR=#000000][FONT=Monaco])){[/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco][COLOR=#000000]		[/COLOR]$sel_sub [COLOR=#0433ff]= [/COLOR]$_GET[COLOR=#0433ff][[/COLOR][COLOR=#007a04]'subj'[/COLOR][COLOR=#0433ff]][/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Monaco][COLOR=#000000]		}[/COLOR]elseif[COLOR=#000000]([/COLOR]isset[COLOR=#000000]([/COLOR][COLOR=#3c96a6]$_GET[/COLOR][[COLOR=#007a04]'page'[/COLOR]][COLOR=#000000])){[/COLOR][/FONT][/COLOR]
[COLOR=#3C96A6][FONT=Monaco][COLOR=#000000]		[/COLOR]$sel_pg [COLOR=#0433ff]= [/COLOR]$_GET[COLOR=#0433ff][[/COLOR][COLOR=#007a04]'page'[/COLOR][COLOR=#0433ff]][/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#0433FF][FONT=Monaco][COLOR=#000000]	}[/COLOR]else[COLOR=#000000]{[/COLOR][/FONT][/COLOR]
[COLOR=#3C96A6][FONT=Monaco][COLOR=#000000]		[/COLOR]$sel_sub [COLOR=#0433ff]= [/COLOR][COLOR=#6b77f8]NULL[/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[COLOR=#3C96A6][FONT=Monaco][COLOR=#000000]		[/COLOR]$sel_pg [COLOR=#0433ff]= [/COLOR][COLOR=#6b77f8]NULL[/COLOR][COLOR=#000000];[/COLOR][/FONT][/COLOR]
[FONT=Monaco]	}[/FONT]
[COLOR=#000000][FONT=Monaco]	[/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco]$sel_subjects [/FONT][/COLOR][COLOR=#0433FF][FONT=Monaco]= [/FONT][/COLOR][COLOR=#000000][FONT=Monaco]get_subj_get_id([/FONT][/COLOR][COLOR=#3C96A6][FONT=Monaco]$sel_sub[/FONT][/COLOR][COLOR=#000000][FONT=Monaco]);
[/FONT][/COLOR]
wht am i doing wrong and why the errors on web browser is different then php error log? how can i fix it.