Jump to content

Function Error


Lee-Bartlett

Recommended Posts

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;
}
?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/125502-function-error/
Share on other sites

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;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648818
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/125502-function-error/#findComment-648829
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.