473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MySQL Error: You have an error in your SQL syntax;

What is wrong with my SQL statement? I moved this application from a PHP4 server to a PHP5 server with a higher version of MySQL. It was working on the old server but now I am getting an error in the syntax.

Expand|Select|Wrap|Line Numbers
  1. MySQL Error: 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 24
Expand|Select|Wrap|Line Numbers
  1. SQL Statement: SELECT * FROM agency WHERE date_time LIKE '%%' AND city LIKE '%%' AND county LIKE '%%' AND impact_agenda LIKE '%%' AND agency_category LIKE '%%' AND (org_name LIKE '%%' OR address LIKE '%%' OR city LIKE '%%' OR state LIKE '%%' OR mail_address LIKE '%%' OR mail_city LIKE '%%' OR mail_state LIKE '%%' OR homepage LIKE '%%' OR name_on_501 LIKE '%%' OR org_phone LIKE '%%' OR contact_phone LIKE '%%' OR fax LIKE '%%' OR org_description LIKE '%%' OR first_name LIKE '%%' OR last_name LIKE '%%' OR email LIKE '%%' OR date_time LIKE '%%' OR impact_agenda LIKE '%%' OR agency_category LIKE '%%') ORDER BY id DESC LIMIT 0, 
Dec 30 '10 #1
4 1979
Markus
6,050 Expert 4TB
This isn't a PHP question, but a MySQL one. I'll move this thread over there.
Dec 30 '10 #2
JKing
1,206 Expert 1GB
Can you provide the actual code snippet?
Dec 30 '10 #3
Forgive me if this isn't what you are asking for as I am not an expert in MySQL. I went to the page in question and found this relevant PHP code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.             // Get filters
  3.             $year = (isset($_SESSION['year'])) ? $_SESSION['year'] : '';
  4.             $city = (isset($_SESSION['city'])) ? $_SESSION['city'] : '';
  5.             $county = (isset($_SESSION['county'])) ? $_SESSION['county'] : '';
  6.             $impact_agenda = (isset($_SESSION['impact_agenda'])) ? $_SESSION['impact_agenda'] : '';
  7.             $agency_category = (isset($_SESSION['agency_category'])) ? $_SESSION['agency_category'] : '';
  8.             $search = (isset($_SESSION['search'])) ? preg_replace('/[^a-z 0-9_-]/i', '', $db->escape($_SESSION['search'])) : '';
  9.             $sort = (isset($_SESSION['sort'])) ? $_SESSION['sort'] : '';
  10.  
  11.             $where = "date_time LIKE '%$year%' AND
  12.                       city LIKE '%$city%' AND
  13.                       county LIKE '%$county%' AND
  14.                       impact_agenda LIKE '%$impact_agenda%' AND
  15.                       agency_category LIKE '%$agency_category%' AND
  16.                       (org_name LIKE '%$search%' OR
  17.                        address LIKE '%$search%' OR
  18.                        city LIKE '%$search%' OR
  19.                        state LIKE '%$search%' OR
  20.                        mail_address LIKE '%$search%' OR
  21.                        mail_city LIKE '%$search%' OR
  22.                        mail_state LIKE '%$search%' OR
  23.                        homepage LIKE '%$search%' OR
  24.                        name_on_501 LIKE '%$search%' OR
  25.                        org_phone LIKE '%$search%' OR
  26.                        contact_phone LIKE '%$search%' OR
  27.                        fax LIKE '%$search%' OR
  28.                        org_description LIKE '%$search%' OR
  29.                        first_name LIKE '%$search%' OR
  30.                        last_name LIKE '%$search%' OR
  31.                        email LIKE '%$search%' OR
  32.                        date_time LIKE '%$search%' OR
  33.                        impact_agenda LIKE '%$search%' OR
  34.                        agency_category LIKE '%$search%')";
  35.  
  36.             $org_name_th = ($sort == 'org_name ASC') ? 'org_name DESC' : 'org_name ASC';
  37.             $org_name_img = 'bg';
  38.             if ($sort == 'org_name ASC') $org_name_img = 'asc';
  39.             if ($sort == 'org_name DESC') $org_name_img = 'desc';
  40.             $impact_th = ($sort == 'impact_agenda ASC') ? 'impact_agenda DESC' : 'impact_agenda ASC';
  41.             $impact_img = 'bg';
  42.             if ($sort == 'impact_agenda ASC') $impact_img = 'asc';
  43.             if ($sort == 'impact_agenda DESC') $impact_img = 'desc';
  44.             $agency_th = ($sort == 'agency_category ASC') ? 'agency_category DESC' : 'agency_category ASC';
  45.             $agency_img = 'bg';
  46.             if ($sort == 'agency_category ASC') $agency_img = 'asc';
  47.             if ($sort == 'agency_category DESC') $agency_img = 'desc';
  48.             $date_th = ($sort == 'id ASC') ? 'id DESC' : 'id ASC';
  49.             $date_img = 'bg';
  50.             if ($sort == 'id ASC') $date_img = 'asc';
  51.             if ($sort == 'id DESC') $date_img = 'desc';
  52.  
  53.             $count = count($db->find_all('', $where));
  54.             if ($per_page == 'All')
  55.                 $per_page = $count;
  56.             $page = (isset($_SESSION['page'])) ? $_SESSION['page'] : 1;
  57.             $offset = ($page - 1) * $per_page;
  58.             $p = new pagination;
  59.             $p->items($count);
  60.             $p->limit($per_page);
  61.             $p->adjacents(4);
  62.             $p->urlFriendly();
  63.             $p->target('manage/page/%/');
  64.             $p->currentPage($page);
  65.  
  66.             $_checked = ' checked="checked"';
  67.             $_selected = ' selected="selected"';
  68.             ?>
