Lee-Bartlett Posted September 23, 2008 Share Posted September 23, 2008 I keep getting Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\xampp\htdocs\Website\includes\functions.php on line 10 but i cant actually see what is wrong with it, can anyone help That is my function <? php function confirm_query($result_set) { if (!$result_set) { die("database query failed: " . mysql_error()); } } function 'get_all_subjects'() { global $connect $query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_set = mysql_query($query, $connect); confirm_query ($subject_set); return $subject_set; } function = get_pages_for_subject(subject_id) { global $connect $query = "SELECT * FROM tblpages WHERE subject_id = {$subject_id["id"]}"; $page_set = mysql_query($query, $connect); confirm_query ($page_set); return $page_set; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/ Share on other sites More sharing options...
jonsjava Posted September 23, 2008 Share Posted September 23, 2008 a few errors. I cleaned them up. If you want an explanation, just ask! <?php function confirm_query($result_set) { if (!$result_set) { die("database query failed: " . mysql_error()); } } function get_all_subjects() { global $connect; $query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_set = mysql_query($query, $connect); confirm_query ($subject_set); return $subject_set; } function get_pages_for_subject($subject_id) { global $connect; $query = "SELECT * FROM tblpages WHERE subject_id = {$subject_id["id"]}"; $page_set = mysql_query($query, $connect); confirm_query ($page_set); return $page_set; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648818 Share on other sites More sharing options...
Lee-Bartlett Posted September 23, 2008 Author Share Posted September 23, 2008 Can you please show me what you cleared up, best way for me to know in the future if that is possible. Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648821 Share on other sites More sharing options...
.josh Posted September 23, 2008 Share Posted September 23, 2008 a) you don't have a closing } for your confirm_query function, you just go right into get_all_subjects function b) you had single quotes around your 2nd function name c) you don't have a ; at the end of global $connect Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648827 Share on other sites More sharing options...
jonsjava Posted September 23, 2008 Share Posted September 23, 2008 you had a space between <? and php you had single quotes around the function name get_all_subjects you forgot the semi-colon after global $connect (both spots) you had an equal sign between function and get_pages_for_subject(subject_id) you did not have a "$" in front of subject_id Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648829 Share on other sites More sharing options...
Lee-Bartlett Posted September 23, 2008 Author Share Posted September 23, 2008 Ah little bits a missed, bugging me for a while, ty guys Quote Link to comment https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.