473,700 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search Function trouble

53 New Member
Someone please help! i am writing a code for a search function and everytime i execute the code i get the following 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 'LIMIT 0,10' at line 1

i have tried to remove the line of code to see wat happens ia search result appears but with errors.

can someone please help sort this problem. [PHP]<?php
$get = $_GET['q'];
$trim = ($get);
$row_limit = 10;
if ($trim == "" ) {
echo "<p>Enter Search</p>";

if (!isset ($get)) {
echo "<p>Not Valid Search</p>";
$conn = mysql_connect ("localhost","r oot","")
or die (mysql_error ());
mysql_select_db ("noble",$co nn) or die (mysql_error()) ;
$search = "SELECT *
FROM Clothes
WHERE Clothes_Brand LIKE \"%$trim%\"
ORDER BY Clothes_Brand";
$search_res = mysql_query($se arch);
if (mysql_num_rows ($search_res) == 0 ) {
echo "<h1>Search Result</>";
echo "<p>Sorry, your search: &quot;" .$trim. "&quot; returned zero results</p>";
echo "<p><a href=\"Noble_Ho mepage.html\">S earch Again?</a></p>";
if (empty($s)){
$search_query .= "LIMIT $s,$row_limit";
$query_result = mysql_query($se arch_query) or die(mysql_error ());
echo "<p>You searched for: &quot;" .$get. "&quot;</p>";
echo "Results";
$count = 1 + $s;
while ($srch = mysql_fetch_arr ay($query_resul t)) {
$title = $srch ['Clothes_Brand'];
echo "$count.)&nbsp; $title" ;
$count++ ;
$current = (($s/$row_limit) + 1);
if ($s>=1) {
print "&nbsp;<a href=\"$PHP_SEL F?s=$previous&q =$get\">&lt;&lt ;
Prev 10</a>&nbsp&nbsp;" ;
Apr 13 '08 #1
1 1222
4,258 Recognized Expert Specialist
The concatenate result of the LIMI clause to the statement is goping to look like
Expand|Select|Wrap|Line Numbers
  1.            ORDER BY Clothes_BrandLIMIT $s,$row_limit
So you need to specify at least one blank in between.

Apr 13 '08 #2

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

Similar topics

by: Steven Spear | last post by:
Hi. I am trying to perform backtracking with this search function. Something is going wrong when I enter 2 at the command line. Entering 1 at the command line seems to work fine. I notice that backtracking never takes place. Obviously there is something wrong with my logic. I have been trying many things for many days to correct the situation, but nothing seems to help. Does anyone have any suggestions? Thanks, Steve #include...
by: Colleyville Alan | last post by:
I have a incremental search box that has been working fine for a couple of months but is now acting up. This search box is from the cd that comes with Getz's book, so I did not write it and have only a superficial understanding of how it works. I have had some trouble in the past when my code goes to another form and comes back sometimes the search function did not work properly. Then I added a line to requery it and it worked fine. ...
by: Gi | last post by:
Hello, I'm a new Php user. I'm trying to use the array functions and would like to ask a suggestion, if possible. I wrote the following sample code: <?php $test="tizio"; $test="caio";
by: zhengyan11 | last post by:
Hey, I encounter a problem when I am trying to add a pop up window on my page, which will trigger a function window.external.addSearchProvider(URL). This function will open a dialog box window. This pop up window only comes up when a user's browser is IE7 AND he is a first-time visitor. My problem is how I can recognize a person
by: markmcgookin | last post by:
Hi Folks, I have a VB app, and I have been working at it for a while, and I am now at the stage where I want to create a search function. Now don't be scared! It is in the .Net compact framework, and uses SQL Server CE as the database (This seems to scare off people trying to help! lol) but the connection and reading of data etc is all handled, and I think it is going to be a "relatively" simple function. My database has a number of fields...
by: .Net Sports | last post by:
I posed this problem last month here, but need more of a clarification, as I still cannot correctly flag a bad password. I need users to submit a passowrd that has at least one numeric character, along with any amount of string-alpha characters (8 numeric characters and 1 string character is fine, for example), but having trouble with the correct regex, as the below still doesnt raise the error alert when all strings with no numbers are...
by: AsheeG87 | last post by:
Hello Everyone! I have a linked list and am trying to include a recursive search. However, I am having trouble understanding how I would go about that. I don't quite understand a recursive search....would any of you be so kind to explain it to me...maybe include some examples. I would GREATLY appreciate it!!!
by: =?Utf-8?B?V2lsbGlhbSBQb3dlbGw=?= | last post by:
I've having trouble searching within the microsoft.public.dotnet.framework.microframework newsgroup. In the Search For: box, I enter "porting" (no quotes), select the newsgroup as listed above, and click Go. The screen repaints with no postings found - but I have clearly seen the word "porting" in the subject of one of the messages. Is this feature "broken"?
by: DeZZar | last post by:
For anyone that has the 'pleasure' of using Office 2007 you will know of one handy feature built in - its the search function housed in the record selector bar at the bottom of a form that allows to basically start typing and it will automatically search any of the fields within the form for matches and navigating to the first matching record as you type.... I would really like to be able to build this function into an Access 2003...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.