Dec 31 '10 #4
There was an error in the way the cookie was being set and the problem has been fixed in the application--I had to hire an experienced developer. Thank you for attempting to help me. I appreciate it.
Jan 13 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: entoone | last post by:
I'm getting the following error Parse error: parse error, expecting `','' or `';'' in /home/notarywe/public_html/php/update2.php on line 108 Here is line 108 <input type="text" name="ud_first"...
0
by: JC | last post by:
I am using Mysql version: 4.0.18-max-log and trying to populate a database from a text file using source option from inside the mysql environment. The population run OK but when creating the...
4
by: learning_C++ | last post by:
Hi, I try to use input = new istrstream(argv,strlen(argv)); in my code, but it always says error: " error: parse error before `(' token" please help me! Thanks, #include <map>
1
by: Annie | last post by:
Hi guys, I am trying to set the connection string for my database in the web.config file however it raises the funny error message: ""Error while trying to run project: Unable to start...
6
by: Thaqalainnaqvi | last post by:
IPB WARNING mysql_query() : Unable to save result set (Line: 457 of /ips_kernel/class_db_mysql.php) There appears to be an error with the database. You can try to refresh the page by clicking...
3
by: haridelphi | last post by:
I download MySQL 5.0.37 from dev.mysql.com/downloads/mysql (Windows (x86) ZIP/Setup.EXE- 37 MB). When install it, i get the Error Message as "Cannot create windows service for MySQL...
5
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
0
by: Subanesh | last post by:
Hi All, Am new to using HTMLUnit.I wrote a sample code(to emulate opening of website google.com and enter a value say "html" in the text field and click the Search button) .The code is as follows...
21
by: missflorenceokosun | last post by:
hi, am florence. i keep having a runtime error stating error in update query syntax. i have looked through my code over and over gain and seem to find no flaw. i need you guys to help me out! ...
3
by: gamereality | last post by:
Hello, this is my first post here. W00T. (Forgive me for using leet speak, it's not my fault.) Here's the rundown: I have MySQL. I have configured the PHP.INI to the correct settings,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.