Jump to content

...error in your SQL syntax - Please help - Thanks


Recommended Posts

I am very new to all of this but maybe someone could put my on the right track - thanks a mill

 

ERROR IN FIREFOX AFTER SEARCH

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 'FROM AllData where 1=1 AND AllData.Restaurant = 1' at line 1

 

CODE - SEARCH RESULTS PAGE

<?php require_once('connections/testing.php'); ?>

<?php

//search value

 

$searchByCounty = $_POST['county'];

$searchByCategory = $_POST['category'];

 

mysql_select_db($database_Testing, $Testing);

 

$query_Recordset1 = "SELECT AllData.Restaurant, AllData.Producer, AllData.Cookery_School, AllData.Caterer, AllData.Consultant, AllData.Accomodation, AllData.Patron, AllData.Freelance, AllData.Lecturer, AllData.Name, AllData.Address1, AllData.Address2, AllData.Address3, AllData.County, AllData.Tel, AllData.Fax, AllData.Email, AllData.Website, AllData.Proprietor, AllData.Chef, AllData.Member1, AllData.Location, AllData.Description, AllData.Additional_Info, AllData.Wheelchair_Access, AllData.OH_Lunch, AllData.OH_Dinner, AllData.Closed, FROM AllData where 1=1";

if($searchByCounty !="All" && $searchByCounty !="")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.County Like '%" . $searchByCounty . "%'";

}

if ($searchByCategory =="Restaurant")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Restaurant = 1";

}

else if ($searchByCategory == "Producer")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Producer = 1";

}

else if($searchByCategory == "Cookery_School")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Cookery_School = 1";

}

else if($searchByCategory == "Caterer")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Caterer = 1";

}

else if($searchByCategory == "Consultant")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Consultant = 1";

}

else if($searchByCategory == "Accomodation")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Accomodation = 1";

}

else if($searchByCategory == "Patron")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Patron = 1";

}

else if($searchByCategory == "Freelance")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Freelance = 1";

}

else if($searchByCategory == "Lecturer")

{

$query_Recordset1 = $query_Recordset1 . " AND AllData.Lecturer = 1";

}

 

$Recordset1 = mysql_query($query_Recordset1, $Testing) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

?>

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.