Hi i'm new to this so pls bear with me!
I'm building a website using Dreamweaver, mysql, php and Apache for a uni project. it is a site for a college that allows the user to search for a course and enrol on one. I have a page where the user can search for a course using a form with 4 search options. they use drop down boxes with more options to search with ie course category has computing, health and fitness, languages or art. centre has 4 centres to choose from etc.
if no options are chosen then all courses are returned ie if they dont wish to search using centre than all centres are included.they choose their search options and press submit and then should be taken to a list of courses that fitted their search.
i have followed this help page
http://www.macromedia.com/support/ultradev/building/multiple_param_search/
and
this is my code
<?php require_once('../Connections/connEnrolment.php'); ?>
<?php
if ($HTTP_POST_VARS["courseCat"] == "comp")
{
$cCat = "comp";
}
else if ($HTTP_POST_VARS["courseCat"] == "art")
{
$cCat = "art";
}
else if ($HTTP_POST_VARS["courseCat"] == "health")
{
$cCat = "health";
}
else if ($HTTP_POST_VARS["courseCat"] == "lang")
{
$cCat = "lang";
}
else
{
$cCat = "";
}
?>
<?php
if ($HTTP_POST_VARS["whichCentre"] == "Elwill")
{
$cCentre = "Elwill";
}
else if ($HTTP_POST_VARS["whichCentre"] == "Malmains")
{
$cCentre = "Malmains";
}
else if ($HTTP_POST_VARS["whichCentre"] == "Oval")
{
$cCentre = "Oval";
}
else if ($HTTP_POST_VARS["whichCentre"] == "Windsor")
{
$cCentre = "Windsor";
}
else
{
$cCentre = "";
}
?>
<?php
if ($HTTP_POST_VARS["whatDay"] == "Monday")
{
$cDay = "mon";
}
else if ($HTTP_POST_VARS["whatDay"] == "Tuesday")
{
$cDay = "tues";
}
else if ($HTTP_POST_VARS["whatDay"] == "Wednesday")
{
$cDay = "wed";
}
else if ($HTTP_POST_VARS["whatDay"] == "Thursday")
{
$cDay = "Thurs";
}
else if ($HTTP_POST_VARS["whatDay"] == "Friday")
{
$cDay = "fri";
}
else if ($HTTP_POST_VARS["whatDay"] == "Saturday")
{
$cDay = "sat";
}
else if ($HTTP_POST_VARS["whatDay"] == "Sunday")
{
$cDay = "sun";
}
else
{
$cDay = "*";
}
?>
<?php
if ($HTTP_POST_VARS["whatTime"] == "Day")
{
$cTime = "day";
}
else if ($HTTP_POST_VARS["whatTime"] == "Evening")
{
$cTime = "evening";
}
else if ($HTTP_POST_VARS["whatTime"] == "Weekend")
{
$cTime = "weekend";
}
else
{
$cTime = "*";
}
?>
<?php
$cCat_rsCourse = "";
if (isset($cCat)) {
$cCat_rsCourse = (get_magic_quotes_gpc()) ? $cCat : addslashes($cCat);
}
$cCentre_rsCourse = "";
if (isset($cCentre)) {
$cCentre_rsCourse = (get_magic_quotes_gpc()) ? $cCentre : addslashes($cCentre);
}
$cDay_rsCourse = "";
if (isset($cDay)) {
$cDay_rsCourse = (get_magic_quotes_gpc()) ? $cDay : addslashes($cDay);
}
$cTime_rsCourse = "";
if (isset($cTime)) {
$cTime_rsCourse = (get_magic_quotes_gpc()) ? $cTime : addslashes($cTime);
}
mysql_select_db($database_connEnrolment, $connEnrolment);
$query_rsCourse = sprintf("SELECT * FROM courses WHERE Category='$cCat' OR Centre='$cCentre' OR Day='$cDay' OR DayTime='$cTime", $cCat_rsCourse,$cCentre_rsCourse,$cDay_rsCourse,$cTime_rsCourse);
$rsCourse = mysql_query($query_rsCourse, $connEnrolment) or die(mysql_error());
$row_rsCourse = mysql_fetch_assoc($rsCourse);
$totalRows_rsCourse = mysql_num_rows($rsCourse);
?>
but i still get this error when i test it
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''*' at line 1"
?????????
please help me! i'm new to dreamweaver, php, and mysql and hate them too!