Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.